Discuss development of drivers for external hardware and components, such as LCD screens, sensors, motor drivers, etc.
Target audience: Users and developers of drivers.
Post Reply
User avatar
Posts: 4
Joined: Sun Jan 06, 2019 3:27 pm


Post by palouf34 » Sun Jan 06, 2019 3:54 pm

Good morning, everyone,

I'm looking to program a nodemcu (esp8266) with an external component that is the veml7700.
here is the datasheet:
here is the tutorial for arduino. ... U:_SEN0228
a solution made of pure python.
I try to adapt it but I block completely on the byte reader.
if a nice person could guide me through how the functions work:
I2C.readfrom_memem(addr, memaddr, nbytes, *, addrsize=8)
I2C.readfrom_mem_into(addr, memaddr, buf, *, addrsize=8)
the same for their equivalent in writing mode.

here is my program start

Code: Select all

#station meteo
#import standard library
import machine
import time

from ustruct import unpack, unpack_from
from array import array

# import special library
import bme280
import bh1750  # librairie capteur BH1750

#start configuration machine

machine.freq(160000000) # set the CPU frequency to 160 MHz

#end of configurartion machine

# address  of external captor
bme280_addr = 0x76
vmle7700_addr = 0x10

# activate i2c port
i2c = machine.I2C(scl=machine.Pin(5),sda=machine.Pin(4))

#create  BJ1750 "object"
capteur_lumiere = bh1750.BH1750(i2c) 

#start software

#start scan i2c buss
print('Scan i2c bus...')
devices = i2c.scan()

if len(devices) == 0:
  print("No i2c device !")
  print('i2c devices found:',len(devices))

  for device in devices:  
    print("Decimal address: ",device," | Hexa address: ",hex(device))

#end scan i2c bus

print("debut calcul")
while i<2:
    tempo = unpack('<h',word)
    print("tempo 1 : ",tempo)
    tempo = unpack('>h',word)
    print("tempo => ",tempo)

    gain = 1.8432 #Gain for 1/8 gain & 25ms IT
    if (capteur_lumiere.detect()):
      mesure_lux = capteur_lumiere.lecture_lumiere(bh1750.MODE_CONTINU_HAUTE_RESOLUTION)
      print("Valeur BH1750 : ")
      print("la mesure est  de ", mesure_lux, " lux")
    else :
          print("Capteur BH1750 non")
    print("Fin boucle")

User avatar
Posts: 4
Joined: Sun Jan 06, 2019 3:27 pm

Re: VEML7700

Post by palouf34 » Fri Jan 18, 2019 10:15 am


I have made good progress on the creation of this new lib.
I still have some tests to do before I push my source on github so that other people with this module can use it simply without breaking my head too much.

thank you

User avatar
Posts: 4
Joined: Sun Jan 06, 2019 3:27 pm

Re: VEML7700

Post by palouf34 » Tue Jan 22, 2019 9:52 am

I pushed on github my version of this library.

I have tested it in several situations and it is stable. if you encounter bugs do not hesitate to open a request on github for me to fix the anomalies.

thank you to you.

Post Reply