diff --git a/esp32_MachineNotify.ino b/esp32_MachineNotify.ino index 51cf678..56ffdad 100644 --- a/esp32_MachineNotify.ino +++ b/esp32_MachineNotify.ino @@ -160,23 +160,11 @@ void setup() { Wire.begin(); #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 // Initialize OLED display if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) { Serial.println(F("SSD1306 allocation failed")); - for (;;); + while (1) { delay(1000); } } display.clearDisplay(); display.setTextSize(1); @@ -186,6 +174,30 @@ void setup() { display.display(); 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 display.clearDisplay(); display.setCursor(0, 0);