Instructables

BH1750 Digital Light Sensor

Featured
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 .


suvinks1 month 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?

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 ?
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

oxygen6666 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)  oxygen6665 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);

}

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

ademmler8 months ago
Nice library and work. Can you provide explanation how to connect the LCD panel?
Mohannad Rawashdeh (author)  ademmler8 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.

Eddiebellamy2 months ago

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

Thanks!

Eddiebellamy2 months ago

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

Thanks!

NaaaF9 months ago
Nice job!
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!