micro:bit and LX1972 light sensor example

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

Connection

 

micro:bit connection module connection
 Gnd GND
 3v3 VCC
P0 output

Code

[cpp]
void setup()
{
Serial.begin(9600); // open serial port, set the baud rate to 9600 bps
}

void loop()
{
int val;
val=analogRead(0); //connect sensor to pin marked P0
Serial.println(val);//print the value to serial
delay(1000);
}
[/cpp]

 

Output

Open the serial monitor and you should see something like this

210
236
2267
2291
2289
2347
2352
2445
2527
2631
2691
2699
2799
2303
2247
265
288
312

To give some context, the 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 500 you may want to send an alarm as its too dark.

Links

LX1972 Analog Light Sensor DIY Maker Illumination Sensor Module

micro:bit and GA1A12S202 light sensor example

In this example we will connect a GA1A12S202 Log-Scale Analog Light Sensor to an Arduino.

The features of this sensor are as follows

Output voltage increases with light on the sensor
Logarithmic response not only gives more sensitivity in low light, its also almost impossible to “max-out” the sensor
Dynamic range of 3 to 55,000 Lux
Use indoors and outdoors without needing to recalibrate!

Again these are typically best used in breakout/module form. Here is a picture of the module

You connect the sensor as follows

Vcc – 3v3
Gnd – Gnd
Out – P3

 

Code

This uses a library – https://github.com/wgbartley/GA1A12S202-sensor

I recieved a compilation error reagrding application.h so the following seemed to fix this issue – ga1a12s02

#include "GA1A12S202.h"
 
GA1A12S202 luxValue(A0);
 
void setup() 
{
    Serial.begin(9600);
    delay(2000);
}
 
void loop() 
{
    Serial.print("Raw value = ");
    Serial.print(luxValue.getRaw());
	Serial.println();
    Serial.print("Lux value = ");
    Serial.println(luxValue.getLux());
	Serial.println();
    delay(1000);
}

 

Results

Open the Serial monitor and you should something like this

Raw value = 315
Lux value = 2.42

Raw value = 314
Lux value = 2.42

Raw value = 27
Lux value = 1.09

Raw value = 28
Lux value = 1.08

Raw value = 339
Lux value = 2.61

Raw value = 338
Lux value = 2.59

 

Links

Adafruit GA1A12S202 Log-scale Analog Light Sensor [ADA1384]