Instructables
BH1750FVI Is a Digital Light sensor , which is an digital Ambient Light Sensor IC for I2C bus interface. This IC is the most suitable to obtain the ambient light data for adjusting LCD and Keypad backlight power of Mobile phone. It is possible to detect wide range at High resolution.( 1 - 65535 lx ).

this sensor has some advantages such like :

1) Illuminance to Digital Converter
2) Wide range and High resolution. ( 1 - 65535 lx )
3) Low Current by power down function
4) 50Hz / 60Hz Light noise reject-function
5) I2C bus Interface ( f / s Mode Support )
6) No need any external parts
7) It is possible to select 2 type of I2C slave-address.
8) It is possible to detect min. 0.11 lx, max. 100000 lx by using this function.

DataSheet for this sensor will be found here 

it's easy to use and connect , so Let's started

We will need :

1) Arduino Board" Uno,Nano,mini .. "

2)BH1750 Breakout .

3)Solderless Jumper

4)CD4050 Hex Buffer IC , Or 510 Ohm resistor *3

5)BreadBoard .

 
Remove these adsRemove these ads by Signing Up

Step 1: Definition of luminous ,Lumen

Picture of Definition of luminous ,Lumen
illuminance is a measure of how much luminous flux is spread over a given area. One can think of luminous flux (measured in lumens) as a measure of the total "amount" of visible light present, and the illuminance as a measure of the intensity of illumination on a surface 

Lumen : The unit for the quantity of light flowing from a source in any one second (the luminous power, or luminous flux) is called the lumen.


In our sensor we will take a reading from it in Lux which is equal  to one lumen per square metre:

Lux = 1 Lm/m2 .


If you'd like to make the light sensor wireless (send the lux value over-the-air somewhere), have a look at the MySensors project. You'll find an light sensor example here:
http://www.mysensors.org/build/light

suvinks4 months ago

I tried to use our library and get my BH1750fvi sensor to work. However it did not. It gave me a constant output of 54612 :(

Could you help? I tried on both arduino mega and duemilinove

I too got the same output!..Did u debug it?

it was an issue with the sensor. Returned it and got a new one. It worked fine

Check the Address it should be 0x23 for single sensor and no need to connect with Ground

baranc1 month ago

I tried to build a setup using BH1750 and an LCD display (this:http://farm9.staticflickr.com/8046/8115486011_a99d721319_b.jpg). I can't seem to connect them simultaneously to an arduino nano 3.0 via I2C. Modified your code to use LCD, tried changing the sensors address as mentioned before yet I couldn't menage to resolve the issue. I'm new at this. Thanks in advance.

IMG_2138.JPG
ChrisM31 month ago

I linked up a bh1750 to my arduino uno, I haven't gone as far as this article with the display screen so my implementation is a little simpler as I'm going to be using this as part of my weather station. It's the article called 'Heat & Light' (the heat is for soldering, the light, well, it should be obvious ;) )

http://www.hmgkry.net

mattthegamer463 made it!1 month ago

Thanks for this, using your code I got my sensor running in 10 minutes and had it integrated into the rest of my code in another 10. I'm working on an ultra-small digital incident/reflected/spot meter for photography. Great work!

IMG_20140821_083604 (Custom).jpgIMG_20140821_083625 (Custom).jpg
oxygen6668 months ago

Hi,

I m going to use 2 lux module for my project and i copied the "Read the Lux value via serial Port " code as well as library to my arduino but there is errors as shown below it also show BH1750FVI does not name a type.

can u please help me to solve this problem

thanks in advance

+++++++++++++++++++++++++++++++++++++++++

sketch_jan22a:23: error: 'BH1750FVI' does not name a type
sketch_jan22a.ino: In function 'void setup()':
sketch_jan22a:28: error: 'LightSensor' was not declared in this scope
sketch_jan22a:36: error: 'Device_Address_H' was not declared in this scope
sketch_jan22a:53: error: 'Continuous_H_resolution_Mode' was not declared in this scope
sketch_jan22a.ino: In function 'void loop()':
sketch_jan22a:61: error: 'LightSensor' was not declared in this scope

+++++++++++++++++++++++++++++++++++++++++++++

Mohannad Rawashdeh (author)  oxygen6668 months ago

OK , is 1 Module worked with you perfectly ?
You just need to connect/disconnect ADD Pin and set the address for each module lonely .

What will be the pin connection for 2nd module? Same? Vcc,GND,A5,A4,A3??? Should we short two modules? Or need to manually connect the pins when needed to be change? This is your code modified for two module. Am i going right? Please help me with the pin connection for 2nd module and check the code if anything is wrong or not.

/*

This is a simple code to test BH1750FVI Light senosr

communicate using I2C Protocol

this library enable 2 slave device address

Main address 0x23

secondary address 0x5C

connect this sensor as following :

VCC >>> 3.3V

SDA >>> A4

SCL >>> A5

addr >> A3

Gnd >>>Gnd

Written By : Mohannad Rawashdeh

*/

// First define the library :

#include <Wire.h>

#include <BH1750FVI.h>

BH1750FVI LightSensor;

BH1750FVI lightMeter;

void setup() { // put your setup code here, to run once:

Serial.begin(9600);

LightSensor.begin();

lightMeter.begin();

/*

Set the address for this sensor

you can use 2 different address

Device_Address_H "0x5C"

Device_Address_L "0x23"

you must connect Addr pin to A3 .

*/

LightSensor.SetAddress(Device_Address_H);//Address 0x5C

// To adjust the slave on other address , uncomment this line

lightMeter.SetAddress(Device_Address_L); //Address 0x5C

//-----------------------------------------------

/*

set the Working Mode for this sensor

Select the following Mode:

Continuous_H_resolution_Mode

Continuous_H_resolution_Mode2

Continuous_L_resolution_Mode

OneTime_H_resolution_Mode

OneTime_H_resolution_Mode2

OneTime_L_resolution_Mode

The data sheet recommanded To use Continuous_H_resolution_Mode

*/

LightSensor.SetMode(Continuous_H_resolution_Mode);

lightMeter.SetMode(Continuous_H_resolution_Mode);

Serial.println("Running...");

}

void loop() {

// put your main code here, to run repeatedly:

uint16_t lux = LightSensor.GetLightIntensity();// Get Lux value

Serial.print("Light 1: ");

Serial.print(lux);

Serial.println(" lux");

delay(10);

lux = lightMeter.GetLightIntensity();// Get Lux value

Serial.print("Light 2: ");

Serial.print(lux);

Serial.println(" lux");

delay(1000);

}

Your code is working for me i removed A3 connection and connected to 3.3 v now both sensor are working

Connection:

VCC- 5v

GND- GND

SCL- A5

SDA- A4

ADD- NC for 0x23 address, and 3.3v for 0x5C address

You can try below code also

/* Connection:

VCC- 5v

GND- GND

SCL- A5

SDA- A4

ADD- NC for 0x23 address, and 3.3v for 0x5C address

*/

#include <Wire.h> //Handle I2C mode for BH1750 sensor Pin 4 SDA, 5 SCL

#include <math.h> //Math library

//BH1750 I2C Address

int Sen1 = 0x23;

int Sen2 = 0x5C;

//Define the string for datastream ID

char sensor1[] = "Sen1";

char sensor2[] = "Sen2";

byte buff[2];

void setup(){

Wire.begin();

Serial.begin(9600);

delay(1000);

}

void loop(){

int i;

uint16_t val1=0, val2=0;

//send signal to sensor 1

BH1750_Init(Sen1);

delay(100);

//read sensor 1 value

if(2==BH1750_Read(Sen1)){

val1 = ((buff[0]<<8)|buff[1])/1.2;

Serial.print("Light 1 : ");

Serial.println(val1,DEC);

}

delay(100);

//send signal to sensor 2

BH1750_Init(Sen2);

delay(100);

//read sensor 2 value

if(2==BH1750_Read(Sen2)){

val2 = ((buff[0]<<8)|buff[1])/1.2;

Serial.print("Light 2 : ");

Serial.println(val2,DEC);

}

delay(100);

Serial.println();

delay(1000);

}

//custom parameter for request values from sensor

int BH1750_Read(int address){

int i = 0;

Wire.beginTransmission(address);

Wire.requestFrom(address,2);

while(Wire.available()){

buff[i] = Wire.read();

i++;

}

Wire.endTransmission();

return i;

}

//custom parameter for receive values from sensor

void BH1750_Init(int address){

Wire.beginTransmission(address);

Wire.write(0x10);

Wire.endTransmission();

}

Yes, One of the sensor is working perfect. can you please put the complete code based on 2 sensor here. because i tried to modify the code but i couldn't

Lectric Wizard11 months ago
Thanks for the information !!! I purchased a couple of these boards & would like to build a solar tracker. When do you think you will be publishing your system ?
Mohannad Rawashdeh (author)  Lectric Wizard11 months ago
I will try it soon :)

hi.. I implemented your code..Its giving a constant output of 54612 LUX which is too high a value!!..Pls help

ademmler11 months ago
Nice library and work. Can you provide explanation how to connect the LCD panel?
Mohannad Rawashdeh (author)  ademmler11 months ago
It's already found on step # 5 .

What will be the pin connection for 2nd module? Same? Vcc,GND,A5,A4,A3??? Should we short two modules? Or need to manually connect the pins when needed to be change? This is your code modified for two module. Am i going right? Please help me with the pin connection for 2nd module and check the code if anything is wrong or not.

What will be the pin connection for 2nd module? Same? Vcc,GND,A5,A4,A3??? Should we short two modules? Or need to manually connect the pins when needed to be change? This is your code modified for two module. Am i going right? Please help me with the pin connection for 2nd module and check the code if anything is wrong or not.

Eddiebellamy5 months ago

Hi! I want to know if I can use the BH1750 with a PIC instead of Arduino.

Thanks!

Eddiebellamy5 months ago

Hi! I want to know if I can use the BH1750 with a PIC instead of Arduino.

Thanks!

NaaaF1 year ago
Nice job!