Adafruit TSL2591 High Dynamic Range Digital Light Sensor Created by lady ada Last updated on 2018-03-06 12:44:15 AM UTC
Guide Contents Guide Contents Overview Pinouts 2 3 6 Power Pins: I2C Logic pins: Other Pins: 6 6 6 Assembly 7 Prepare the header strip: Add the breakout board: And Solder! 7 8 8 Wiring & Test Install Adafruit_TSL2591 library Install Adafruit_Sensor Load Demo Library Reference 10 10 11 11 13 Constructor Gain and Timing Unified Sensor API void getEvent(sensors_event_t*) void getSensor(sensor_t*) Raw Data Access API 13 13 14 14 15 16 Arduino Library Docs CircuitPython Usage Downloads 18 19 20 23
Overview When the future is dazzlingly-bright, this ultra-high-range luminosity sensor will help you measure it. The TSL2591 luminosity sensor is an advanced digital light sensor, ideal for use in a wide range of light situations. Compared to low cost CdS cells, this sensor is more precise, allowing for exact lux calculations and can be configured for different gain/timing ranges to detect light ranges from up to 188uLux up to 88,000 Lux on the fly.
This sensor is much like the TSL2561 but with a wider range (and the interface code is different). This sensor has a massive 600,000,000:1 dynamic range! Unlike the TSL2561 you cannot change the I2C address either, so keep that in mind. © Adafruit Industries https://learn.adafruit.
The built in ADC means you can use this with any microcontroller, even if it doesn't have analog inputs. The current draw is extremely low, so its great for low power data-logging systems. about 0.4mA when actively sensing, and less than 5 uA when in power-down mode. © Adafruit Industries https://learn.adafruit.
Pinouts The TSL2591 is a I2C sensor. That means it uses the two I2C data/clock wires available on most microcontrollers, and can share those pins with other sensors as long as they don't have an address collision. For future reference, the I2C address is 0x29 and you can't change it! Power Pins: Vin - this is the power pin. Since the chip uses 3 VDC, we have included a voltage regulator on board that will take 3-5VDC and safely convert it down.
Assembly Prepare the header strip: Cut the strip to length if necessary. It will be easier to solder if you insert it into a breadboard - long pins down © Adafruit Industries https://learn.adafruit.
Add the breakout board: Place the breakout board over the pins so that the short pins poke through the breakout pads © Adafruit Industries https://learn.adafruit.
And Solder! Be sure to solder all pins for reliable electrical contact. (For tips on soldering, be sure to check out our Guide to Excellent Soldering (https://adafru.it/aTk)). © Adafruit Industries https://learn.adafruit.
You're done! Check your solder joints visually and continue onto the next steps © Adafruit Industries https://learn.adafruit.
Wiring & Test You can easily wire this breakout to any microcontroller, we'll be using an Arduino. For another kind of microcontroller, just make sure it has I2C, then port the code - its pretty simple stuff! Connect Vin to the power supply, 3-5V is fine. Use the same voltage that the microcontroller logic is based off of. For most Arduinos, that is 5V Connect GND to common power/data ground Connect the SCL pin to the I2C clock SCL pin on your Arduino.
And type in adafruit tsl2591 to locate the library. Click Install We also have a great tutorial on Arduino library installation at: http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use Install Adafruit_Sensor The TSL2591 library uses the Adafruit_Sensor support backend so that readings can be normalized between sensors.
Thats it! Now open up the serial terminal window at 9600 speed to begin the test. Try covering with your hand or shining a lamp onto the sensor to experiment with the light levels! © Adafruit Industries https://learn.adafruit.
Library Reference The Adafruit_TSL2591 library contains a number of public functions to help you get started with this sensor. Constructor To create an instance of the Adafruit_TSL2591 driver, simple declare an appropriate object, along with a 32-bit numeric value to identify this sensor (in case you have several TSL2591s and want to track them separately in a logging system).
/**************************************************************************/ /* Configures the gain and integration time for the TSL2561 */ /**************************************************************************/ void configureSensor(void) { // You can change the gain on the fly, to adapt to brighter/dimmer light situations //tsl.setGain(TSL2591_GAIN_LOW); // 1x gain (bright light) tsl.setGain(TSL2591_GAIN_MED); // 25x gain //tsl.
results, as shown in the following code: /**************************************************************************/ /* Performs a read using the Adafruit Unified Sensor API. */ /**************************************************************************/ void unifiedSensorAPIRead(void) { /* Get a new sensor event */ sensors_event_t event; tsl.getEvent(&event); /* Display the results (light is measured in lux) */ Serial.print("[ "); Serial.print(event.timestamp); Serial.print(" ms ] "); if ((event.
/**************************************************************************/ /* Displays some basic information on this sensor from the unified sensor API sensor_t type (see Adafruit_Sensor for more information) */ /**************************************************************************/ void displaySensorDetails(void) { sensor_t sensor; tsl.getSensor(&sensor); Serial.println("------------------------------------"); Serial.print ("Sensor: "); Serial.println(sensor.name); Serial.
values, as shown in the code below: /**************************************************************************/ /* Show how to read IR and Full Spectrum at once and convert to lux */ /**************************************************************************/ void advancedRead(void) { // More advanced data read example. Read 32 bits with top 16 bits IR, bottom 16 bits full spectrum // That way you can do whatever math and comparisons you want! uint32_t lum = tsl.
Arduino Library Docs Arduino Library Docs (https://adafru.it/AvJ) © Adafruit Industries https://learn.adafruit.
CircuitPython It's easy to use the TSL2591 sensor with CircuitPython and the Adafruit CircuitPython TSL2591 module. This module allows you to easily write Python code that reads the luminosity and more from the sensor. First wire up a TSL2591 to your board exactly as shown on the previous pages for Arduino using an I2C connection.
Next connect to the board's serial REPL so you are at the CircuitPython >>> prompt. Usage To demonstrate the usage of the sensor we'll initialize it and read the luminosity from the board's Python REPL. Run the following code to import the necessary modules and initialize the I2C connection with the sensor: import board import busio import adafruit_tsl2591 i2c = busio.I2C(board.SCL, board.SDA) sensor = adafruit_tsl2591.
adafruit_tsl2591.GAIN_MED - 25x gain (the default) adafruit_tsl2591.GAIN_HIGH - 428x gain adafruit_tsl2591.GAIN_MAX - 9876x gain integration_time - Set the integration time of the sensor to a value of: adafruit_tsl2591.INTEGRATIONTIME_100MS - 100ms (the default) adafruit_tsl2591.INTEGRATIONTIME_200MS - 200ms adafruit_tsl2591.INTEGRATIONTIME_300MS - 300ms adafruit_tsl2591.INTEGRATIONTIME_400MS - 400ms adafruit_tsl2591.INTEGRATIONTIME_500MS - 500ms adafruit_tsl2591.INTEGRATIONTIME_600MS - 600ms sensor.
# Simple demo of the TSL2591 sensor. # every second. import time Will print the detected light value import board import busio import adafruit_tsl2591 # Initialize the I2C bus. i2c = busio.I2C(board.SCL, board.SDA) # Initialize the sensor. sensor = adafruit_tsl2591.TSL2591(i2c) # You can optionally change the gain and integration time: #sensor.gain = adafruit_tsl2591.GAIN_LOW (1x gain) #sensor.gain = adafruit_tsl2591.GAIN_MED (25x gain, the default) #sensor.gain = adafruit_tsl2591.
Downloads Datasheets & Files TSL2591 Datasheet EagleCAD PCB files on GitHub Fritzing object in Adafruit Fritzing library Schematic Layout (Dimensions are in Inches) © Adafruit Industries Last Updated: 2018-03-06 12:44:14 AM UTC Page 24 of 24