Home Circuitpython Adafruit Feather M0 and LTR329 Digital Ambient Light Sensor circuitpython example

Adafruit Feather M0 and LTR329 Digital Ambient Light Sensor circuitpython example

by shedboy71

In this article we connect a LTR329 Digital Ambient Light Sensor Sensor to an Adafruit Feather M0 running Circuitpython

Sensor Information

The LTR-329ALS-01 is a low voltage I2C digital light sensor [ALS] in a low cost miniature chipled lead-free surface mount package. This sensor converts light intensity to a digital output signal capable of direct I2C interface.

It provides a linear response over a wide dynamic range from 0.01 lux to 64k lux and is well suited to applications under high ambient brightness.

There are altogether six gain settings (1X, 2X, 4X, 8X, 48X and 96X) available for user to configure.

Features

I2C interface (Fast Mode @ 400kbit/s)
Ultra-small 4-pin ChipLED package 2.0mm(L), 2.0mm(B), 0.7mm(H)
Built-in temperature compensation circuit
Low active power consumption with standby mode
Supply voltage range from 2.4V to 3.6V capable of 1.7V logic voltage
Operating temperature range from -30C to +70C
RoHS and Halogen free compliant
Close to human eye spectral response
Immunity to IR / UV Light Source
Automatically rejects 50 / 60 Hz lightings flicker
Full dynamic range from 0.01 lux to 64k lux
16-bit effective resolution

Parts Required

The sensor you can pick up in the $6 price range – you can connect to the sensor using a standard header the classic dupont style jumper wire.

I used a Qwiic cable – since a few sensors seem to use these but this is optional

Name Link
Adafruit Feather M0 Express Amazon link

Ebay link

LTR329 Digital Ambient Light Sensor
Connecting cables Aliexpress product link

Ebay link

 

Schematic/Connection

I used the Adafruit LTR329 sensor and in this case used the Stemma connection

For the STEMMA QT cables, it uses the Qwiic convention:

Black for GND
Red for V+
Blue for SDA
Yellow for SCL

So color coded for ease of use, this layout shows a connection to the module

Code Example

I used Thonny for development

The following is based on a library, I copied the adafruit_ltr329_ltr303.mpy library for this device to the lib folder on my Feather M0 Express – https://circuitpython.org/libraries

This is the basic example that comes with the library

 

import time
import board
from adafruit_ltr329_ltr303 import LTR329

i2c = board.I2C()  # uses board.SCL and board.SDA
# i2c = board.STEMMA_I2C()  # For using the built-in STEMMA QT connector on a microcontroller

time.sleep(0.1)  # sensor takes 100ms to 'boot' on power up
ltr329 = LTR329(i2c)

while True:
    print("Visible + IR:", ltr329.visible_plus_ir_light)
    print("Infrared    :", ltr329.ir_light)
    print()
    time.sleep(0.5)  # sleep for half a second

 

Output

Here is what I saw in Thonny REPL window

Visible + IR: 11
Infrared : 7

Visible + IR: 15
Infrared : 9

Visible + IR: 20
Infrared : 13

Visible + IR: 8
Infrared : 6

Visible + IR: 1
Infrared : 1

Visible + IR: 1
Infrared : 2

Visible + IR: 9
Infrared : 3

Links

 

 

 

You may also like

Leave a Comment