ESP32 and TEMT6000 ambient light sensor

TEMT6000 ambient light sensor is a silicon NPN epitaxial planar phototransistor in a miniature transparent 1206 package for surface mounting.

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

Features
• Adapted to human eye responsivity
• Wide angle of half sensitivity ϕ = ± 60°

Applications

Ambient light sensor for display backlight dimming in:

Mobile phones
Notebook computers
PDA’s
Cameras
Dashboards

 

Connection and Layout

TEMT6000 Pin ESP32 Pin
SIG A0
GND GND
VCC 3v3
esp32 and temt6000
esp32 and temt6000

 

Code

No libraries needed


#define LIGHTSENSORPIN A1 //Ambient light sensor reading

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

void loop()
{
float reading = analogRead(LIGHTSENSORPIN); //Read light level
float square_ratio = reading / 1023.0; //Get percent of maximum value (1023)
square_ratio = pow(square_ratio, 2.0);
Serial.println(reading);
delay(1000);
}

 

Output

Open the serial monitor and you should see something like this

41.00
42.00
4.00
1.00
21.00
38.00
41.00
41.00
40.00

 

Links

https://www.vishay.com/docs/81579/temt6000.pdf

TEMT6000 Light Sensor

SHARE
Previous articleESP32 and bme280 temperature sensor example
Next articleESP32 and WS2812b RGB led example