This is an example application for the TAOS TSL2561 Light-to-Digital Converter device.
It is written and tested for v3.3 of the ESP-IDF environment, using the xtensa-esp32-elf toolchain (gcc version 5.2.0).
Ensure that submodules are cloned:
$ git clone --recursive https://github.com/DavidAntliff/esp32-tsl2561-example.git
Build the application with:
$ cd esp32-tsl2561-example.git
$ idf.py menuconfig # set your serial configuration and the I2C GPIO - see below
$ idf.py -p (PORT) flash monitor
The program should detect your connected device and periodically obtain a light reading from it, displaying it on the console.
This application makes use of the following components (included as submodules):
- components/esp32-smbus
- components/esp32-tsl2561
To run this example, connect one TSL2561 device to two GPIOs on the ESP32 (I2C SDA and SCL). If external pull-up resistors are not provided with the sensor, add a 10 KOhm resistor from each GPIO to the 3.3V supply.
idf.py menuconfig
can be used to set the I2C GPIOs and TSL2561 device I2C address.
The TSL2561 can be set to one of three I2C addresses depending on the connection state of the ADDR SEL pin:
- If ADDR SEL is tied to ground, the address is 0x29.
- If ADDR SEL is floating (not connected), the address is 0x39.
- If ADDR SEL is tied to VCC (3.3V), the address is 0x49.
This example provides:
- Visible, InfraRed and Full Spectrum light level measurements.
- Lux calculation .
- Compile-time selection of integration time and gain.
The source is available from GitHub.
The code in this project is licensed under the MIT license - see LICENSE for details.
"I2C" is a registered trademark of Phillips Corporation.
"SMBus" is a trademark of Intel Corporation.