Skip to content

Ambient Light Wireling Tutorial

Ambient Light Sensor Wireling product photo closeup

The Ambient Light Sensor Wireling allows you to measure light intensity in your next TinyCircuits project. 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!

Measure light with the 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.

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
  • 10mm x 10mm (.394 inches x .394 inches)
  • Max Height (from the lower bottom of Wireling to upper top Wireling Connector): 3.70mm (0.15 inches)
  • Weight: 1 gram (.04 ounces)


  • Lux: The official Merriam Webster definition is: "a unit of illumination equal to the direct illumination on a surface that is everywhere one meter from a uniform point source of one candle intensity or equal to one lumen per square meter." So basically, lux is the amount of light in an area one meter away from the sensor. Check out the Wikipedia for a helpful table to better understand lux readings put out by the sensor.
  • 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 interface with any TinyCircuits Arduino board, you will need the Arduino IDE and a Micro USB Cable

There are multiple processor/adapter combinations that can be used with Wirelings. Use the following table to find the combination that works for you.

Processor Adapter
*TinyDuino and USB TinyShield Wireling Adapter TinyShield
*TinyZero Wireling Adapter TinyShield
*TinyScreen+ Wireling Adapter TinyShield
WirelingZero N/A
*RobotZero N/A
Arduino Wireling Arduino Shield
Raspberry Pi Wireling Pi Hat

* These processors have a 32-pin connector and can have multiple Wireling Adapter TinyShields stacked to increase the number of Wireling ports up to a maximum of 32 total Wireling ports.

In order to interface with Wirelings, you'll need the appropriate number of Wireling Cables and the Wireling.h Library (You can download this from GitHub as linked, or from the Library Manager in the Arduino IDE). The TSL2572 Library

You will also need the Ambient Light Sensor Wireling and the included example Arduino sketch.

Wireling Code
Port 0 Ambient Light Sensor Example Sketch

Hardware Assembly

Depending on the development system you choose, you will need to put together a TinyDuino stack including the Wireling Adapter TinyShield using the 32-pin tan connectors, or you will just need to plug in your Wireling to Port 0 using a Wireling Cable. (You can change this port in the included Arduino Sketch using the Wireling.selectPort() function)

NOTE: Be mindful when inserting Wireling Cables - the connector pins inside the 5-pin connectors on Wirelings can be bent when cables are inserted at an angle.

Assembly of light sensor wireling and WirelingZero with cables

Software Setup

If you have not already done so, download the Ambient Light Sensor Wireling Example Sketch and open it in the Arduino IDE. The TSL2572 Library is required for this sketch.

Make the correct Tools selections for your development board. If unsure, you can double check the Help page that mentions the Tools selections needed for any TinyCircuits processor.

Upload Program

Upload the program and open the Serial Monitor to see the sensor's output.

 * TSL2572 Ambient Light Sensor Wireling Tutorial:
 * This program will print the lux value read from the sensor to  the 
 * Serial Monitor
 * Hardware by: TinyCircuits
 * Code by: Ken Burns & Laveréna Wienclaw for TinyCircuits
 * Initiated: 11/29/2017 
 * Updated: 12/31/2020

#include <Wire.h>         // For I2C communication with sensor
#include <Wireling.h>     // For interfacing with Wirelings
#include <TSL2572.h>      // For TSL2572 ambient light sensor

TSL2572 light_sensor;

// Global variable for gain value used to Read the sensor
int gain_val = 0;

// Make Serial Monitor compatible for all TinyCircuits processors
#if defined(ARDUINO_ARCH_AVR)
  #define SerialMonitorInterface Serial
#elif defined(ARDUINO_ARCH_SAMD)
  #define SerialMonitorInterface SerialUSB

void setup() {

  // Initialize Wireling
  Wireling.selectPort(0); // Port #'s correspond to backside of the Adapter TinyShield

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

void loop() {
  float AmbientLightLux = light_sensor.readAmbientLight();

  // Print lux value to Serial Monitor
  SerialMonitorInterface.print("Lux: ");

This is an example of lux output printed to the Serial Monitor taken from pointing the sensor around a room:

Serial monitor output of lux readings

You can try shining a phone flashlight onto the sensor, or covering it with a hand to see the range of readings.


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!