BH1750 I2C Light Sensor

Overview

This module interfaces to the BH1750 Light Sensor made by Rohm Semiconductor. This is a simple, inexpensive light sensor which provides reasonably accurate, quantitative values for the light level. The BH1750 can be operated in continuous or single measurement mode, and has resolution settings of 0.5 lx, 1 lx, and 4 lx, and communicates over I2C. This offers a way to measure light levels more accurately and consistently than using a light-dependent resistor.

Wiring

It is recommended to use one of the widely available modules, as the part has very fine pitch pins, making it difficult to solder at home; additionally, these modules handle the DVI pin. If using the bare component, see the datasheet for more information.

Connect VCC to +3.3v, Ground to Ground, and SCL and SDA to the corresponding pins of the I2C bus. Addr should be connected to either ground or vcc, to set the I2C address to be used.

Setup

Setup I2C, then call:

var bh=require("BH1750").connect(i2c, addr)

i2c is the i2c bus.

addr is the value of the address pins - true if it's connected to VCC, otherwise it should be omitted or set to false.

Start Measuring

bh.start(resolution,onetime)

resolution is 1, 2 or 3: 1 - High Resolution mode, accurate to 1 lx. Recommended by manufacturer. 2 - Low Resolution mode, accurate to 4 lx. 3 - High Resolution mode 2, accurate to 0.5 lx.

onetime is either true (1) or false (0). If false (or omitted), the part will be put into continuous measurement mode. If true, the part will take only a single measurement, which will be available after 120ms.

Reading

bh.read() returns the current light level, in lux.

Other

Two additional functions are provided, to power down, power up, and soft-reset the part. When you call connect(), the part is automatically powered on and reset.

bh.power(1) //power on
bh.power(0) //power off
bh.reset()

Finally, the measurement time can be adjusted within the limits specified in the datasheet. The scaling factor is automatically adjusted. See the datasheet for more details on the MT option.

bh.setMT(mt)

Buying

BH1750 sensors can be purchased from many places:

This page is auto-generated from GitHub. If you see any mistakes or have suggestions, please let us know.