Using the BH1750 with Arduino is a simple matter of wiring up the sensor to your Arduino-compatible microcontroller, installing the hp_BH1750 library written by Stefan Armborst, and running one of many very well written examples. Usually we write our own library but we were so impressed by Stefan's that we didn't think we could possibly improve on it, so use it!

I2C Wiring

Use this wiring if you want to connect via I2C interface. The I2C address address for the BH1750 is 0x23 and can be switched to 0x5C by pulling the address pin high to VCC

Here is how to wire up the sensor using one of the STEMMA QT connectors. The examples show a Metro but wiring will work the same for an Arduino or other compatible board.

  •  Connect board VIN (red wire) to Arduino 5V if you are running a 5V board Arduino (Uno, etc.). If your board is 3V, connect to that instead.
  • Connect board GND (black wire) to Arduino GND
  • Connect board SCL (yellow wire) to Arduino SCL
  • Connect board SDA (blue wire) to Arduino SDA

Here is how to wire the sensor to a board using a solderless breadboard:

  • Connect board VIN (red wire) to Arduino 5V if you are running a 5V board Arduino (Uno, etc.). If your board is 3V, connect to that instead.
  • Connect board GND (black wire) to Arduino GND
  • Connect board SCL (yellow wire) to Arduino SCL
  • Connect board SDA (blue wire) to Arduino SDA

Library Installation

You can install the hp_BH1750 library for Arduino using the Library Manager in the Arduino IDE.

Click the Manage Libraries ... menu item, search for hp BH1750, and select the hp_BH1750 library:

Load Example

To show the fundamental feature of the sensor, measuring the ambient light in lux, you can use the modestly titled "BareMinimum" example:

Open File -> Examples -> hp_BH1750 -> BareMinimum

After opening the demo file, upload to your Arduino wired up to the sensor. Once you upload the code, you will see the Lux values being printed when you open the Serial Monitor (Tools->Serial Monitor) at 9600 baud, similar these measurements I got from waving a flashlight at the sensor

Example Code


A full listing of the above example can be found in the hp_BH1750 repo's example directory along with several other examples that show the many features of the library.

This guide was first published on Jul 21, 2020. It was last updated on Jul 21, 2020.
This page (Arduino) was last updated on Sep 20, 2020.