Contact Sales & After-Sales Service

Contact & Quotation

  • Inquire: Call 0086-755-23203480, or reach out via the form below/your sales contact to discuss our design, manufacturing, and assembly capabilities.
  • Quote: Email your PCB files to Sales@pcbsync.com (Preferred for large files) or submit online. We will contact you promptly. Please ensure your email is correct.
Drag & Drop Files, Choose Files to Upload You can upload up to 3 files.

Notes:
For PCB fabrication, we require PCB design file in Gerber RS-274X format (most preferred), *.PCB/DDB (Protel, inform your program version) format or *.BRD (Eagle) format. For PCB assembly, we require PCB design file in above mentioned format, drilling file and BOM. Click to download BOM template To avoid file missing, please include all files into one folder and compress it into .zip or .rar format.

BH1750 Arduino: Digital Light Sensor Tutorial

Working with light-dependent resistors gets frustrating when you need actual lux values instead of arbitrary analog readings. The BH1750 Arduino combination solves this problem elegantly, providing calibrated digital illuminance measurements that require zero manual conversion.

I’ve used this sensor in everything from automatic greenhouse lighting to display brightness controllers, and it consistently delivers reliable results with minimal code complexity. This tutorial covers the complete integration process from wiring to advanced measurement modes.

What is the BH1750 Ambient Light Sensor?

The BH1750FVI is a 16-bit digital ambient light sensor manufactured by ROHM Semiconductor. Unlike photoresistors that output variable resistance requiring ADC conversion and calibration, the BH1750 provides direct digital lux readings over the I2C bus.

Inside the chip, a photodiode with spectral response matched to human eye sensitivity generates current proportional to incident light. An integrated transimpedance amplifier converts this current to voltage, which the onboard ADC digitizes. The internal logic then calculates illuminance in lux units and transmits the result via I2C.

This architecture means you get consistent, calibrated measurements without dealing with reference voltages, voltage dividers, or lookup tables. The sensor outputs values from 1 to 65535 lux, covering conditions from dim indoor lighting through bright outdoor environments.

BH1750 Technical Specifications

Here are the key specifications from the ROHM datasheet:

ParameterValue
Supply Voltage2.4V – 3.6V (IC), 3.3V – 5V (module)
Supply Current120 µA (typical)
Standby Current1 µA (typical)
Measurement Range1 – 65535 lux
Resolution1 lux (High Res), 4 lux (Low Res), 0.5 lux (High Res Mode 2)
Measurement Time120 ms (High Res), 16 ms (Low Res)
InterfaceI2C (up to 400 kHz)
I2C Addresses0x23 (default), 0x5C (ADDR high)
Spectral ResponseApproximates human eye
Accuracy±20% typical

The module versions commonly sold include an onboard 3.3V regulator and I2C pull-up resistors, making them safe to connect directly to 5V Arduino boards.

BH1750 Pinout Configuration

Most BH1750 breakout modules expose five pins:

PinNameFunction
1VCCPower supply (3.3V – 5V on modules)
2GNDGround
3SCLI2C Clock
4SDAI2C Data
5ADDRI2C Address selection

The ADDR pin determines the sensor’s I2C address. When left floating or connected to ground (voltage below 0.7×VCC), the address is 0x23. Pulling ADDR high (above 0.7×VCC) changes the address to 0x5C. This allows two BH1750 sensors on the same I2C bus with different addresses.

Understanding Lux Measurement

Lux is the SI unit of illuminance, measuring luminous flux per unit area. Here’s a practical reference:

ConditionTypical Lux Value
Moonless night0.0001 lux
Full moon0.3 – 1 lux
Street lighting10 – 50 lux
Office lighting300 – 500 lux
Overcast day1,000 – 2,000 lux
Indirect sunlight10,000 – 25,000 lux
Direct sunlight32,000 – 100,000 lux

The BH1750’s 65535 lux maximum means it saturates in direct sunlight. For outdoor applications, you may need an optical filter or different sensor.

BH1750 Measurement Modes

The sensor supports six measurement modes grouped into two categories:

Continuous Measurement Modes

In continuous mode, the sensor repeatedly measures and updates its output register automatically:

ModeResolutionMeasurement Time
Continuous High Resolution1 lux120 ms
Continuous High Resolution 20.5 lux120 ms
Continuous Low Resolution4 lux16 ms

One-Time Measurement Modes

In one-time mode, the sensor takes a single measurement then enters power-down mode automatically:

ModeResolutionMeasurement Time
One-Time High Resolution1 lux120 ms
One-Time High Resolution 20.5 lux120 ms
One-Time Low Resolution4 lux16 ms

The datasheet recommends High Resolution mode for most applications. The 120 ms integration time rejects 50Hz and 60Hz noise from artificial lighting, providing more stable readings. Use Low Resolution mode only when you need faster updates and can tolerate reduced accuracy.

Wiring BH1750 to Arduino

The I2C connection requires just four wires:

BH1750 PinArduino UNOArduino MegaNotes
VCC5V (or 3.3V)5V (or 3.3V)Module has regulator
GNDGNDGNDCommon ground
SCLA521I2C Clock
SDAA420I2C Data
ADDRGND or NCGND or NC0x23 address

For dual-sensor configurations, connect one ADDR pin to GND (address 0x23) and the other to VCC (address 0x5C).

Installing the BH1750 Library

Several libraries support the BH1750. The most popular is the BH1750 library by Christopher Laws:

Open Arduino IDE, navigate to Sketch → Include Library → Manage Libraries. Search for “BH1750” and install the library by Christopher Laws. This library handles all the I2C communication and mode configuration.

Alternative libraries include hp_BH1750 by Stefan Armborst (recommended by Adafruit) and ErriezBH1750 for more advanced features.

Basic Arduino Code Example

Here’s a minimal sketch to read and display lux values:

#include <Wire.h>

#include <BH1750.h>

BH1750 lightMeter;

void setup() {

  Serial.begin(9600);

  Wire.begin();

  if (lightMeter.begin()) {

    Serial.println(“BH1750 initialized”);

  } else {

    Serial.println(“BH1750 not found!”);

    while (1);

  }

}

void loop() {

  float lux = lightMeter.readLightLevel();

  Serial.print(“Light: “);

  Serial.print(lux);

  Serial.println(” lux”);

  delay(1000);

}

Upload the code and open the Serial Monitor at 9600 baud. You should see lux readings updating every second. Wave your hand over the sensor or shine a flashlight on it to verify the values change appropriately.

Advanced Mode Configuration

To use different measurement modes, pass the mode parameter to begin():

#include <Wire.h>

#include <BH1750.h>

BH1750 lightMeter;

void setup() {

  Serial.begin(9600);

  Wire.begin();

  // Use One-Time High Resolution Mode

  lightMeter.begin(BH1750::ONE_TIME_HIGH_RES_MODE);

}

void loop() {

  float lux = lightMeter.readLightLevel();

  Serial.print(“Light: “);

  Serial.print(lux);

  Serial.println(” lux”);

  // In one-time mode, configure again before next reading

  lightMeter.configure(BH1750::ONE_TIME_HIGH_RES_MODE);

  delay(1000);

}

Available mode constants:

  • BH1750::CONTINUOUS_HIGH_RES_MODE (default)
  • BH1750::CONTINUOUS_HIGH_RES_MODE_2 (0.5 lux resolution)
  • BH1750::CONTINUOUS_LOW_RES_MODE
  • BH1750::ONE_TIME_HIGH_RES_MODE
  • BH1750::ONE_TIME_HIGH_RES_MODE_2
  • BH1750::ONE_TIME_LOW_RES_MODE

Displaying Lux on LCD

Combining the BH1750 with a 16×2 LCD creates a practical light meter:

#include <Wire.h>

#include <BH1750.h>

#include <LiquidCrystal.h>

BH1750 lightMeter;

LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

void setup() {

  Wire.begin();

  lightMeter.begin();

  lcd.begin(16, 2);

  lcd.print(“Light Intensity”);

}

void loop() {

  float lux = lightMeter.readLightLevel();

  lcd.setCursor(0, 1);

  lcd.print(”                “);  // Clear line

  lcd.setCursor(0, 1);

  lcd.print(lux);

  lcd.print(” lux”);

  delay(500);

}

Automatic Lighting Control Project

Here’s a practical application that controls an LED based on ambient light:

#include <Wire.h>

#include <BH1750.h>

BH1750 lightMeter;

const int ledPin = 9;

const int threshold = 100;  // Lux threshold

void setup() {

  Serial.begin(9600);

  Wire.begin();

  lightMeter.begin();

  pinMode(ledPin, OUTPUT);

}

void loop() {

  float lux = lightMeter.readLightLevel();

  Serial.print(“Lux: “);

  Serial.print(lux);

  if (lux < threshold) {

    digitalWrite(ledPin, HIGH);

    Serial.println(” – LED ON”);

  } else {

    digitalWrite(ledPin, LOW);

    Serial.println(” – LED OFF”);

  }

  delay(500);

}

