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

Step 1: 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 .


<p>This sketch requires <strong>BH1750.h</strong> library. </p><p>You can download the library here</p><p><a href="https://docs.google.com/file/d/0B4qM0hq-OmC1RHhEcXRNSmZ1YW8/" rel="nofollow">https://docs.google.com/file/d/0B4qM0hq-OmC1RHhEcXRNSmZ1YW8/</a></p><p>I made it from http://sunrobotics.co.in/index.php?main_page=product_info&amp;cPath=22&amp;products_id=415</p>
<p>Does BH1750 work with mega 2560 board also?It worked fine with uno.But although i tried i couldn't get it successfully connected with mega.It constatntly gives 54612 lux as the intensity.what should i do to make it work with mega?Please help me out here.I am trying to do a project with arduino to measure light intensity</p>
<p>Not bad, but in need of some polish for itsrough &quot;edges&quot;.</p><p>The comments/questions about setting and using I2C slave address are newbie question. I think the confusion stems from the article saying that the sensor's <br>ADDR pin line MUST be tied to the Arduino's A3 pin. While that may be OK for testing (to verify the code), there is no reason to design a real embedded system with dynamic I2C slave addressing as all the sensors will be hard-wired. A major benefit of I2C is that it allows using common data and clock lines to communicate with potentially a LOT of peripherals. It's the slave address that is issued over the I2C bus that determines which sensor SHOULD respond. Manufacturers that are licensed and registered to use I2C have address(es) assigned that have little chance of being the same as some other peripheral's address(es). If you are doing an AD HOC design of a slave I2C peripheral, then you may get into trouble, but only if you want your peripheral to be used anywhere.</p><p>The same issues apply to USB's VID/PID (vendor and product IDs). It those aren't coordinated, then everyone loses through the confusion. But it doesn't explain why there isn't a &quot;pool&quot; of open USB addresses for debug and testing or why it's a license violation to &quot;share&quot; one that is &quot;owned&quot;. Most, if not all, of the first USB devices on PCs used the default ones in Microsoft's DDK sample code and library and still do!</p><p>BTW, there are lots other light sensors out there, both simple and complex. Some applications may not need the sophistication (or added expense) of this sensor. A simple CdS sensor or Silicon photo transistor may be suitable with the right adaptation.</p>
<p>sir, can this digital light sensor module be interfaced to fpga to sense the indoor i'light intensity and adjust the LED brightness???</p>
<p>Hello, I wanted to know how to connect more than one BH1750 sensors to a<br> single arduino so that the addresses do not conflict. The output from each<br>sensor should be used to do a specific task, like turning on specific <br>LEDs corresponding to respective sensor. Can anybody give the connection<br> details and the sketch to be uploaded to the arduino. Thanks in <br>advance.</p>
<p>Hello, I wanted to know how to connect more than one BH1750 sensors to a<br> single arduino so that the addresses do not conflict. The output from each <br>sensor should be used to do a specific task, like turning on respective <br>LEDs corresponding to respective sensors. Can anybody give the connection<br> details and the sketch to be uploaded to the arduino? Thanks in <br>advance.</p>
<p>I have a project about Solar panel, that I have use 2 Bh1750 to collect the information and compare to each other, depend on that, I can control the step-motor, make sure the Solar panel receive most light and spread on over the panel. And I dont know how to get the address of the second Bh1750. Can any body help me? Thank u!</p>
i want to interface this sensor with lpc1768 .please give me sample code for this...
I am working on a similar project and got stuck on a proint, and I hope somebody will guide me..the requirement is &quot; I have a hardware devcie which has different color LED's (Green,red and Yellow color) and I have to calculate how many times each color LED glows for each mode of operation,<br><br>So what kind of light sensor I have to use with Arduino UNO to achieve this
<p>easiest way would be to actually take an electric reading at the LED pin (i.e. connect the cathode to a pin for example) and measure what's going on there... 0 probably your LED is off and above a threshold (say a few V) LED is on...</p><p>if you don't have access to the internals of your device, then just stick a photoXXX (XXX= resistor/diode/transistor depending on your needs) in front of each LED (use &quot;patafix&quot; to hold the photoXXX just in front of the diode) and measure what your photoXXX sees.</p>
<p>I have my BH1750 outdoor to test and I get 54612, if I move it to the shadow it drops, so the sensor is working.</p><p>My question is how to change the sensor-range? Or is the sensor getting a maximum input from the sun. Weather now is zero-clouds.</p>
<p>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 :(</p><p>Could you help? I tried on arduino mega</p>
<p>On a mega Rev 3 I got it to work by using pins 20 and 21, new dedicated sda and scl pins</p>
<p>(1) Could someone please explain why the CD4050 works? It is my understanding the 4050 is a mono-directional logic buffer, and</p><p>(2) Can the BH1750 be modified to eliminate its internal pull down resistors so I can include it with multiple other I2C sensors?</p>
<p>test:23: error: 'BH1750FVI' does not name a type<br>test.ino: In function 'void setup()':<br>test:28: error: 'LightSensor' was not declared in this scope<br>test:36: error: 'Device_Address_H' was not declared in this scope<br>test:53: error: 'Continuous_H_resolution_Mode' was not declared in this scope<br>test.ino: In function 'void loop()':<br>test:61: error: 'LightSensor' was not declared in this scope</p>
<p>Hello, I have exactly the same problem as him but on the Arduino Yun! Could you help me?</p>
<p>In Step 3 on your diagram with the IC CD4050, the wiring seems to be incorrect. According to the CD4050 pin-out, pin 13 is not used. Please check.</p>
<p>In Step 3 on your diagram with the IC CD4050, the wiring seems to be incorrect. According to the CD4050 pin-out, pin 13 is not used. Please check.</p>
<p>In Step 3 on your diagram with the IC CD4050, the wiring seems to be incorrect. According to the CD4050 pin-out, pin 13 is not used. Please check.</p>
<p>In Step 3 on your diagram with the IC CD4050, the wiring seems to be incorrect. According to the CD4050 pin-out, pin 13 is not used. Please check.</p>
<p>If you'd like to make the light sensor wireless (send the lux value over-the-air somewhere), have a look at the <a href="http://www.mysensors.org/" rel="nofollow">MySensors</a> project. You'll find an light sensor example here:<br><a href="http://www.mysensors.org/build/light" rel="nofollow">http://www.mysensors.org/build/light</a></p>
<p>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 :(</p><p>Could you help? I tried on both arduino mega and duemilinove</p>
<p>I too got the same output!..Did u debug it?</p>
<p>it was an issue with the sensor. Returned it and got a new one. It worked fine</p>
<p>Check the Address it should be 0x23 for single sensor and no need to connect with Ground</p>
<p>I tried to build a setup using BH1750 and an LCD display (this:<a href="http://farm9.staticflickr.com/8046/8115486011_a99d721319_b.jpg" rel="nofollow">http://farm9.staticflickr.com/8046/8115486011_a99d721319_b.jpg</a>). 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. </p>
<p>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 &amp; Light' (the heat is for soldering, the light, well, it should be obvious ;) )</p><p>http://www.hmgkry.net</p>
<p>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!</p>
<p>Hi,</p><p>I m going to use 2 lux module for my project and i copied the &quot;Read the Lux value via serial Port &quot; code as well as library to my arduino but there is errors as shown below it also show BH1750FVI does not name a type.</p><p>can u please help me to solve this problem </p><p>thanks in advance</p><p>+++++++++++++++++++++++++++++++++++++++++</p><p>sketch_jan22a:23: error: 'BH1750FVI' does not name a type<br>sketch_jan22a.ino: In function 'void setup()':<br>sketch_jan22a:28: error: 'LightSensor' was not declared in this scope<br>sketch_jan22a:36: error: 'Device_Address_H' was not declared in this scope<br>sketch_jan22a:53: error: 'Continuous_H_resolution_Mode' was not declared in this scope<br>sketch_jan22a.ino: In function 'void loop()':<br>sketch_jan22a:61: error: 'LightSensor' was not declared in this scope</p><p>+++++++++++++++++++++++++++++++++++++++++++++</p>
<p>OK , is 1 Module worked with you perfectly ?<br>You just need to connect/disconnect ADD Pin and set the address for each module lonely . </p>
<p>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.</p><p>/*</p><p> This is a simple code to test BH1750FVI Light senosr</p><p> communicate using I2C Protocol </p><p> this library enable 2 slave device address</p><p> Main address 0x23 </p><p> secondary address 0x5C </p><p> connect this sensor as following :</p><p> VCC &gt;&gt;&gt; 3.3V</p><p> SDA &gt;&gt;&gt; A4 </p><p> SCL &gt;&gt;&gt; A5</p><p> addr &gt;&gt; A3</p><p> Gnd &gt;&gt;&gt;Gnd</p><p> Written By : Mohannad Rawashdeh</p><p> */</p><p> // First define the library :</p><p>#include &lt;Wire.h&gt;</p><p>#include &lt;BH1750FVI.h&gt;</p><p>BH1750FVI LightSensor;</p><p>BH1750FVI lightMeter;</p><p>void setup() { // put your setup code here, to run once:</p><p> Serial.begin(9600);</p><p> LightSensor.begin();</p><p> lightMeter.begin();</p><p> /*</p><p> Set the address for this sensor </p><p> you can use 2 different address</p><p> Device_Address_H &quot;0x5C&quot;</p><p> Device_Address_L &quot;0x23&quot;</p><p> you must connect Addr pin to A3 .</p><p> */</p><p> LightSensor.SetAddress(Device_Address_H);//Address 0x5C</p><p> // To adjust the slave on other address , uncomment this line</p><p> lightMeter.SetAddress(Device_Address_L); //Address 0x5C</p><p> //-----------------------------------------------</p><p> /*</p><p> set the Working Mode for this sensor </p><p> Select the following Mode:</p><p> Continuous_H_resolution_Mode</p><p> Continuous_H_resolution_Mode2</p><p> Continuous_L_resolution_Mode</p><p> OneTime_H_resolution_Mode</p><p> OneTime_H_resolution_Mode2</p><p> OneTime_L_resolution_Mode</p><p> The data sheet recommanded To use Continuous_H_resolution_Mode</p><p> */</p><p> LightSensor.SetMode(Continuous_H_resolution_Mode);</p><p> lightMeter.SetMode(Continuous_H_resolution_Mode);</p><p> Serial.println(&quot;Running...&quot;);</p><p>}</p><p>void loop() {</p><p> // put your main code here, to run repeatedly: </p><p> uint16_t lux = LightSensor.GetLightIntensity();// Get Lux value</p><p> Serial.print(&quot;Light 1: &quot;);</p><p> Serial.print(lux);</p><p> Serial.println(&quot; lux&quot;);</p><p> delay(10);</p><p> lux = lightMeter.GetLightIntensity();// Get Lux value</p><p> Serial.print(&quot;Light 2: &quot;);</p><p> Serial.print(lux);</p><p> Serial.println(&quot; lux&quot;);</p><p> delay(1000);</p><p>}</p>
<p>Your code is working for me i removed A3 connection and connected to 3.3 v now both sensor are working </p><p>Connection: </p><p>VCC- 5v </p><p>GND- GND </p><p>SCL- A5 </p><p>SDA- A4 </p><p>ADD- NC for 0x23 address, and 3.3v for 0x5C address </p>
<p>You can try below code also</p><p>/* Connection:</p><p> VCC- 5v</p><p> GND- GND</p><p> SCL- A5</p><p> SDA- A4</p><p> ADD- NC for 0x23 address, and 3.3v for 0x5C address</p><p> */</p><p>#include &lt;Wire.h&gt; //Handle I2C mode for BH1750 sensor Pin 4 SDA, 5 SCL</p><p>#include &lt;math.h&gt; //Math library</p><p>//BH1750 I2C Address</p><p>int Sen1 = 0x23;</p><p>int Sen2 = 0x5C;</p><p>//Define the string for datastream ID</p><p>char sensor1[] = &quot;Sen1&quot;;</p><p>char sensor2[] = &quot;Sen2&quot;;</p><p>byte buff[2];</p><p>void setup(){</p><p> Wire.begin();</p><p> Serial.begin(9600); </p><p> delay(1000); </p><p> }</p><p>void loop(){</p><p> int i;</p><p> uint16_t val1=0, val2=0;</p><p> //send signal to sensor 1</p><p> BH1750_Init(Sen1);</p><p> delay(100);</p><p> //read sensor 1 value</p><p> if(2==BH1750_Read(Sen1)){</p><p> val1 = ((buff[0]&lt;&lt;8)|buff[1])/1.2;</p><p> Serial.print(&quot;Light 1 : &quot;);</p><p> Serial.println(val1,DEC);</p><p> }</p><p> delay(100);</p><p> //send signal to sensor 2</p><p> BH1750_Init(Sen2);</p><p> delay(100);</p><p> //read sensor 2 value</p><p> if(2==BH1750_Read(Sen2)){</p><p> val2 = ((buff[0]&lt;&lt;8)|buff[1])/1.2;</p><p> Serial.print(&quot;Light 2 : &quot;);</p><p> Serial.println(val2,DEC);</p><p> }</p><p> delay(100);</p><p> Serial.println();</p><p> delay(1000);</p><p>}</p><p>//custom parameter for request values from sensor </p><p>int BH1750_Read(int address){</p><p> int i = 0;</p><p> Wire.beginTransmission(address);</p><p> Wire.requestFrom(address,2);</p><p> while(Wire.available()){</p><p> buff[i] = Wire.read();</p><p> i++;</p><p> }</p><p> Wire.endTransmission();</p><p> return i;</p><p>}</p><p>//custom parameter for receive values from sensor</p><p>void BH1750_Init(int address){</p><p> Wire.beginTransmission(address);</p><p> Wire.write(0x10);</p><p> Wire.endTransmission();</p><p>}</p>
<p>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</p>
Thanks for the information !!! I purchased a couple of these boards &amp; would like to build a solar tracker. When do you think you will be publishing your system ?
I will try it soon :)
<p>hi.. I implemented your code..Its giving a constant output of 54612 LUX which is too high a value!!..Pls help</p>
Nice library and work. Can you provide explanation how to connect the LCD panel?
It's already found on step # 5 .
<p>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.</p>
<p>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.</p>
<p>Hi! I want to know if I can use the BH1750 with a PIC instead of Arduino.</p><p>Thanks!</p>
<p>Hi! I want to know if I can use the BH1750 with a PIC instead of Arduino.</p><p>Thanks!</p>
Nice job!

About This Instructable