better error handling
This commit is contained in:
parent
fa6c2a753a
commit
4f823f8aa3
@ -160,23 +160,11 @@ void setup() {
|
|||||||
Wire.begin();
|
Wire.begin();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_SENSORS
|
|
||||||
// Initialize light sensors
|
|
||||||
if (!lightMeter1.begin(BH1750::CONTINUOUS_HIGH_RES_MODE, 0x23)) {
|
|
||||||
Serial.println(F("Could not find valid BH1750 sensor at 0x23, check wiring!"));
|
|
||||||
while (1) { }
|
|
||||||
}
|
|
||||||
if (!lightMeter2.begin(BH1750::CONTINUOUS_HIGH_RES_MODE, 0x5C)) {
|
|
||||||
Serial.println(F("Could not find valid BH1750 sensor at 0x5C, check wiring!"));
|
|
||||||
while (1) { }
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ENABLE_DISPLAY
|
#ifdef ENABLE_DISPLAY
|
||||||
// Initialize OLED display
|
// Initialize OLED display
|
||||||
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
|
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
|
||||||
Serial.println(F("SSD1306 allocation failed"));
|
Serial.println(F("SSD1306 allocation failed"));
|
||||||
for (;;);
|
while (1) { delay(1000); }
|
||||||
}
|
}
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
@ -186,6 +174,30 @@ void setup() {
|
|||||||
display.display();
|
display.display();
|
||||||
delay(500);
|
delay(500);
|
||||||
|
|
||||||
|
#ifdef ENABLE_SENSORS
|
||||||
|
// Initialize light sensors
|
||||||
|
if (!lightMeter1.begin(BH1750::CONTINUOUS_HIGH_RES_MODE, 0x23)) {
|
||||||
|
Serial.println(F("Could not find valid BH1750 sensor at 0x23, check wiring!"));
|
||||||
|
display.clearDisplay();
|
||||||
|
display.setCursor(0, 0);
|
||||||
|
display.println(F("Err: Sensor 0x23"));
|
||||||
|
display.println(" " + String(DEVICE1_NAME));
|
||||||
|
display.println(F(" not found"));
|
||||||
|
display.display();
|
||||||
|
while (1) { delay(1000); }
|
||||||
|
}
|
||||||
|
if (!lightMeter2.begin(BH1750::CONTINUOUS_HIGH_RES_MODE, 0x5C)) {
|
||||||
|
Serial.println(F("Could not find valid BH1750 sensor at 0x5C, check wiring!"));
|
||||||
|
display.clearDisplay();
|
||||||
|
display.setCursor(0, 0);
|
||||||
|
display.println(F("Err: Sensor 0x5C"));
|
||||||
|
display.println(" " + String(DEVICE2_NAME));
|
||||||
|
display.println(F(" not found"));
|
||||||
|
display.display();
|
||||||
|
while (1) { delay(1000); }
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_WIFI
|
#ifdef ENABLE_WIFI
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
display.setCursor(0, 0);
|
display.setCursor(0, 0);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user