DLIGHT - read from microPython
-
I have an ATOM S3 Lite with a DLIGHT connected to the Grove interface. DLIGHT is the "Ambient Light Unit" with a light sensor of some kind. I have the UIFlow v2 on the ATOM, so microPython is working. I want to read the values from the DLIGHT sensor.
I have code like the following:import machine i2c = machine.SoftI2C(scl=machine.Pin(32), sda=machine.Pin(26)) i2c.scan() i2c.readfrom(35, 2)
the scan() function returns [35] so I presume it is connecting successfully.
But the readfrom() always returns b'\x00\x00' no matter what brightness the light is on the sensor.
Is there something else I need to do, to initialize the DLIGHT?
Or do I need to pass 'freq' or other parameters when I create the i2c object? -
If this:
https://docs.m5stack.com/en/core/AtomS3 Lite
is your unit, maybe try pins scl 1 and sda 2 ?
Works (on Arduino IDE, anyway), for me!
-Terry -
Actually I mis-identified my module, it's ATOM LITE not ATOM S3 LITE on closer inspection (the names of these things can be confusing). I got the pin numbers scl 32 and sda 26 from the legend on the device itself, and I think they must be correct since it is able to reply with the [35] from the scan() function.
I tried looking at the Arduino code from GitHub to see if it does some kind of initialization of the DLIGHT before reading, but I can't figure it out.
Anyway thanks for replying Terry.