Home Sensor Projects Arduino GA1A12S202 Analog Light Sensor example

Arduino GA1A12S202 Analog Light Sensor example

by shedboy71

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!

What is Lux though ? Well this helpful table shows some examples

Examples
Illuminance Surfaces illuminated by:
0.0001 lux Moonless, overcast night sky (starlight)
0.002 lux Moonless clear night sky with airglow
0.27–1.0 lux Full moon on a clear night
3.4 lux Dark limit of civil twilight under a clear sky
50 lux Family living room lights
80 lux Office building lighting
100 lux Very dark overcast day
320–500 lux Office lighting
400 lux Sunrise or sunset on a clear day.
1000 lux Overcast day  typical TV studio lighting
1000025000 lux Full daylight (not direct sun)
32000100000 lux Direct sunlight

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

ga1a1s202_

Connection and Layout

Vcc – 5v
Gnd – Gnd
Out – A0 (or you can use another analog in pin but you would need to change the code example)

Which you can see in the layout here

arduino-and-ga1a1s202wp_bb

 

Code

This uses a library – https://github.com/arduinolearning/Arduino-Libraries/tree/master/GA1A12S202

 

[codesyntax lang=”cpp”]

#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);
}

[/codesyntax]

 

Testing

Open the Serial monitor and you should something like this, varying the light source will change the value

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

 

Links
Adafruit GA1A12S202 Log-scale Analog Light Sensor [ADA1384]

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