Signaling Type I2C
This sketch requires BH1750.h library.
You can download the library here
https://docs.google.com/file/d/0B4qM0hq-OmC1RHhEcXRNSmZ1YW8/
/*
Example of BH1750 library usage.
This example initalises the BH1750 object using the default
high resolution mode and then makes a light level reading every second.
Connection:
VCC-5v
GND-GND
SCL-SCL(analog pin 5)
SDA-SDA(analog pin 4)
ADD-NC or GND
*/
#include <Wire.h>
#include <BH1750.h>
BH1750 lightMeter;
void setup(){
Serial.begin(9600);
lightMeter.begin();
Serial.println(“Running…”);
}
void loop() {
uint16_t lux = lightMeter.readLightLevel();
Serial.print(“Light: “);
Serial.print(lux);
Serial.println(” lx”);
delay(1000);
}

and if you use more than one?
Hallo, I tried tou use code for BH1750, but compilling the scetch program doesn”t pass me throuhg line: Serial.println(“Running…”); with comment Stray “\”. Can sombeodz help me, Iam begiiner in programming Thanks Chay.
replace the ” ” in both sentences (setup print and loop print) and you are good to go 😉
Hi cmosgr
I am trying your code on an arduino mega using a BH1750 module GY-302 just like yours. I am using all your code and all the libraries you link to. No matter what connections I try I always get a continual reading of 54612 lx (pinned out I guess). This is for any light conditions.
Do you have any ideas that could help me troubleshoot?
Thanks
Yes 54612lx means that there’s a connection or hardware problem.
Check again connections SCL,SDA pins 🙂
Thanks for your prompt assistance. I have now tried it with two modules, bought a new one, on two breadboards, checking everything ten times but still no good. Tried it with the address pin grounded or floating. My soldering looks decent and I don’t think I cooked anything so it is all a mystery to me. If you have any other thoughts please let me know. Was going to make a colorimeter. Thanks again for trying to help.
Finally and boy do I feel stupid. My Mega rev 3 board has dedicated sda and scl pins (20 and 21) connect to those and all is well. You were so right, check the pins, I just did not realise that meant check the pins available on the board. Thanks.