Created
March 17, 2016 22:05
-
-
Save ViliusKraujutis/898d94e952103533cc7f to your computer and use it in GitHub Desktop.
I was always getting ‘54612 lux’ measurments. It was mystery, until I found out, that I had to connect my SCL and SDA pins to dedicated 20th and 21st pins on Arduino MEGA 2560.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment