Home Circuitpython Adafruit Feather M0 and LX1972 light sensor circuitpython example

Adafruit Feather M0 and LX1972 light sensor circuitpython example

by shedboy71

In this example we connect a LX1972 light sensor to an Adafruit Feather M0 running Circuitpython

First lets look at some information about the sensor from the manufacturer

Description

The LX1972 is a low cost silicon light sensor with spectral response that closely emulates the human eye. Patented circuitry produces peak spectral response at 520nm, with IR response less than ±5%, of the peak response, above 900nm.

The photo sensor is a PIN diode array with a linear, accurate, and very repeatable current transfer function.

High gain current mirrors on the chip multiply the PIN diode photo-current to a sensitivity level that can be voltage scaled with a standard value external resistor. Output current from this simple to use two-pin device can be used directly or converted to a voltage by placing it in series with a single resistor at either of its two pins.

Dynamic range is determined by the resistors (typically in the range of 10K to 100K) and power supply values. Typically the LX1972 needs only 1.8V of headroom to operate at 1000 Lux illumination.

Internal temperature compensation allows dark current to be kept below 200nA over the full specification temperature range (-40 to +85°), providing high accuracy at low light levels. Usable ambient light conditions range is from 1 to more than 5000 Lux.

The LX1972 is optimized for controlling back lighting systems in low cost consumer products such as LCD TV, portable computers, and digital cameras.

FEATURES:
1. Near Human Eye Spectral Response
2. Very Low IR Sensitivity
3. Highly Accurate & Repeatable Output Current vs. Light
4. Scalable Output Voltage
5. Temperature Stable
6. Integrated High Gain Photo Current Amplifiers
7. No Optical Filters Needed

 

Parts Required

 

Name Link
Adafruit Feather M0 Express Adafruit (PID 3403) Feather M0 Express – Designed for CircuitPython – ATSAMD21 Cortex M0
LX1972 1PCS LX1972 Analog Light Sensor DIY Maker Illumination Sensor Module
Connecting cables Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire

 

Schematic/Connection

 

Feather module connection
 Gnd GND
 3v3 VCC
D5 output

Code Example

I used Mu for development

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

 

Output

Here is what I saw in Mu REPL window

23888
25280
22496
784
912
960
784
960
992
880
896

A low value was me covering the sensor and the high value was a desktop lamp. So in a practical application you would need to figure out the analog value you wished to act on, so for example if you read in under 1000 you may want to send an alarm as its too dark.

Links

 

You may also like

Leave a Comment