# Ambient light sensor TEMT600

TEMT6000 is ambient light sensor. It is sensitive to visible light much like human eye and has peak sensitivity at 570nm.

Visible spectrum is 390 – 700 nm.

The sensor can handle voltages from 3.3v and 5v. The sensor has been designed into a voltage divider circuit. To read that voltage connect SIG pin to any analog to digital conversion pin on microcontroller.

Ambient light sensor for control of display backlight dimming in LCD displays and keypad backlighting of mobile devices and in industrial on/off-lighting operation.

TEMT6000 measures illuminance (measured in lux (lx). It is a measure of the total quantity of visible light emitted by a source (referred to as luminous flux, measured in lumens (lm) divided by an area in square meters. 1 lx = 1lm/m2.

To get the brightness the sensor measures, we then simply have to measure the voltage on the `SIG` (also called `OUT`) pin using the Analog To Digital Sensor and convert those voltage measurements to illuminance values in lux.

To get the illuminance in lux, we first need to convert the measured voltage to the current flowing across the TEMT6000 sensor. This current is also equal to the current flowing across the 10kΩ resistor in the voltage divider circuit, which is `I = adc_value/10000kΩ`.

Volts = analogRead() * 0.5 / 1024.0

Amps = volts / 10000.0

microamps = amps / 1000000

lux = microamps *2.0

```float lux = analogRead(TEMT6000_PIN) * 0.9765625; // 1000 / 1024 = 0.9765625
```

The datasheet for the TEMT6000 specifies a proportional correlation between current and illuminance: Every 2 µA of current correlates to 1 lx in the illuminance.

## Code

I’m using Visual Studio Code + PlatformIO. Arduino Uno

```#include <Arduino.h>

#define TEMT6000_PIN A0

void setup() {
pinMode(TEMT6000_PIN,  INPUT);
Serial.begin(9600);
}

void loop() {

double volts = reading * 5.0 / 1024.0;
Serial.print("Volts: "); Serial.println(volts);

/*
In the case of 8-bit AVR Arduino boards,
the float type is 32-bits
which makes the limit 6 or 7 digits.

double amps = volts / 10000.0; // = 0
Serial.print("Amps: ");Serial.println(amps);

double microamps = amps / 1000000; // = 0
Serial.print("Microamps: ");Serial.println(microamps);

double lux = microamps * 2.0; // = 0
Serial.print("Lux: "); Serial.println(lux);
*/
Serial.print("Lux: ");
float lux2 = analogRead(TEMT6000_PIN) * 0.9765625; // 1000 / 1024 = 0.9765625
Serial.println(lux2);
Serial.println("");

delay(1000);
}
```