From ab58242899b8ecdbc3a284946f008c8bb98b7e0a Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Wed, 7 Mar 2018 00:53:53 +0100 Subject: [PATCH] add wifi error handling --- src/main.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 84febfe..9ffe7d4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -71,8 +71,16 @@ void ICACHE_FLASH_ATTR sendValues() { WiFi.forceSleepWake(); WiFi.begin(ssid, password); Serial.print("Connecting to wifi"); + int tries = 0; while (WiFi.status() != WL_CONNECTED) { + tries++; Serial.print("."); + if (tries > 20) { + Serial.println(" [ERROR]"); + Serial.println("Retrying in 1 minute.."); + delay(postingInterval); + ESP.restart(); + } delay(500); } Serial.println(" [CONNECTED]"); @@ -199,7 +207,7 @@ void setup() { sds.mode_mon_300(); Wire.begin(BMP_SDA, BMP_SCL); - if (!bmp.begin()) { + if (!bmp.begin(BMP085_MODE_STANDARD)) { Serial.println("No valid BMP085 sensor!"); }