Home / Tutorials / Arduino Tutorial / Using the BH1750 (GY-30) Sensor with Arduino
BH1750 GY-30 breakout board

Using the BH1750 (GY-30) Sensor with Arduino

The BH1750 is a light intensity sensor which interfaces with a microcontroller through the I2C bus. It can directly provide lux values without further processing unlike CdS cells or photodiodes.

Overview

Illuminance is a measure of how much an incident light lightens up a given surface. It is given in lumens per square meter or lumens for square foot; the latter is equivalent to a foot-candle while the former is to a lux.

The BH1750 offers lux measurement in two modes: continuous and one-shot. When in continuous mode, the sensor measures light intensity non-stop. When in the latter mode, single measurements are done then the sensor powers down.

The user can specify the sensitivity for both modes. A BH1750 in low resolution detects a minimum of 4 lux in 16 milliseconds. Moreover, a BH1750 in high resolution detects as low as 1 lux in 120 milliseconds. A third sensitivity mode (high resolution 2) enables the sensor to measure as low as 0.5 lux in 120 milliseconds.

The maximum lux value for the low and high resolution modes is 54612.5 lux. This is about five times of full daylight. In high resolution 2 mode, the maximum lux value reduces to 27306.25 lux.

Condition Illumination (lux)
Sunlight 107,527
Full Daylight 10,752
Overcast Day 1,075
Very Dark Day 107
Twilight 10.8
Deep Twilight 1.08
Full Moon .108
Quarter Moon .0108
Starlight .0011
Overcast Night .0001

Wiring the BH1750 to Arduino

For this article, I am using the GY-30 breakout board:

BH1750 GY-30 breakout board

The breakout board not only contains the sensor (in circle) but also other required components. This makes it ready to interface with a microcontroller like an Arduino.

As mentioned, the BH1750 uses the I2C bus, hence, it uses only two pins for data:

Arduino to BH1750 wiring diagram

The ADD pin helps determine the I2C address of the BH1750. When the voltage to this pin is less than 70% of VCC, the address is 0x23. Otherwise, the I2C address is 0x5C. For our setup above, in which ADD is floating, the address is 0x23.

Programming

There are tons of Arduino libraries for the BH1750, but the one I find easiest to use is by Christopher Laws.

You can download the library from the link above and extract if to your Documents/Arduino/libraries folder or you can use the IDE’s library manager:

Add library through IDE

Search for BH1750 and Laws’ library is the first result:

Search for BH1750 and install

The library comes with five examples. The best one to get started to is the BH1750Test.

Reading the lux values is fairly easy. First step is to create an object from the BH1750 class which is usable after including the library:
Then, invoke begin() function then the readLightLevel() function which returns a float value:
In BH1750Test sketch above, the lux levels are printed in the Serial Monitor.

By default, the library uses continuous high resolution mode. To change this, pass the parameter either to begin() or to another function configure(). The possible parameters are:

For example, if you want to use one shot, high resolution mode, then:

Or

Normally, the sensor reverts to the default mode after a data is sent using one shot mode. However, the library automatically uses the same mode even if the previous mode is one shot.

Applications

In case you’re wondering where lux meters are used, just look at your phone. The brightness of your phone’s screen adjusts to ambient light. This is possible through a lux sensor like the BH1750.

Buildings follow a set of standards for the correct amount of illumination. Checking this requires a lux meter. Here’s the recommended illumination for rooms in a house:

Domestic Areas Lux Level
Hallway & Landing 500
Stairs 100
Dining Room 200
Kitchen 300
Living Room 300-500
Laundry or Utility Room 200
Bathroom 300
Bedroom (Adults) 300
Bedroom (Children) 500
Study Room or Home Office 500-800
Workshop, Shed or Garage 800-1100

Check Also

HX711 Load Cell

How to Use Load Cell with HX711 and Arduino

Measuring an object’s weight can sometimes be part of a bigger project. And unless you …

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.