Disabling voltage check for wifi

This commit is contained in:
Gunnar Skjold
2023-10-14 08:20:11 +02:00
parent f9b4680b9c
commit 2a44f89a7b

View File

@@ -577,11 +577,12 @@ void loop() {
debugW_P(PSTR("Used %dms to handle mqtt"), millis()-start); debugW_P(PSTR("Used %dms to handle mqtt"), millis()-start);
} }
} }
/*
if(now - lastVoltageCheck > 500) { if(now - lastVoltageCheck > 500) {
handleVoltageCheck(); handleVoltageCheck();
lastVoltageCheck = now; lastVoltageCheck = now;
} }
*/
} else { } else {
if(dnsServer != NULL) { if(dnsServer != NULL) {
dnsServer->processNextRequest(); dnsServer->processNextRequest();
@@ -852,8 +853,8 @@ bool handleVoltageCheck() {
debugD_P(PSTR("Setting new max Vcc to %.2f"), vcc); debugD_P(PSTR("Setting new max Vcc to %.2f"), vcc);
maxVcc = vcc; maxVcc = vcc;
} else if(WiFi.getMode() != WIFI_OFF) { } else if(WiFi.getMode() != WIFI_OFF) {
float diff = maxVcc-vcc; float diff = min(maxVcc, (float) 3.3)-vcc;
if(diff > 0.3) { if(diff > 0.4) {
debugW_P(PSTR("Vcc dropped to %.2f, disconnecting WiFi for 5 seconds to preserve power"), vcc); debugW_P(PSTR("Vcc dropped to %.2f, disconnecting WiFi for 5 seconds to preserve power"), vcc);
WiFi_disconnect(2000); WiFi_disconnect(2000);
return false; return false;
@@ -1457,10 +1458,12 @@ void WiFi_connect() {
} }
lastWifiRetry = millis(); lastWifiRetry = millis();
/*
if(!handleVoltageCheck()) { if(!handleVoltageCheck()) {
debugW_P(PSTR("Voltage is not high enough to reconnect")); debugW_P(PSTR("Voltage is not high enough to reconnect"));
return; return;
} }
*/
if (WiFi.status() != WL_CONNECTED) { if (WiFi.status() != WL_CONNECTED) {
WiFiConfig wifi; WiFiConfig wifi;