TSL2561 Luminosity Sensor



Similar documents
Adafruit MCP9808 Precision I2C Temperature Sensor Guide

Adafruit SHT31-D Temperature & Humidity Sensor Breakout

Adafruit BME280 Humidity + Barometric Pressure + Temperature Sensor Breakout

DS1307 Real Time Clock Breakout Board Kit

2.2" TFT Display. Created by Ladyada. Last updated on :15:09 PM EDT

Thermistor. Created by Ladyada. Last updated on :30:46 PM EDT

Tiny Arduino Music Visualizer

Using the Adafruit Unified Sensor Driver. Created by Kevin Townsend

Adafruit Si4713 FM Radio Transmitter with RDS/RDBS Support

Adafruit LSM9DS0 Accelerometer + Gyro + Magnetometer 9-DOF Breakouts

1.5" & 2.1" Monochrome 128x64 OLED Display Module

2.3" Monochrome 128x32 OLED Display Module

Character LCDs. Created by Ladyada. Last updated on :45:29 PM EDT

MCP4725 Digital to Analog Converter Hookup Guide

Adding a Real Time Clock to Raspberry Pi

Data Acquisition Module with I2C interface «I2C-FLEXEL» User s Guide

1.8" TFT Display Breakout and Shield

A REST API for Arduino & the CC3000 WiFi Chip

Adafruit ATWINC1500 WiFi Breakout

UniPi technical documentation REV 1.1

Arduino Lesson 0. Getting Started

Matrix and 7-Segment LED Backpack with the Raspberry Pi

Designing VM2 Application Boards

Building a Basic Communication Network using XBee DigiMesh. Keywords: XBee, Networking, Zigbee, Digimesh, Mesh, Python, Smart Home

Arduino Lesson 13. DC Motors. Created by Simon Monk

RGB LED Strips. Created by lady ada. Last updated on :00:18 PM EST

AR1100 Resistive Touch Screen Controller Guide

Arduino Due Back. Warning: Unlike other Arduino boards, the Arduino Due board runs at 3.3V. The maximum. Overview

Arduino Lesson 4. Eight LEDs and a Shift Register

QUICK START GUIDE FOR DEMONSTRATION CIRCUIT BIT DIFFERENTIAL ADC WITH I2C LTC2485 DESCRIPTION

PN532 NFC RFID Module User Guide

Arduino ADK Back. For information on using the board with the Android OS, see Google's ADK documentation.

Adafruit Proto Shield for Arduino

Battery Power for LED Pixels and Strips. Created by Phillip Burgess

Electronic Rotary Table Divider V2.1 Construction

Arduino Lesson 14. Servo Motors

Tire pressure monitoring

IR Communication a learn.sparkfun.com tutorial

Real Time Clock USB Evaluation Board V3.0

DS1307ZN. 64 x 8 Serial Real-Time Clock

Bluetooth + USB 16 Servo Controller [RKI-1005 & RKI-1205]

Surveillance System Using Wireless Sensor Networks

The $25 Son of a cheap timer This is not suitable for a beginner. You must have soldering skills in order to build this kit.

Hardware Connections between Arduino and IMU Nori Wilkins Apr. 5, 2013

7 OUT1 8 OUT2 9 OUT3 10 OUT4 11 OUT5 12 OUT6 13 OUT7 14 OUT8 15 OUT9 16 OUT10 17 OUT11 18 OUT12 19 OUT13 20 OUT14 21 OUT15 22 OUT16 OUT17 23 OUT18

Temperature Sensors. Resistance Temperature Detectors (RTDs) Thermistors IC Temperature Sensors

Measuring Resistance Using Digital I/O

C4DI Arduino tutorial 4 Things beginning with the letter i

PICAXE DATALOGGER (AXE110P)

Using Arduino Microcontrollers to Sense DC Motor Speed and Position

Adafruit LED Backpacks

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science Microprocessor Project Laboratory

Data Sheet. Adaptive Design ltd. Arduino Dual L6470 Stepper Motor Shield V th November L6470 Stepper Motor Shield

DIY Pocket LED Gamer - Tiny Tetris!

ic-mq EVAL MQ1D EVALUATION BOARD DESCRIPTION

Pololu DRV8835 Dual Motor Driver Shield for Arduino

