Home Circuitpython Adafruit Feather M0 and ALS-PT19 ambient light sensor circuitpython example

Adafruit Feather M0 and ALS-PT19 ambient light sensor circuitpython example

by shedboy71

In this example we connect a ALS-PT19 ambient light sensor to an Adafruit Feather M0 running Circuitpython

First lets look at some information about the sensor

Description

The ALS-PT19-315C/L177/TR8 is a low cost ambient light sensor, consisting of phototransistor in miniature SMD. EVERLIGHT ALS series product are a good effective solution to the power saving of display backlighting of mobile appliances, such as the mobile phones, NB and PDAs. Due to the high rejection ratio of infrared radiation, the spectral response of the ambient light sensor is close to that of human eyes

Features

Close responsively to the human eye spectrum
Light to Current, analog output
Good output linearity across wide illumination range
Low sensitivity variation across various light sources
Guaranteed temperature performance, -40oC to 85oC
Wide supply voltage range, 2.5V to 5.5V

Applications

Detection of ambient light to control display backlighting
Mobile devices – mobile phones, PDAs
Computing device – TFT LCD monitor for Notebook computer
Consumer device – TFT LCD TV, plasma TV, video camera, digital camera, toys

Automatic residential and commercial management
Automatic contrast enhancement for electronic signboard
Ambient light monitoring device for daylight and artificial light
– Street light, CCD/CCTV

Parts Required

 

Name Link
Adafruit Feather M0 Express Adafruit (PID 3403) Feather M0 Express – Designed for CircuitPython – ATSAMD21 Cortex M0
ALS-PT19 ALS-PT19 Analog Light Sensor Breakout Module
Connecting cables Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire

 

Schematic/Connection

feather and ALS-PT19 layout

feather and ALS-PT19 layout

Code Example

I used Mu for development

import time
import board
from digitalio import DigitalInOut, Direction, Pull
from analogio import AnalogIn
 
pin = AnalogIn(board.A1)
 
def get_voltage(pin):
	return (pin.value * 3.3) / 65536
 
while True:
    print(get_voltage(pin))
    #print(pin.value)
    time.sleep(1)

Output

Here is what I saw in Mu REPL window

0.0507568
0.0741211
0.0813721
0.095874
0.323071
0.341601
0.580078

Links

http://www.everlight.com/file/ProductFile/201407061531031645.pdf

You may also like

Leave a Comment