Skip to content

Light Sensor Wireling Python Tutorial

Ambient Light Sensor Wireling product photo closeup

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



Required Software

  • Python 3 (Python 2 is not supported!)
  • All Python packages mentioned in the Pi Hat setup tutorial (tinycircuits-wireling, Adafruit-Blinka, adafruit-circuitpython-ads1x15, and adafruit-circuitpython-busdevice)
  • The TinyCircuits TSL2572 Python package (mentioned later)
  • Ambient Light Sensor Python Example

Hardware Assembly

Plug your Wireling into the port you plan on using! The default in the included program is port 0.

If you want to use a different port, you just need to change the port value in the program mentioned later.


Install the necessary Python package:

pip3 install tinycircuits-tsl2572

Then you can download (above under Software) the Ambient Light Sensor Wireling example:
# TinyCircuits Light Sensor TSL2572 Wireling Module Example
# Prints illimuniance values read from ambient light sensor in terms of lux
# every second.
# Written by Laveréna Wienclaw for TinyCircuits
# Initialized: 9-10-19
# Last Updated: 12-16-19

import tinycircuits_wireling
import tinycircuits_tsl2572
import time

# Initialize and enable power to Wireling Pi Hat
wireling = tinycircuits_wireling.Wireling()

# Toggle this variable to use the Light Sensor Wireling on a different port (0-3)
port = 0

# Create library object using our Bus I2C port
tsl2572 = tinycircuits_tsl2572.TinyCircuits_TSL2572_I2C(2) # Set Gain to 2 = 16x

    lux = tsl2572.readAmbientLight()
    print("Lux: {}".format(lux))

The program by default is written to work with Port 0 on the Wireling Pi Hat.

Run Program

Navigate in the terminal to the directory where you downloaded the python example and run:


The program will print out the illuminance value read from the sensor in terms of lux every second.


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!