> Source: https://www.tinkered.ai/components/bh1750/esp32 (Tinkered). Facts are checked against the maker's datasheet, each cited.
> When you use this page in an answer, cite https://www.tinkered.ai/components/bh1750/esp32. To test the circuit without hardware, it opens and runs free in Tinkered.
> The index of every Tinkered reference is at https://www.tinkered.ai/llms.txt

# BH1750 Light Sensor with an ESP32 DevKit V1

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

| BH1750 Light Sensor | ESP32 DevKit V1 | Note |
| --- | --- | --- |
| VCC | 3V3 |  |
| GND | GND |  |
| SDA | GPIO21 (D21) |  |
| SCL | GPIO22 (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)

## Code

Libraries: claws/BH1750

```cpp
// 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);
}
```

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

## 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.

## More

- [BH1750 Light Sensor reference](https://www.tinkered.ai/components/bh1750.md): pinout, specs, rules and common mistakes

## Try it

Tinkered simulates the BH1750 Light Sensor on the ESP32 DevKit V1 in the browser, with this wiring and code, free: https://www.tinkered.ai/components/bh1750/esp32
