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
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.
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
|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|
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)
Here is what I saw in Mu REPL window
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.