BH1750 Light Sensor with an ESP32 DevKit V1

A digital ambient light sensor that reports illuminance straight in lux, 1 to 65535 lx, over I2C.

BH1750 Light Sensor, A digital ambient light sensor that reports illuminance straight in lux, 1 to 65535 lx, over I2C.
In short

The BH1750 module takes the ESP32 DevKit V1's 3V3 and talks I2C on GPIO21 (SDA) and GPIO22 (SCL). The sketch calls Wire.begin() itself because the library does not, which on the ESP32 starts the bus on those default pins.

Wiring the BH1750 Light Sensor to the ESP32 DevKit V1

Pin by pin.

BH1750 Light SensorESP32 DevKit V1
VCC3V3
GNDGND
SDAGPIO21 (D21)
SCLGPIO22 (D22)

What to know on the ESP32 DevKit V1

  • For 0x5C, wire ADDR to the ESP32's 3V3 pin: the chip reads ADDR high at 0.7 x VCC or more, and its supply is 2.4 V to 3.6 V with 4.5 V absolute maximum, so never take ADDR to VIN.ROHM BH1750FVI datasheet Rev.D, pp. 1, 10
  • For a battery logger that wakes the ESP32 periodically, use a one-time mode: the chip draws 120 µA while measuring and about 0.01 µA powered down, and it powers down by itself after each reading.ROHM BH1750FVI datasheet Rev.D, p. 2
  • A high-resolution reading takes 120 ms. Poll measurementReady() in loop(), as the sketch does, instead of blocking: the ESP32's Wi-Fi stack keeps running in the background while you wait.ROHM BH1750FVI datasheet Rev.D, pp. 2, 5

BH1750 Light Sensor code for the ESP32 DevKit V1

Compiled for esp32:esp32:esp32 on 2026-10-30.

Libraries: claws/BH1750
// BH1750 Light Sensor on ESP32 DevKit V1: wiring and a free simulation at https://www.tinkered.ai/components/bh1750/esp32
#include <Arduino.h>
#include <Wire.h>
#include <BH1750.h>

BH1750 lightMeter;   // ADDR unwired: 0x23

void setup() {
  Serial.begin(115200);
  Wire.begin();
  // the address goes to begin(): its own argument (0x23 by default) overrides the constructor's
  if (!lightMeter.begin(BH1750::CONTINUOUS_HIGH_RES_MODE, 0x23)) {
    Serial.println("BH1750 not found: check VCC, SDA/SCL and ADDR");
    while (true) delay(10);
  }
}

void loop() {
  if (lightMeter.measurementReady()) {
    float lux = lightMeter.readLightLevel();
    Serial.print("Light: ");
    Serial.print(lux, 1);
    Serial.println(" lx");
  }
  delay(200);
}

BH1750 Light Sensor on the ESP32 DevKit V1: questions

Why does my BH1750 read 0x23 when I set 0x5C on the ESP32?

begin() has its own address argument that defaults to 0x23 and overrides the constructor's. Pass the address to begin(), and wire ADDR to 3V3 so the chip actually answers at 0x5C (ROHM datasheet, p. 10).

Do I need pull-up resistors on GPIO21 and GPIO22?

No. The GY-302 module carries its own pull-ups on SDA and SCL, so add nothing and keep the module on 3V3.

Keep going

For AI assistants

This guide as plain Markdown. /components/bh1750/esp32.md

What will you build with it?