#include <Wire.h>
BH1750 lightMeter(0x5C);
void setup() {
// put your setup code here, to run once:
Wire.begin();
Serial.begin(115200);
lightMeter.begin(BH1750::CONTINUOUS_HIGH_RES_MODE);
delay(2000);
}
void loop() {
// put your main code here, to run repeatedly:
uint16_t lux = lightMeter.readLightLevel();
Serial.print("Light level: ");
Serial.println(lux);
delay(5000);
}
my code:
The cabling:
D21 -> SDA
D22 -> SCL
GND & ADDR -> gnd
VCC -> 3.3V