This sketch turns on an LED when ambient light drops below 100 lux, simulating automatic night lighting.

BH1750 vs LDR Comparison

Why choose the BH1750 over a simple photoresistor?

FeatureBH1750LDR (Photoresistor)
OutputDigital lux valueAnalog resistance
CalibrationFactory calibratedRequires manual calibration
Accuracy±20%Varies widely
Light Source IndependenceHighLow
InterfaceI2C (2 pins)Analog (1 pin + resistor)
Cost~$2-5 module~$0.10-0.50
Code ComplexityLowerHigher

For projects requiring actual lux measurements or consistent behavior across units, the BH1750 saves significant development time despite higher component cost.

Troubleshooting Common Issues

Sensor Not Detected

Verify I2C connections (SDA to A4, SCL to A5 on UNO). Run an I2C scanner sketch to confirm the address. Check if ADDR pin state matches the address in your code (0x23 for ADDR low, 0x5C for ADDR high).

Readings Stuck at Zero

Ensure the sensor has power (check LED indicator if present on module). Allow 180 ms after power-up before first reading. Verify the correct measurement mode is configured.

Inconsistent Readings

Use High Resolution mode for better noise rejection. Add averaging in software if readings fluctuate under fluorescent lights. Ensure stable power supply without voltage drops.

Maximum Value (65535)

The sensor is saturated. Reduce light intensity or add a neutral density filter. Consider a sensor with higher range for outdoor applications.

Useful Resources and Downloads

ResourceDescription
BH1750 Datasheet (ROHM)Official IC specifications
BH1750 Arduino LibraryChristopher Laws library
hp_BH1750 LibraryAlternative library by Stefan Armborst
Erriez BH1750 LibraryFeature-rich library
Adafruit BH1750 GuideTutorial and wiring diagrams

Frequently Asked Questions

Can I use the BH1750 with 5V Arduino boards?

Yes, most BH1750 modules include an onboard 3.3V regulator and I2C level shifting. You can safely connect VCC to the Arduino’s 5V pin. The module handles voltage conversion internally.

How do I connect two BH1750 sensors to one Arduino?

Use the ADDR pin to assign different I2C addresses. Connect one sensor’s ADDR to GND (address 0x23) and the other’s ADDR to VCC (address 0x5C). Create two BH1750 objects in code, specifying each address.

What measurement mode should I use?

For most indoor applications, use Continuous High Resolution Mode (the default). It provides 1 lux resolution and rejects 50/60 Hz lighting noise. Use Low Resolution Mode only when you need updates faster than 120 ms.

Why do readings differ from my phone’s lux meter?

Variations are normal due to sensor calibration differences, spectral response variations, and measurement geometry. The BH1750’s ±20% accuracy specification means readings within that range of a reference meter are acceptable.

Can the BH1750 measure direct sunlight?

The sensor saturates at 65535 lux, while direct sunlight can exceed 100,000 lux. For outdoor applications in bright conditions, you’ll need an optical filter or a sensor with higher dynamic range.

Building Better Light-Sensing Projects

The BH1750 Arduino pairing delivers professional-grade ambient light sensing at hobbyist prices. The I2C interface keeps wiring simple, the digital output eliminates calibration headaches, and the multiple measurement modes provide flexibility for various applications.

Start with the basic code example to verify your wiring, then expand into projects like automatic display brightness, plant growth monitors, or energy-efficient lighting controllers. The sensor’s human-eye-matched spectral response makes it particularly suitable for applications involving visual comfort or display optimization.


Meta Description:

“Learn to use the BH1750 digital light sensor with Arduino. Complete tutorial with wiring diagram, code examples, measurement modes, and lux meter project. Step-by-step guide.”

(167 characters)

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Sales & After-Sales Service

Contact & Quotation

  • Inquire: Call 0086-755-23203480, or reach out via the form below/your sales contact to discuss our design, manufacturing, and assembly capabilities.

  • Quote: Email your PCB files to Sales@pcbsync.com (Preferred for large files) or submit online. We will contact you promptly. Please ensure your email is correct.

Drag & Drop Files, Choose Files to Upload You can upload up to 3 files.

Notes:
For PCB fabrication, we require PCB design file in Gerber RS-274X format (most preferred), *.PCB/DDB (Protel, inform your program version) format or *.BRD (Eagle) format. For PCB assembly, we require PCB design file in above mentioned format, drilling file and BOM. Click to download BOM template To avoid file missing, please include all files into one folder and compress it into .zip or .rar format.