Arduino Lesson 17. Sending Movement Detector

Arduino Lesson 5. The Serial Monitor

Controlling a Dot Matrix LED Display with a Microcontroller

QUICK START GUIDE FOR DEMONSTRATION CIRCUIT 994 THREE CHANNEL LED BALLASTER WITH PWM LT3003 DESCRIPTION

PCAN-MicroMod Universal I/O Module with CAN Interface. User Manual. Document version ( )

UPS PIco. to be used with. Raspberry Pi B+, A+, B, and A. HAT Compliant. Raspberry Pi is a trademark of the Raspberry Pi Foundation

CAN-Bus Shield Hookup Guide

User and installation manual

KTA-223 Arduino Compatible Relay Controller

1 Coffee cooling : Part B : automated data acquisition

Advanced Data Capture and Control Systems

MXL5007T TUNER RADIO

How to use the OMEGALOG software with the OM-SQ2010/SQ2020/SQ2040 Data Loggers.

Arduino Lesson 9. Sensing Light

System theremino MasterDIL-V3

Develop a Dallas 1-Wire Master Using the Z8F1680 Series of MCUs

WinLIN Setup and Operation:

The components. E3: Digital electronics. Goals:

Bob Rathbone Computer Consultancy

USING I2C WITH PICAXE

Cornerstone Electronics Technology and Robotics I Week 15 Voltage Comparators Tutorial

If an occupancy of room is zero, i.e. room is empty then light source will be switched off automatically

USB2.0 <=> I2C V4.4. Konverter Kabel und Box mit Galvanischetrennung

Monitor Your Home With the Raspberry Pi B+

USB to serial chip CH340

Build Instructions for TempBug: Internet-Connected Thermometer Step 1: Gather the parts

The Bus (PCI and PCI-Express)

Pmod peripheral modules are powered by the host via the interface s power and ground pins.

By: John W. Raffensperger, Jr. Revision: 0.1 Date: March 14, 2008

How to Make a Pogo Pin Test Jig. Created by Tyler Cooper

Flight Controller. Mini Fun Fly

MODULE BOUSSOLE ÉLECTRONIQUE CMPS03 Référence :

Setting up IO Python Library on BeagleBone Black

Adafruit Music Maker Shield

DATASHEET. ADAM Arduino Display Adaptor Module. Arduino Compatible Shield P/N: 4Display-Shield-FT843 For the 4D Systems 4DLCD-FT843 Display

PIR Motion Sensor. Created by Ladyada. Last updated on :15:25 PM EST

A Digital Timer Implementation using 7 Segment Displays

The self-starting solar-powered Stirling engine

DS1621 Digital Thermometer and Thermostat

Analog control unit for mobile robots

Accessing I2C devices with Digi Embedded Linux 5.2 example on Digi Connect ME 9210

Electronic Brick of Current Sensor

IS31FL3731 AUDIO MODULATED MATRIX LED DRIVER. May 2013

ARDUINO SEVERINO SERIAL SINGLE SIDED VERSION 3 S3v3 (REVISION 2) USER MANUAL

Transcription:

TSL2561 Luminosity Sensor Created by lady ada Last updated on 2015-06-12 12:10:28 PM EDT

Guide Contents Guide Contents Overview Wiring the TSL2561 Sensor Using the TSL2561 Sensor Downloads Buy a TSL2561 Sensor 2 3 5 8 13 14 Adafruit Industries https://learn.adafruit.com/tsl2561 Page 2 of 14

Overview The TSL2561 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 0.1-40,000+ Lux on the fly. The best part of this sensor is that it contains both infrared and full spectrum diodes! That means you can seperately measure infrared, full-spectrum or humanvisible light. Most sensors can only detect one or the other, which does not accurately represent what human eyes see (since we cannot perceive the IR light that is detected by most photo diodes). The sensor has a digital (i2c) interface. You can select one of three addresses so you can have up to three sensors on one board - each with a different i2c address. 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.5mA when actively sensing, and less than 15 ua when in powerdown mode. Adafruit Industries https://learn.adafruit.com/tsl2561 Page 3 of 14

