Light
Interfacing BH1750 Light with Raspberry Pi
What is the BH1750?
BH1750 practical reference
The BH1750 is a 16-bit digital ambient light sensor that talks over I2C and returns a lux value directly — no ADC, no voltage divider, and no manual calibration curve like a raw LDR needs. Internally it uses a photodiode plus an integrating ADC and outputs a number already scaled to real-world lux.
It's the sensor to reach for whenever a project needs an actual lux measurement rather than a rough "bright vs dark" signal — automatic display brightness, greenhouse light logging, or camera exposure decisions. The catch that trips people up is the ADDR pin: leaving it floating gives unpredictable address behavior, so it should always be tied firmly to GND (address 0x23) or VCC (address 0x5C), especially useful when running two BH1750s on the same bus.
Key specifications
- Interface: I2C, up to 400kHz
- I2C address: 0x23 (ADDR to GND) or 0x5C (ADDR to VCC)
- Operating voltage: 2.4–3.6V (many breakout boards add a regulator for 5V tolerance — check yours)
- Measurement range: 1–65535 lux, direct digital output
- Resolution: 1 lux (standard mode), 0.5 lux (high-resolution mode 2)
- Measurement modes: Continuous or one-time, selectable resolution mode
- Conversion time: ~120ms (high-res mode), ~16ms (low-res mode)
- Current draw: ~120µA active, ~1µA power-down
Pinout and connection notes
Always tie ADDR to a defined level (GND or VCC) rather than leaving it floating — a floating ADDR pin can cause an unreliable or wrong I2C address at power-up.
- VCC: Power, 2.4–3.6V (check breakout for 5V tolerance)
- GND: Ground
- SCL: I2C clock
- SDA: I2C data
- ADDR: Address select — tie to GND for 0x23, or VCC for 0x5C. Never leave floating.
Integration checklist
- Confirm the exact part number and breakout-board revision.
- Verify supply voltage, current demand, logic levels, and signal direction against the datasheet.
- Check controller pin assignments and bus address or interface mode against the example code.
- Power up with external loads disconnected, then test signals before full integration.
- If readings or communication fail, check power and ground first, then pin mapping, interface settings, and library initialization.
Troubleshooting and reproducibility
Record the board used, wiring, library/version, supply arrangement, and measured behavior. Use the selected board-specific wiring example as the source of truth. Never assume visually similar modules share identical voltage tolerance or pin order.
Setting Up BH1750 with Raspberry Pi
Library
smbus2 by kplindegaard
pip3 install smbus2
Wiring
| Component pin | Raspberry Pi pin | Note |
|---|---|---|
| VCC | 3.3V (physical pin 1) | |
| GND | GND (physical pin 6) | |
| SCL | GPIO3 / SCL (physical pin 5) | |
| SDA | GPIO2 / SDA (physical pin 3) | |
| ADDR | GND (sets address to 0x23) |
Swipe sideways to see every column →
Enable I2C via raspi-config → Interface Options → I2C. Verify with i2cdetect -y 1 that the sensor shows at 0x23.
Related Components
A3144
Digital Hall-effect switch for contactless magnetic detection
Flame Sensor
Infrared flame detector for early fire-alert projects.
LDR (Photoresistor)
The simplest way to make something react to darkness or bright light.
TSL2561
Dual-photodiode lux sensor with good accuracy across mixed lighting conditions.
Related Guides & Projects
Raspberry Pi Pico W and Pico 2 W: Install MicroPython with Thonny or UF2
Hold BOOTSEL, drag the correct UF2 file, open the REPL and blink the onboard LED. Includes the Pico vs Pico W vs Pico 2 W firmware differences and what to do when the drive does not appear.
Raspberry Pi Pico W Web Server in MicroPython: Control an LED and Read a Sensor
Connect the Pico W to WiFi, serve a responsive control page, switch an LED and display the onboard temperature or an external sensor, with timeouts and reconnect handling.
Raspberry Pi Pico Oscilloscope with MicroPython
Convert a Raspberry Pi Pico into a basic 500 kSPS oscilloscope using its 12-bit ADC and MicroPython. Displays waveforms on an SSD1306 OLED or streams samples over USB serial to a Python plotter on your PC.
Self-Hosted Nextcloud NAS on Raspberry Pi 4
Build a private, durable Nextcloud NAS on a Raspberry Pi 4 -- SSD boot instead of a failure-prone SD card, Docker Compose with Redis caching, Tailscale for remote access with zero ports forwarded, and an automated backup strategy that actually runs.