Reference
BH1750
Ambient light sensor.
- Connects over
- I²C
- Address
- 0x23 (or 0x5C)
- Made by
- Rohm
- Datasheet
- mouser.com
Use it
hardware {
device bh1750: BH1750
}
every 1s {
let value: float = bh1750.lux()
log("bh1750", "lux={value}")
}
On its own, the declaration puts the BH1750 on the first I²C bus (SDA 21, SCL 22 on the ESP32) at 0x23. To choose the pins or the address, declare the bus and attach the device: device bh1750: BH1750 on i2c0 at 0x5C with i2c i2c0(sda: 21, scl: 22).
Methods
-
bh1750.lux() -> float
Light intensity in lux
Wiring
| Pin | Connect to |
|---|---|
VCC | 3.3V or 5V |
GND | Ground |
SDA | Pull-up to VCC (often on breakout board) |
SCL | Pull-up to VCC |
ADDR | 0x23 if ADDR=GND, 0x5C if ADDR=VCC |
Specifications
- Voltage
- 2.4V – 3.6V (typical 3.0V)
- Current
- 120 μA active
- Range
- 1 – 65535 lux
- Resolution
- 1 lux (high-res mode), 4 lux (low-res)
- Interface speed
- I²C up to 400 kHz
Tips
- Linear lux output — no log conversion needed (unlike a photoresistor).
- High-resolution mode takes 120 ms per reading; one-shot mode saves power.
- Better long-term stability than VEML7700 but smaller dynamic range.
Alternatives worth knowing:
- VEML7700: Wider dynamic range (~120k lux), more sensitive at low light.
- TSL2591: Even wider range (188 μlux to 88k lux); two diodes for IR rejection.