-
Notifications
You must be signed in to change notification settings - Fork 108
Open
Description
See this thread on Arduino forum:
https://forum.arduino.cc/t/connect-arduino-to-bh1750/1370271
In short, with one sensor having ADDR->Vcc and the other having ADDR->GND, and using this code:
#include <Wire.h>
#include <BH1750.h>
BH1750 lightSensor1(0x23); // ADDR nối GND
BH1750 lightSensor2(0x5C); // ADDR nối VCC
void setup() {
Serial.begin(9600);
Wire.begin();
lightSensor1.begin(BH1750::CONTINUOUS_HIGH_RES_MODE_2);
lightSensor2.begin(BH1750::CONTINUOUS_HIGH_RES_MODE_2);
Serial.println(F("\n---------------- LOADING ----------------"));
Serial.println(F("| Sensor 1 (0x23) | Sensor 2 (0x5C) |"));
}
void loop() {
float lux1 = lightSensor1.readLightLevel();
float lux2 = lightSensor2.readLightLevel();
Serial.print("| ");
Serial.print(" lx");
if (lux1 < 10) Serial.print(" ");
else if (lux1 < 100) Serial.print(" ");
else Serial.print(" ");
Serial.print("| ");
Serial.print(lux2, 2);
Serial.println(" lx |");
delay(500);
}
Whichever sensor has ADDR->GND is ignored and both sensors read same value which is coming from the sensor with ADDR->Vcc.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels