Hi, it’s my first post on the zerynth comunity.
I am trying to write the driver for the ambient light and proximity sensor (VCNL4010) with DOIT esp32, but since it’s my first time ever trying to write a driver, it doesn’t work. I was hoping you could help me (probably its just stupid mistakes anyway)
The error shows up the first i2c.write in the init_VCNL4010 function.
P.S. since its my first post please be patient if i violated code of conduct
# sensor software reset
#send the command for enabling the sampling mode
my_p.write_bytes(0x80,0x02) """ Addressing. The first byte of an I2C transfer contains the slave address and the data direction. The address is 7 bits long, followed by the direction bit. ... Thus, only 112 addresses are available with the 7 bit address scheme. To get rid of this a special method for using 10 bit addresses is defined. """ #my_p.write(0x80) #my_p.write(0x02) print("init went good")
return (lo << 8 | (hi & 0xFF))
#resolution is on 16-bits so i need 0xFF in this case
#shifting leaves first 8 bits to 0
#while the & with hi makes it so that if needed some bits can
#be set to 0, given a lower-than-16-bits resolution
while True: #read proximity port.write(0x87) sleep(20) data=port.read(2) proximity_raw_value = build_value(data, data) print('Proximity raw value = ', proximity_raw_value) print('Proximity value = ', proximity_raw_value) print('_____________________________________') sleep(2000)
except Exception as e: