elschopi / micropython-tsl2591

Port of maxlklaxl/python-tsl2591for micropython-based devices like the ESP8266.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Micropython TSL2591 module

This is a simple python library for the Adafruit TSL2591 breakout board based on the Arduino library from Adafruit. python-tsl2591 was developed to work on a Raspberry PI. I then forked it to create a Micropython version. There were two changes from the original:

  1. Micropython does not provide an smbus api, so smbus was emulated on top of the lower-level I2C library it does provide.
  2. The ESP8266 and other chips are severely memory limited. With the Raspberry Pi version, even importing the tsl2591 module caused it to run out of memory on the ESP8266. The code was simplified were possible and all the comments stripped out.

INFO

Coming soon...

Installing

Just copy tsl2591.py to your micropython board. Micropython's webrepl has experimental support for copying files. I instead used the mpfshell to copy files to my ESP8266 board.

Quickstart

import tsl2591

tsl = tsl2591.Tsl2591()  # initialize
full, ir = tsl.get_full_luminosity()  # read raw values (full spectrum and ir spectrum)
lux = tsl.calculate_lux(full, ir)  # convert raw values to lux
print lux, full, ir

License

Python files in this repository are released under the MIT license.

About

Port of maxlklaxl/python-tsl2591for micropython-based devices like the ESP8266.

License:Other


Languages

Language:Python 100.0%