VEML7700

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
palouf34
Posts: 4
Joined: Sun Jan 06, 2019 3:27 pm
Contact:

VEML7700

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: http://www.vishay.com/docs/84323/designingveml7700.pdf
here is the tutorial for arduino.
https://www.dfrobot.com/wiki/index.php/ ... 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)
and
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 !")
else:
  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")
i=0
while i<2:
   
    word=i2c.readfrom_mem(vmle7700_addr,6,2)
    print(word)
    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")
      time.sleep(1)
    else :
          print("Capteur BH1750 non")
    print("Fin boucle")
    i=i+1

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

Re: VEML7700

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

Hello,

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
palouf34
Posts: 4
Joined: Sun Jan 06, 2019 3:27 pm
Contact:

Re: VEML7700

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

I pushed on github my version of this library.

https://github.com/palouf34/veml7700

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