ArduinoGeneral

SKU:SEN0390 light sensor help

userHead Account cancelled 2021-09-14 04:44:28 537 Views0 Replies
Hi All,

I was looking for some help. I'm trying to get the light sensor to work with a pico via I2C using mircopython. I have successfully connected and detected the sensor, however, I'm not sure what to do next. If I read the sensor, I just get 0x00 as the returned value all the time. Do I need to set the configuration profile first on the chip? If so, how do I achieve this in MicroPython?

My code so far, and the output:

import machine
sda=machine.Pin(0)
scl=machine.Pin(1)
i2c=machine.I2C(0,sda=sda, scl=scl, freq=400000)

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))

print(i2c.readfrom(74,5))

output::

Scan i2c bus...
i2c devices found: 1
Decimal address: 74 | Hexa address: 0x4a
b'\x00\x00\x00\x00\x00'

thanks in advance.