Arduino BH1750 Light Sensor: Wiring, Code and Simulator

To build this Arduino BH1750 Light Sensor project you need an Arduino Uno and a light sensor BH1750. A BH1750 digital light sensor read in lux. Make the 4 connections in the wiring table, upload the Arduino C++ code, and move the Illuminance slider: office light is about 500 lx, sunlight tens of thousands.

Open this circuit in the free Arduino Uno simulator

Parts list

QtyPartWhat it does
1Arduino Unothe microcontroller board
1Light Sensor BH1750A digital light meter in lux on I²C (0x23; 0x5C with ADDR high): lightMeter.begin(), readLightLevel().

Wiring

#FromTo
1Arduino Uno 5VLight Sensor BH1750 VCC
2Arduino Uno GNDLight Sensor BH1750 GND
3Arduino Uno A4Light Sensor BH1750 SDA
4Arduino Uno A5Light Sensor BH1750 SCL

Step by step

  1. Open the simulator. Open the BitForBytes Embedded Lab in your browser and start from the Arduino Uno. No install or account is needed.
  2. Add the parts. Add a light sensor BH1750 from the parts palette.
  3. Wire 1. Connect Arduino Uno 5V to Light Sensor BH1750 VCC.
  4. Wire 2. Connect Arduino Uno GND to Light Sensor BH1750 GND.
  5. Wire 3. Connect Arduino Uno A4 to Light Sensor BH1750 SDA.
  6. Wire 4. Connect Arduino Uno A5 to Light Sensor BH1750 SCL.
  7. Paste the Arduino C++ code. Paste the Arduino C++ code below into the code editor.
  8. Run it. Press Run. Move the Illuminance slider: office light is about 500 lx, sunlight tens of thousands.

Arduino C++ code

// BH1750: a digital light meter in lux, over I2C.
#include <Wire.h>
#include <BH1750.h>

BH1750 meter;

void setup() {
  Serial.begin(9600);
  Wire.begin();
  meter.begin();
}

void loop() {
  float lux = meter.readLightLevel();
  Serial.print("Light: ");
  Serial.print(lux, 0);
  Serial.println(" lx");
  delay(500);
}

What to try

Move the Illuminance slider: office light is about 500 lx, sunlight tens of thousands.

Frequently asked questions

How do I wire the BH1750 Light Sensor project on an Arduino Uno?

Make 4 connections: Arduino Uno 5V to Light Sensor BH1750 VCC; Arduino Uno GND to Light Sensor BH1750 GND; Arduino Uno A4 to Light Sensor BH1750 SDA; Arduino Uno A5 to Light Sensor BH1750 SCL.

What parts do I need for this Arduino project?

An Arduino Uno and a light sensor BH1750.

Can I simulate this Arduino project online for free?

Yes. The BitForBytes Embedded Lab runs this exact circuit and Arduino C++ code in your browser for free, with no install and no hardware. The sketch is compiled with the real Arduino toolchain and runs on an emulated ATmega328P.

What does the code do?

A BH1750 digital light sensor read in lux.

More Arduino Uno projects