Home Espruino Espruino and GA1A12S202 Analog Light Sensor example

Espruino and GA1A12S202 Analog Light Sensor example

by iainhendry

In this example we will connect a GA1A12S202 Log-Scale Analog Light Sensor to an Espruino. Like a CdS photo-cell, the sensor does not require a microcontroller, the analog voltage output increases with the amount of light shining on the sensor face. This sensor has a lot of improvements that make it better for nearly any project.

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

GA1A12S202

GA1A12S202

 

 

 

 

 

 

 

 

Illuminance Example
0.002 lux Moonless clear night sky
0.2 lux Design minimum for emergency lighting (AS2293).
0.27 – 1 lux Full moon on a clear night
3.4 lux Dark limit of civil twilight under a clear sky
50 lux Family living room
80 lux Hallway/toilet
100 lux Very dark overcast day
300 – 500 lux Sunrise or sunset on a clear day. Well-lit office area.
1,000 lux Overcast day; typical TV studio lighting
10,000 – 25,000 lux Full daylight (not direct sun)
32,000 – 130,000 lux Direct sunlight

 

Schematics

 

You connect the sensor as follows

Vcc – 3v3
Gnd – Gnd
Out – A0

espruino and GA1A12S202

espruino and GA1A12S202

 

Code

var rawValue = analogRead(A0);
var logLux = rawValue * 3.3;
var luxValue = Math.pow(logLux, 10);

console.log('Raw Value: ', rawValue);
console.log('Lux: ', luxValue);

 

Output

Raw Value: 0.38135347524
Lux: 9.96360456839
Raw Value: 0.70679789425
Lux: 4765.31779115492
Value: 0.78077363241
Lux: 12894.09251032220

 

Links

 

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More