BH1750 Light Sensor: Raspberry Pi

Model Picture
 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

Raspbery Pi Connection Diagram
Raspberry Pi Pinout Diagram

BH1750 Light Intensity Sensor Pinout Diagram
BH1750 Light Intensity Sensor Pinout Diagram

I2C Connection Table

BH1750 PinRaspberry Pi
VCC3.3V
GNDGND
SDAGPIO2 (Pin 3)
SCLGPIO3 (Pin 5)

👉 Default I2C Address: 0x23 (or 0x5C depending on ADDR pin)


4. Detailed Step By Step Circuit Working

  1. BH1750 senses ambient light intensity.
  2. Internal ADC converts light into digital lux value.
  3. Data is sent via I2C protocol (SDA & SCL).
  4. Raspberry Pi reads lux value directly.
  5. 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 bus
  • addr = 0x23 → Default BH1750 address
  • read_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 1 to 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.

à´¤ുà´Ÿà´•്à´•à´•്à´•ാർക്à´•ാà´¯ുà´³്à´³ ഇലക്à´Ÿ്à´°ോà´£ിà´•്à´¸് ലളിതമാà´¯ി പഠിà´•്à´•ാം.

Empowering students in Kerala with hands-on technical skills.