New handling of long wifi connection
This commit is contained in:
parent
1269bf6f0e
commit
459bb3fae0
12
README.md
12
README.md
@ -4,17 +4,17 @@ I started this project out of curiosity for how a motion sensor is working and s
|
|||||||
|
|
||||||
## TODO
|
## 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 Plato in device (today it assumes that formula is in SG).
|
||||||
* Add support for converting between SG/Plato in device.
|
* Add support for converting between SG/Plato in device.
|
||||||
* Add support for Blynk as endpoint
|
* 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 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 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)
|
* Add support for WifiManager Secure access.
|
||||||
* [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......
|
|
||||||
|
|
||||||
# Functionallity
|
# Functionallity
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
Binary file not shown.
BIN
bin/firmware.bin
BIN
bin/firmware.bin
Binary file not shown.
13
src/main.cpp
13
src/main.cpp
@ -128,7 +128,7 @@ void setup() {
|
|||||||
Log.notice(F("Main: Detected doubletap on reset." CR));
|
Log.notice(F("Main: Detected doubletap on reset." CR));
|
||||||
|
|
||||||
LOG_PERF_START("main-wifi-connect");
|
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_STOP("main-wifi-connect");
|
||||||
|
|
||||||
LOG_PERF_START("main-gyro-read");
|
LOG_PERF_START("main-gyro-read");
|
||||||
@ -169,7 +169,7 @@ void loop() {
|
|||||||
if( sleepModeActive || abs(millis() - loopMillis) > interval ) {
|
if( sleepModeActive || abs(millis() - loopMillis) > interval ) {
|
||||||
float angle = 0;
|
float angle = 0;
|
||||||
float volt = myBatteryVoltage.getVoltage();
|
float volt = myBatteryVoltage.getVoltage();
|
||||||
float sensorTemp = 0;
|
//float sensorTemp = 0;
|
||||||
loopCounter++;
|
loopCounter++;
|
||||||
#if LOG_LEVEL==6
|
#if LOG_LEVEL==6
|
||||||
Log.verbose(F("Main: Entering main loop." CR) );
|
Log.verbose(F("Main: Entering main loop." CR) );
|
||||||
@ -224,6 +224,15 @@ void loop() {
|
|||||||
#endif
|
#endif
|
||||||
int sleepInterval = myConfig.getSleepInterval();
|
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.
|
// If the sensor is moving and we are not getting a clear reading, we enter sleep for a short time to conserve battery.
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
@ -93,9 +93,8 @@ bool Wifi::connect( bool showPortal ) {
|
|||||||
delay(100);
|
delay(100);
|
||||||
Serial.print( "." );
|
Serial.print( "." );
|
||||||
|
|
||||||
if( i++ > 100 ) {
|
if( i++ > 60 ) { // Try for 6 seconds.
|
||||||
LittleFS.end();
|
return connectedFlag; // Return to main that we have failed to connect.
|
||||||
ESP.reset();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Serial.print( CR );
|
Serial.print( CR );
|
||||||
|
Loading…
Reference in New Issue
Block a user