Some Stats Approximates Human eye Response Precisely Measures Illuminance in Diverse Lighting Conditions Temperature range: -30 to 80 *C Dynamic range (Lux): 0.1 to 40,000 Lux Voltage range: 2.7-3.6V Interface: I2C Pick one up today from the Adafruit shop! (http://adafru.it/439) Adafruit Industries https://learn.adafruit.com/tsl2561 Page 4 of 14

Wiring the TSL2561 Sensor This is an easy sensor to get started with. The breakout board comes with a 6-pin header strip that you can use to plug the sensor into a breadboard or perfboard. Simply plug the header into a solderless breadboard with the long pins down and short pins up. Place the sensor on top so each pad has a header pin in it and solder the two together. Next we will connect it to our microcontroller. In this case we'll be using an Arduino but nearly any microcontroller can be used by adapting our code Connect the VCC pin to a 3.3V or 5v power source. Note: Currently shipping sensors have a 3.3v regulator built-in. If you have an older version of the sensor that does not have the voltage regulator, it cannot be used with anything higher than 3.3V! Connect GND to the ground pin. Connect the i2c SCL clock pin to your i2c clock pin. On the classic Arduino Uno/Duemilanove/Diecimila/etc this is Analog pin #5 Adafruit Industries https://learn.adafruit.com/tsl2561 Page 5 of 14

Connect the i2c SDA data pin to your i2c data pin. On the classic Arduino Uno/Duemilanove/Diecimila/etc this is Analog pin #4 Unfortunately, the i2c lines on most microcontrollers are fixed so you're going to have to stick with those pins. You may be wondering, how is it OK to connect a 3.3V chip like the TSL2561 to 5.0V data pins like the Arduino? Isn't that bad? Well, in this specific case its OK. I2c uses pullup lines to the 3.3V power pin, so the data is actually being sent at 3.3V. As long as all the sensors/device on the i2c bus are running on 3.3V power, we're fine. However, don't use a 5.0v powered i2c device (like the DS1307) with pullups at the same time as a 3.3V device like the TSL2561! If you want to use this sensor with a datalogger that uses the DS1307, remove any/all of the pullup resistors from the DS1307 SDA/SCL pins. The pullups built into the TSL2561 will then be active and keep the voltage at 3.3V which is safe for both the RTC and the sensor. Adafruit Industries https://learn.adafruit.com/tsl2561 Page 6 of 14

You don't need to connect the ADDR (i2c address change) or INT (interrupt output) pins. The ADDR pin can be used if you have an i2c address conflict, to change the address. Connect it to ground to set the address to 0x29, connect it to 3.3V (vcc) to se t the address to 0x49 or leave it floating (unconnected) to use address 0x39. The INT pin is an ouput from the sensor used when you have the sensor configured to signal when the light level has changed. We don't have that code written in this tutorial so you don't have to use it. If you do end up using it, use a 10K-100K pullup from INT to 3.3V (vcc) Adafruit Industries https://learn.adafruit.com/tsl2561 Page 7 of 14

Using the TSL2561 Sensor To use this sensor and calculate Lux, there's a lot of very hairy and unpleasant math. You can check out the math in the datasheet (http://adafru.it/ajr) but really, its not intuitive or educational - its just how the sensor works. So we took care of all the icky math and wrapped it up into a nice Arduino library. (http://adafru.it/az9) You can find the Arduino library repository on github (http://adafru.it/az9) To install it, click the button below to download the compressed ZIP file then install it. This guide (http://adafru.it/aym) will help you with the install process if you have never installed an Arduino library. Download Adafruit_TSL2561 V2 Library http://adafru.it/d7d You will also need the Adafruit Sensor Library (http://adafru.it/azm) if you do not already have it installed. You can download it by clicking this button to get the compressed Zip. Then install as you did above. Download Adafruit_Sensor Library http://adafru.it/cmo Restart the IDE Now you can run the File->Examples->Adafruit_TSL2561->sensorapi example program which will read and calculate the lux readings for you. Open up the serial monitor at 9600 baud to see the measurements. Use a lamp or your hand to illuminate/shade the sensor to see the values change. Adafruit Industries https://learn.adafruit.com/tsl2561 Page 8 of 14

The library is fairly simple to use. The first line of code in the example is the 'constructor' where you can supply the I2C ADDR (in case you want to change it), and a unique ID to attach to this sensor (you can just leave this to the default value of 12345 for now). By modifying the I2C address we can have up to three TSL2561 sensors connected on the same board: // The address will be different depending on whether you leave // the ADDR pin float (addr 0x39), or tie it to ground or vcc. In those cases // use TSL2561_ADDR_LOW (0x29) or TSL2561_ADDR_HIGH (0x49) respectively Adafruit_TSL2561 tsl = Adafruit_TSL2561(TSL2561_ADDR_FLOAT, 12345); Adafruit Industries https://learn.adafruit.com/tsl2561 Page 9 of 14

Next up, you will want to configure the sensor with the gain and integration time. You can have either a gain of 0 (no extra gain, good in low light situations) or a gain of 16 which will boost the light considerably in dim situations. You can also change the integration time, which is how long it will collect light data for. The longer the integration time, the more precision the sensor has when collecting light samples. New to v2.0 of the driver, there is also an auto-gain option that is useful when measuring in mixed lighting-situations. This will automatically enable or disable the gain depending on the light level. This is still an experimental feature and the trigger levels to switch may need to be tweeked, but this should be useful to collect light both indoors and outdoors without having to change the code yourself. /**************************************************************************/ /* Configures the gain and integration time for the TSL2561 */ /**************************************************************************/ void configuresensor(void) { /* You can also manually set the gain or enable auto-gain support */ // tsl.setgain(tsl2561_gain_1x); /* No gain... use in bright light to avoid sensor saturation */ // tsl.setgain(tsl2561_gain_16x); /* 16x gain... use in low light to boost sensitivity */ tsl.enableautorange(true); /* Auto-gain... switches automatically between 1x and 16x */ /* Changing the integration time gives you better sensor resolution (402ms = 16-bit data) */ tsl.setintegrationtime(tsl2561_integrationtime_13ms); /* fast but low resolution */ // tsl.setintegrationtime(tsl2561_integrationtime_101ms); /* medium resolution and speed */ // tsl.setintegrationtime(tsl2561_integrationtime_402ms); /* 16-bit data but slowest conversions */ /* Update these values depending on what you've set above! */ Serial.println("------------------------------------"); Serial.print ("Gain: "); Serial.println("Auto"); Serial.print ("Timing: "); Serial.println("13 ms"); Serial.println("------------------------------------"); } By default, the driver will return light in standard SI lux units, which are a result of some complex calculations based on both photo diodes on the TSL2561 (one for full spectrum and one for IR). The sensitivity of the two diodes can be seen in the chart below: Adafruit Industries https://learn.adafruit.com/tsl2561 Page 10 of 14

When you're ready to get your measurement in standard SI lux units, simply call getevent with a reference to the 'sensors_event_t' object where the sensor data will be stored. This example assumes we are using the 'tsl' instance of Adafruit_TSL2561 at the top of the example code: Adafruit Industries https://learn.adafruit.com/tsl2561 Page 11 of 14

/* Get a new sensor event */ sensors_event_t event; tsl.getevent(&event); /* Display the results (light is measured in lux) */ if (event.light) { Serial.print(event.light); Serial.println(" lux"); } else { /* If event.light = 0 lux the sensor is probably saturated and no reliable data could be generated! */ Serial.println("Sensor overload"); } This function will return a reading in SI lux units, which is probably the easiest unit to understand when working with light. If you wish to manually read the individual photo diodes, though, you can still do this in the latest library by calling the getluminosity function, and passing in two variables where the sensor data will be stored: uint16_t broadband = 0; uint16_t infrared = 0; /* Populate broadband and infrared with the latest values */ getluminosity (&broadband, &infrared); That's it! The example should be easy to understand and work into your own projects from here! Adafruit Industries https://learn.adafruit.com/tsl2561 Page 12 of 14

Downloads Datasheet (http://adafru.it/ajs) TSL2561 Driver v2.0 (Unified Sensor Driver) (http://adafru.it/az9) - See http://learn.adafruit.com/tsl2561/use (http://adafru.it/c7o) for installation instructions TSL2561 Driver v1.0 on github (obsolete!) (http://adafru.it/ajt) Adafruit Industries https://learn.adafruit.com/tsl2561 Page 13 of 14

Buy a TSL2561 Sensor Buy a TSL2561 Sensor (http://adafru.it/439) Adafruit Industries Last Updated: 2015-06-12 12:10:28 PM EDT Page 14 of 14