Using the BH1750 light sensor

This sensor can give a fairly accurate indication of light level and is available on the usual breakout board.


Connection is as follows

Gnd to Arduino Gnd
ADD to Gnd for 0x23 or 5volts for 0x5C address
SDA to Arduino A4
SCL to Arduino A5
Vcc to Arduino 5volts

The sketch I used reports light levels in lux units, the Serial Monitor needs to be set to 9600.

// Measuring Light Intensity with the BH1750 board
// Connect Gnd --> Gnd
// Connect ADD --> Gnd for address 0x23 or leave unconnected
// Connect ADD --> Vcc 5v for address 0x5C
// Connect SDA --> A4
// Connect SCL --> A5
// Connect Vcc --> 5 volts

int ledPin =13; // onboard LED

#include //BH1750 IIC Mode
int BH1750address = 0x23; //setting i2c address with ADD LOW
//int BH1750address = 0x5C; //setting i2c address with ADD HIGH

byte buff[2];
void setup()
Serial.begin(9600);//init Serial band rate
pinMode(ledPin, OUTPUT);

void loop()
int i;
uint16_t val=0;

val=((buff[0]< 1000) { // set the level here
digitalWrite(ledPin,HIGH); // turn on the onboard LED if light level above a certain amount
else {
digitalWrite(ledPin, LOW);

int BH1750_Read(int address) //
int i=0;
Wire.requestFrom(address, 2);
while(Wire.available()) //
buff[i] =; // receive one byte
return i;

void BH1750_Init(int address)
Wire.write(0x10);//1lx reolution 120ms


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: