Browse Source

add wifi error handling

lightsleep
Hendrik Langer 7 years ago
parent
commit
ab58242899
  1. 10
      src/main.cpp

10
src/main.cpp

@ -71,8 +71,16 @@ void ICACHE_FLASH_ATTR sendValues() {
WiFi.forceSleepWake(); WiFi.forceSleepWake();
WiFi.begin(ssid, password); WiFi.begin(ssid, password);
Serial.print("Connecting to wifi"); Serial.print("Connecting to wifi");
int tries = 0;
while (WiFi.status() != WL_CONNECTED) { while (WiFi.status() != WL_CONNECTED) {
tries++;
Serial.print("."); Serial.print(".");
if (tries > 20) {
Serial.println(" [ERROR]");
Serial.println("Retrying in 1 minute..");
delay(postingInterval);
ESP.restart();
}
delay(500); delay(500);
} }
Serial.println(" [CONNECTED]"); Serial.println(" [CONNECTED]");
@ -199,7 +207,7 @@ void setup() {
sds.mode_mon_300(); sds.mode_mon_300();
Wire.begin(BMP_SDA, BMP_SCL); Wire.begin(BMP_SDA, BMP_SCL);
if (!bmp.begin()) { if (!bmp.begin(BMP085_MODE_STANDARD)) {
Serial.println("No valid BMP085 sensor!"); Serial.println("No valid BMP085 sensor!");
} }

Loading…
Cancel
Save