Skip to content

Ambient Light Sensor TinyShield Tutorial

The Ambient Light Sensor TinyShield allows you to measure light intensity in your next TinyDuino project. But not only is this sensor able to measure light, it can also be programmed for proximity detection with the help of an LED. Check out page 5 of the TSL2572 datasheet if you're interested in this application!

If you have a smartphone, you probably carry an ambient light sensor in your pocket every day. Current iPhones use this type of sensor to control screen brightness, and for proximity detection to turn off the screen during phone calls when the device is near your face.

To learn more about the TinyDuino Platform, click here


Measure light with your TinyDuino - this TinyShield features a TAOS TSL2572 Ambient Light Sensor, that approximates human eye response to light intensity under a variety of lighting conditions and through a variety of attenuation materials. Accurate ALS measurements are the result of TAOS’ patented dual-diode technology and the UV rejection filter incorporated in the package. In addition, the operating range is extended to 60,000 lux in sunlight when the low-gain mode is used.

The Ambient Light Sensor TinyShield incorporates level shifters and a local power supply to ensure proper and safe operation over the entire TinyDuino operating voltage range between 3 – 5V.

To see what other TinyShields are compatible with this TinyShield, see the TinyShield Compatibility Matrix

Technical Details TAOS TSL2572 Ambient Light Sensor Specs
  • Approximates Human Eye Response
  • 45,000,000:1 Dynamic Range
  • Operation to 60,000 lux in Sunlight
  • Package UV Rejection Filter
  • Wide Magnetic Field Range (+/-8 Oe)
  • Low Power – Active: 200uA, Wait: 90uA, Sleep: 2.2u
TinyDuino Power Requirements
  • Voltage: 3.0V - 5.5V
  • Current: 200uA (Active). Due to the low current, this board can be run using the TinyDuino coin cell option.
Pins Used
  • A5/SCL - I2C Serial Clock line
  • A4/SDA - I2C Serial Data line
  • 20mm x 20mm (.787 inches x .787 inches)
  • Max Height (from lower bottom TinyShield Connector to upper top TinyShield Connector): 5.11mm (0.201 inches)
  • Weight: .96 gram (.03 ounces)


  • You can also use this shield without the TinyDuino – there are 0.1" spaced connections for power, ground, and the two I2C signals along the side of the TinyShield to allow you to connect a different system. 


TinyZero and Ambient Light Sensor TinyShield



Hardware Assembly

On top of your processor board of choice (i.e. TinyDuino), place the Ambient Light Sensor TinyShield. Plug a MicroUSB cable into the USB port and then plug the cable into a free USB port on your computer. Make sure the processor is switched on.

An assembled stack of a TinyDuino, USB TinyShield, and Ambient Light Sensor TinyShield.

Software Setup

First, open the Arduino IDE. If you don't have it installed, check out our TinyDuino Setup Tutorial.

The TSL2572 Library is required for this sketch.

The Code

Press here to download a .zip file of the program. View the .ino Sketch file here:

  TinyCircuits Ambient Light TinyShield Example Sketch
  Using AMS TAOS TSL2572

  This example code is in the public domain.

  Written 25 October 2015
  By Ken Burns
  Modified 31 December 2020
  By Hunter Hykes

#include <Wire.h>
#include <TSL2572.h>      // For TSL2572 ambient light sensor

TSL2572 light_sensor;

#if defined (ARDUINO_ARCH_AVR)
#define SerialMonitorInterface Serial
#include <SoftwareSerial.h>
#elif defined(ARDUINO_ARCH_SAMD)
#define SerialMonitorInterface SerialUSB

int gain_val = 0;

void setup()

  //  light_sensor.init(GAIN_1X);
  //  light_sensor.init(GAIN_8X);
  //  light_sensor.init(GAIN_120X);

void loop()
  float AmbientLightLux = light_sensor.readAmbientLight();
  SerialMonitorInterface.print("Lux: ");


Upload the program using the Tools selections:

Tools selections for TinyDuino (Your COM# will probably be different)

Once the upload is complete, open up the Serial Monitor at 9600 baud and you'll be able to observe the data gathered by the sensor!

Data from the Ambient Light Sensor TinyShield here at TinyCircuits

For your project that involves sensing light, you will probably have to take some readings first to find out what those readings would be. Make sure you account for day and night light if the sun may be involved!


Contact Us

If you have any questions or feedback, feel free to email us or make a post on our forum. Show us what you make by tagging @TinyCircuits on Instagram, Twitter, or Facebook so we can feature it.

Thanks for making with us!