Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use BH1750: Examples, Pinouts, and Specs

Image of BH1750Design with BH1750 in Cirkit Designer

Introduction

The BH1750 is a digital light sensor designed to measure ambient light intensity in lux, providing precise and reliable readings. It communicates via the I2C protocol, making it easy to integrate into microcontroller-based systems. The sensor is widely used in applications such as automatic brightness control for displays, energy-efficient lighting systems, and environmental monitoring.

Key features of the BH1750 include high resolution (up to 1 lux), low power consumption, and a compact design, making it suitable for portable and battery-powered devices.

Explore Projects Built with BH1750

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of Arduino Mega ADK Automated Plant Watering and Environmental Monitoring System: A project utilizing BH1750 in a practical application
Arduino Mega ADK Automated Plant Watering and Environmental Monitoring System

This circuit features an Arduino Mega ADK as the central microcontroller, interfacing with a variety of sensors and actuators. It includes a BH1750 light sensor and a DHT11 temperature and humidity sensor for environmental monitoring, both interfacing via I2C. The system controls a stepper motor via an A4988 driver, two water pumps through a 3-channel relay, and a fan using an IRF520 PWM module, with several push switches to trigger inputs. An OLED display provides a user interface, and soil moisture levels are monitored with two soil sensors. A non-contact water level sensor is also included for liquid level detection.

Open Project in Cirkit Designer

Technical Specifications

The following table outlines the key technical details of the BH1750:

Parameter Value
Operating Voltage 2.4V to 3.6V
Operating Current 0.12 mA (typical)
Measurement Range 1 lux to 65535 lux
Communication Protocol I2C (7-bit address: 0x23 or 0x5C)
Resolution 1 lux
Operating Temperature -40°C to +85°C
Dimensions 3.0mm x 1.6mm x 1.2mm

Pin Configuration and Descriptions

The BH1750 has six pins, as described in the table below:

Pin Number Pin Name Description
1 VCC Power supply (2.4V to 3.6V)
2 GND Ground
3 SDA I2C data line
4 SCL I2C clock line
5 ADDR I2C address selection (LOW: 0x23, HIGH: 0x5C)
6 NC Not connected (leave unconnected or floating)

Usage Instructions

How to Use the BH1750 in a Circuit

  1. Power the Sensor: Connect the VCC pin to a 3.3V power source and the GND pin to ground.
  2. I2C Communication: Connect the SDA and SCL pins to the corresponding I2C pins on your microcontroller. Use pull-up resistors (typically 4.7kΩ) on the SDA and SCL lines if not already present.
  3. Address Selection: Use the ADDR pin to select the I2C address:
    • Connect ADDR to GND for address 0x23.
    • Connect ADDR to VCC for address 0x5C.
  4. Initialize the Sensor: Configure the BH1750 in your microcontroller's code to start taking measurements.

Important Considerations and Best Practices

Example Code for Arduino UNO

Below is an example of how to use the BH1750 with an Arduino UNO:

#include <Wire.h>
#include <BH1750.h>

// Create an instance of the BH1750 library
BH1750 lightMeter;

void setup() {
  Serial.begin(9600); // Initialize serial communication at 9600 baud
  Wire.begin();       // Initialize I2C communication

  // Initialize the BH1750 sensor
  if (lightMeter.begin(BH1750::CONTINUOUS_HIGH_RES_MODE)) {
    Serial.println("BH1750 initialized successfully");
  } else {
    Serial.println("Error initializing BH1750. Check connections.");
    while (1); // Halt execution if initialization fails
  }
}

void loop() {
  // Read light intensity in lux
  float lux = lightMeter.readLightLevel();

  // Print the light intensity to the Serial Monitor
  Serial.print("Light Intensity: ");
  Serial.print(lux);
  Serial.println(" lux");

  delay(1000); // Wait for 1 second before taking the next reading
}

Troubleshooting and FAQs

Common Issues and Solutions

  1. No Data from the Sensor

    • Cause: Incorrect I2C wiring or address mismatch.
    • Solution: Verify the SDA and SCL connections and ensure the correct I2C address is used in the code.
  2. Inaccurate Readings

    • Cause: Direct light exposure or unstable power supply.
    • Solution: Shield the sensor from direct light and ensure a stable 3.3V power source.
  3. Sensor Not Initializing

    • Cause: Faulty connections or incorrect initialization code.
    • Solution: Double-check all connections and ensure the initialization code matches the selected I2C address.

FAQs

Q: Can the BH1750 operate at 5V?
A: No, the BH1750 operates at a voltage range of 2.4V to 3.6V. Use a level shifter if interfacing with a 5V system.

Q: How do I change the measurement mode?
A: The BH1750 library allows you to set different modes (e.g., high resolution, low resolution) using the begin() function. Refer to the library documentation for details.

Q: What is the maximum distance for I2C communication?
A: The maximum distance depends on the pull-up resistor values and the I2C clock speed. For typical setups, keep the distance under 1 meter for reliable communication.