Overview

This GA1A12S202 based sensor breakout is a big step-up from the basic CdS photo-cell. The biggest improvement over plain photocells is a true log-lin relationship with light levels. Most light sensors have a linear relationship with light levels, which means that they're not very sensitive to changes in darkened areas and 'max' out very easily when there's a lot of light. Sometimes you can tweak a resistor to make them better in dark or bright light but its hard to get good performance at both ends.

This sensor is logarithmic over a large dynamic range of 3 to 55,000 Lux, so it has a lot of sensitivity at low light levels but is also nearly impossible to "max out" so you can use it indoors or outdoors without changing code or calibration. Since the sensor is fabricated on a chip, there are also fewer manufacturing variations, so you won't have to re-calibrate the sensor from one board to another.
The GA1A12S202 sensor breakout is small and easy to integrate into any project. It makes a nice upgrade from a CdS photo-cell. It does not require a microcontroller, the analog voltage output increases with the amount of light shining on the sensor face. Use it to build a photovore, an automatic lighting system, a photo-meter or any number of light sensitive/light-reactive projects.

For more information including graphs, power consumption, etc check out the datasheet. On this breakout we placed a 68KΩ resistor from OUT to ground to turn the current into a voltage.

Assembly and Wiring

Assembly

The Adafruit Analog Light Sensor comes pre-assembled and fully tested on a handy breakout board. We have included a small header strip in case you want to use it on a breadboard. This can be installed in a few simple steps:

Position the header

Trim the header to size if needed and place long-pins-down in the breadboard.

Position the breakout board

Line the board up with the header pins and drop it in place for soldering.

Solder!

Solder each pin to assure good electrical conductivity.

Wiring for Arduino

Wiring this sensor is very simple. It can be powered by 2.3-6V, and has an analog output of up to 3v max. To use with an Arduino, wire it as follows:

  • VCC -> 5v
  • OUT -> A0
  • GND -> GND
SInce the output range of the sensor is 0-3v, for maximum resolution, it is best to use the 3.3v pin for your voltage reference. To do this, run a jumper from 3.3v to AREF on your Arduino. In your code, be sure to specify "analogReference(EXTERNAL);"


When using an external analog reference, it is important to specify analogReference(EXTERNAL) in your code before performing any analogRead() operations. Otherwise, your external reference will be shorted to the default internal 5v reference. This can damage your Arduino.

Standalone Wiring

One nice thing about this little sensor is that it doesn't require a microprocessor for interfacing. You can use this sensor to make simple light-activated circuits or even an analog light meter. The sensor output varies from about 5-50uA. With the on-board 68K resistor, this translates to a range of about 0.3v to 3v.

Programming

This sensor has a usable range of about 3-55,000 lux. This covers a pretty wide range of indoor and outdoor lighting conditions:

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

Simple Lux Measurement:

This sensor is simple to use with a microcontroller like the Arduino. Just connect the output to an analog pin and read. The sketch below reads the raw sensor input and converts the value to Lux. Since the logarithmic part of the output range extends from approximately 0.3v to 3.3v, we use the 3.3v pin as an external voltage reference to maximize the resolution.
Download: file
/*
  Test sketch for the Adafruit Analog Light Sensor
  by Bill Earl
  for Adafruit Industries
  
  Connect sensor output to Analog Pin 0
  Connect 5v to VCC and GND to GND
  Connect 3.3v to the AREF pin 
 */

int sensorPin = A0;    // select the input pin for the potentiometer

float rawRange = 1024; // 3.3v
float logRange = 5.0; // 3.3v = 10^5 lux

void setup() 
{
  analogReference(EXTERNAL); //
  Serial.begin(9600);
  Serial.println("Adafruit Analog Light Sensor Test");
}

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

Downloads

This guide was first published on Jun 22, 2013. It was last updated on Jun 22, 2013.