diff --git a/README.md b/README.md
index c17ab2f..7ef448c 100644
--- a/README.md
+++ b/README.md
@@ -4,17 +4,17 @@ I started this project out of curiosity for how a motion sensor is working and s
## TODO
+* Add iSpindle 3D print cradle + small PCB (what I use for my builds)
+* Validate the power consumption of the device using amp meter (integrated and/or separate)
+* Testing, Testing and more testing......
+
+Lower priority
* Add support for Plato in device (today it assumes that formula is in SG).
* Add support for converting between SG/Plato in device.
* Add support for Blynk as endpoint
* Add support for https connections (push) - [need to reduce memory usage for this to work, gets out of memory error]
* Add support for https web server (will require certificates to be created as part of build process)
-* Add iSpindle 3D print cradle + small PCB (what I use for my builds)
-* [done] Validate max sleep time to 70 min (max time for ESP)
-* Validate the power consumption of the device using amp meter (integrated and/or separate)
-* [done] Add option to use temperature readings from motion sensor (longer battery life)
-* [done] When using temp from motion sensor the value should be the initial read or the value will not be accurate.
-* Testing, Testing and more testing......
+* Add support for WifiManager Secure access.
# Functionallity
diff --git a/bin/config.min.htm b/bin/config.min.htm
index 2ae55b0..b0c839c 100644
--- a/bin/config.min.htm
+++ b/bin/config.min.htm
@@ -1 +1 @@
-
Beer Gravity Monitor
...
(C) Copyright 2021 Magnus Persson
\ No newline at end of file
+Beer Gravity Monitor
...
(C) Copyright 2021 Magnus Persson
\ No newline at end of file
diff --git a/bin/firmware-debug.bin b/bin/firmware-debug.bin
index f9909b9..d5816cd 100644
Binary files a/bin/firmware-debug.bin and b/bin/firmware-debug.bin differ
diff --git a/bin/firmware.bin b/bin/firmware.bin
index 1004918..f7e839c 100644
Binary files a/bin/firmware.bin and b/bin/firmware.bin differ
diff --git a/src/main.cpp b/src/main.cpp
index c2ab1de..3fd7b77 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -128,7 +128,7 @@ void setup() {
Log.notice(F("Main: Detected doubletap on reset." CR));
LOG_PERF_START("main-wifi-connect");
- myWifi.connect( dt );
+ myWifi.connect( dt ); // This will return false if unable to connect to wifi, will be handled in loop()
LOG_PERF_STOP("main-wifi-connect");
LOG_PERF_START("main-gyro-read");
@@ -169,7 +169,7 @@ void loop() {
if( sleepModeActive || abs(millis() - loopMillis) > interval ) {
float angle = 0;
float volt = myBatteryVoltage.getVoltage();
- float sensorTemp = 0;
+ //float sensorTemp = 0;
loopCounter++;
#if LOG_LEVEL==6
Log.verbose(F("Main: Entering main loop." CR) );
@@ -224,6 +224,15 @@ void loop() {
#endif
int sleepInterval = myConfig.getSleepInterval();
+ // If we didnt get a wifi connection, we enter sleep for a short time to conserve battery.
+ // ------------------------------------------------------------------------------------------------
+ //
+ if( !myWifi.isConnected() ) { // no connection to wifi
+ Log.notice(F("MAIN: No connection to wifi established, sleeping for 60s." CR) );
+ sleepInterval = 60; // 60s
+ goToSleep = true;
+ }
+
// If the sensor is moving and we are not getting a clear reading, we enter sleep for a short time to conserve battery.
// ------------------------------------------------------------------------------------------------
//
diff --git a/src/wifi.cpp b/src/wifi.cpp
index 4abe380..30ed0f2 100644
--- a/src/wifi.cpp
+++ b/src/wifi.cpp
@@ -93,9 +93,8 @@ bool Wifi::connect( bool showPortal ) {
delay(100);
Serial.print( "." );
- if( i++ > 100 ) {
- LittleFS.end();
- ESP.reset();
+ if( i++ > 60 ) { // Try for 6 seconds.
+ return connectedFlag; // Return to main that we have failed to connect.
}
}
Serial.print( CR );