Home Chipkit Chipkit Uno and GA1A12S202 light sensor example

Chipkit Uno and GA1A12S202 light sensor example

by shedboy71

In this example we will connect a GA1A12S202 Log-Scale Analog Light Sensor to a Chipkit Uno

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

Illuminance Example
0.002 lux Moonless clear night sky
0.2 lux Design minimum for emergency lighting
0.27 – 1 lux Full moon on a clear night
3.4 lux 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.
1,000 lux Overcast day
10,000 – 25,000 lux Full daylight
32,000 – 130,000 lux Direct sunlight

 

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

GA1A12S202

GA1A12S202

Connection

Vcc – 3v
Gnd – Gnd
Out – A0

Code

 

[codesyntax lang=”cpp”]

int sensorPin = A0; //
float rawRange = 1023;
float logRange = 3.3;

void setup()
{
Serial.begin(9600);
}

void loop()
{
// read the raw value from the sensor:
int rawValue = analogRead(sensorPin);

Serial.print("Raw = ");
Serial.print(rawValue);
Serial.print(" - Lux = ");
Serial.println(RawToLux(rawValue));
delay(1000);
}

float RawToLux(int raw)
{
float logLux = raw * logRange / rawRange;
return pow(10, logLux);
}

[/codesyntax]

 

Results

Open the Serial monitor and you should something like this

Raw = 198 – Lux = 4.35
Raw = 195 – Lux = 4.26
Raw = 181 – Lux = 3.84
Raw = 195 – Lux = 4.26
Raw = 9 – Lux = 1.07
Raw = 13 – Lux = 1.10
Raw = 186 – Lux = 3.98
Raw = 204 – Lux = 4.55
Raw = 195 – Lux = 4.26

The sensor was covered and moved close to a desktop lamp – the higher values

Links

Adafruit GA1A12S202 Log-scale Analog Light Sensor [ADA1384]

Share

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