tutorialspinouttools
Sensors · ESP32-C3

TEMT6000 on OLED: Ambient Light

Free ESP32 & Arduino tutorial · wiring, code & parts · gokul.builds

Overview & Wiring

What it is: The TEMT6000 is a simple analog light sensor whose output rises with brightness. Its response is tuned to visible light like the human eye, making it a nicer analog light sensor than a bare LDR. How it works: The breakout is basically a phototransistor feeding a load resistor, so the SIG pin gives a voltage proportional to light. Read it with the ESP32 ADC. This sketch maps the reading to a friendly 0–100 % brightness. Wiring: TEMT6000 SIG -> GPIO0 (analog) TEMT6000 VCC -> 3V3 TEMT6000 GND -> GND OLED VCC=3V3, GND=GND, SDA=GPIO4, SCL=GPIO5 Libraries: only "Adafruit SSD1306" and "Adafruit GFX Library". On screen / Serial: brightness as 0–100 % plus the calibrated millivolts. Shade it vs shine a torch to see the swing. Gotchas: It's a relative sensor, not calibrated lux — for real lux use the BH1750 or TSL2561. GPIO0 is a boot-strap pin; safe to read but don't hold it low during reset.

Circuit Diagram

TEMT6000 on OLED: Ambient Light wiring diagram for ESP32-C3

Parts You Need

ESP32-C3 SuperMiniBuy →
0.96" SSD1306 OLEDBuy →

Source Code (Arduino / ESP32)

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

Adafruit_SSD1306 display(128, 64, &Wire, -1);

#define TEMT 0                // SIG on GPIO0 (ADC)

void setup() {
  Serial.begin(115200);
  Wire.begin(4, 5);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
}

void loop() {
  int mv = analogReadMilliVolts(TEMT);        // calibrated mV
  int pct = map(constrain(mv, 0, 3300), 0, 3300, 0, 100);

  display.clearDisplay();
  display.setTextColor(SSD1306_WHITE);
  display.setTextSize(1);
  display.setCursor(0, 0);
  display.println("TEMT6000 Light");
  display.setTextSize(3);
  display.setCursor(0, 22);
  display.printf("%d%%", pct);
  display.setTextSize(1);
  display.setCursor(0, 54); display.printf("%d mV", mv);
  display.display();

  Serial.printf("Light: %d%%  (%d mV)\n", pct, mv);
  delay(300);
}
Browse all tutorials ESP32-C3 pinout Calculators