1. Introduction
The BH1750 is a digital light sensor that measures ambient light intensity in lux. Unlike LDR, it provides direct digital output via I2C, making it accurate and easy to use with the Raspberry Pi.
2. Components
- Raspberry Pi 4 Model B
- BH1750
- Jumper wires
- Breadboard (optional)
3. Circuit and Connections
| BH1750 Pin | Raspberry Pi |
|---|---|
| VCC | 3.3V |
| GND | GND |
| SDA | GPIO2 (Pin 3) |
| SCL | GPIO3 (Pin 5) |
👉 Default I2C Address: 0x23 (or 0x5C depending on ADDR pin)
4. Detailed Step By Step Circuit Working
- BH1750 senses ambient light intensity.
- Internal ADC converts light into digital lux value.
- Data is sent via I2C protocol (SDA & SCL).
- Raspberry Pi reads lux value directly.
- No external ADC required.
5. Libraries to be Included
Install required libraries:
sudo apt update
sudo apt install python3-smbus i2c-tools
pip3 install smbus2
Enable I2C:
sudo raspi-config
→ Interface Options → I2C → Enable
6. Code (Python)
import smbus2
import time
bus = smbus2.SMBus(1)
addr = 0x23
while True:
data = bus.read_i2c_block_data(addr, 0x20)
lux = (data[0] << 8 | data[1]) / 1.2
print("Light Intensity: {:.2f} lux".format(lux))
time.sleep(1)
7. Detailed Step By Step Code Working
SMBus(1)→ Initializes I2C busaddr = 0x23→ Default BH1750 addressread_i2c_block_data()→ Reads sensor data- Combines two bytes → gives light value
- Dividing by 1.2 → converts to lux
- Loop continuously prints light intensity
8. Tips
- Use
i2cdetect -y 1to confirm address - Avoid direct strong light for testing
- Use stable 3.3V supply
- Keep wiring short
- Try address 0x23 / 0x5C if not detected
9. Uses
- Automatic street lighting
- Smart home lighting systems
- Display brightness control
- Weather monitoring systems
- Energy-saving applications
10. Conclusion
The BH1750 is an accurate and easy-to-use digital light sensor. With I2C communication, it simplifies light measurement projects and eliminates the need for ADC.