adafruit / Adafruit_CircuitPython_TSL2561

CircuitPython driver for TSL2561 Light Sensor
MIT License
4 stars 7 forks source link

How to install on Micropython? #35

Closed janjagusch closed 3 years ago

janjagusch commented 3 years ago

Hi, thanks for maintaining this package! :+1:

I'm currently struggling to use a TSL2561 sensor with a ESP8266 microcontroller running micropython on the esp8266-20200911-v1.13 firmware.

Trying to install the driver with upip returns a generic error message.

>>> import upip
# upip fails to install the tsl2561 driver
>>> upip.install("adafruit-circuitpython-tsl2561")
Installing to: /lib/
# The following warning is always printed when running `upip.install` for the first time in a session
# and I don't believe it's related to the library specifically
Warning: micropython.org SSL certificate is not validated
Error installing 'adafruit-circuitpython-tsl2561': , packages may be partially installed
# just to demonstrate that upip succeeds to install some other package
>>> upip.install('micropython-uasyncio')
Installing to: /lib/
Installing micropython-uasyncio 2.0 from https://micropython.org/pi/uasyncio/uasyncio-2.0.tar.gz
Installing micropython-uasyncio.core 2.0 from https://micropython.org/pi/uasyncio.core/uasyncio.core-2.0.tar.gz

Since this is the same library I have also installed on my Raspberry Pi Zero (where it's working correctly), I can imagine that this library or its dependencies contain code that might not be compatible with the ESP8266. This could explain the failed installation, even though I'm not sure.

By the way, I also tried using the deprecated micropython-adafruit-tsl2561. There the installation is trivial (cp tsl2561.py /pyboard/) but the luminosity values seem incorrect (well, it's a deprecated library after all).

Could you maybe clear up whether this TSL2561 driver should support a ESP8266 running micropython? If not, maybe it would be good to add a list of supported devices or firmwares. Because to me it looks a bit like this library would only run on computers, like the Raspberry Pi.

janjagusch commented 3 years ago

Ok, just realized that you should run the circuitpython firmware, as instructed int he module docstring. Will try that and report how it goes.

Update: Turns out that circuitpyhon does not support the ESP8266 anymore (source).

ladyada commented 3 years ago

correct this code is for circuitpython for micropython you could try this code, it is completely unsupported https://github.com/adafruit/micropython-adafruit-tsl2561