diff --git a/data/igate_conf.json b/data/igate_conf.json
index c3d9017..4260b1b 100644
--- a/data/igate_conf.json
+++ b/data/igate_conf.json
@@ -66,6 +66,7 @@
"sendBatteryVoltage": false,
"externalVoltageMeasurement": false,
"externalVoltagePin": 34,
- "lowPowerMode": false
+ "lowPowerMode": false,
+ "lowVoltageCutOff": 0
}
}
\ No newline at end of file
diff --git a/data_embed/index.html b/data_embed/index.html
index 7af611d..59a8ec9 100644
--- a/data_embed/index.html
+++ b/data_embed/index.html
@@ -1280,6 +1280,25 @@
>
+
+
+
+
+ MCU will deep sleep when below provided battery voltage to save power. Set to 0 if you don't want this option. Please calibrate your voltage reading first!
+
+
diff --git a/data_embed/script.js b/data_embed/script.js
index 0916b13..9251635 100644
--- a/data_embed/script.js
+++ b/data_embed/script.js
@@ -215,6 +215,7 @@ function loadSettings(settings) {
// Experimental
document.getElementById("other.lowPowerMode").checked = settings.other.lowPowerMode;
+ document.getElementById("other.lowVoltageCutOff").value = settings.other.lowVoltageCutOff || 0
updateImage();
refreshSpeedStandard();
diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp
index 65fecf3..17d8332 100644
--- a/src/LoRa_APRS_iGate.cpp
+++ b/src/LoRa_APRS_iGate.cpp
@@ -154,7 +154,9 @@ void loop() {
return; // Don't process IGate and Digi during OTA update
}
- BATTERY_Utils::checkIfShouldSleep();
+ if (Config.lowVoltageCutOff > 0) {
+ BATTERY_Utils::checkIfShouldSleep();
+ }
thirdLine = Utils::getLocalIP();
diff --git a/src/battery_utils.cpp b/src/battery_utils.cpp
index a11bb0b..428b6da 100644
--- a/src/battery_utils.cpp
+++ b/src/battery_utils.cpp
@@ -1,12 +1,6 @@
#include "battery_utils.h"
#include "configuration.h"
#include "pins_config.h"
-//#include "lora_utils.h"
-
-// Uncomment if you want to monitor voltage and sleep if voltage is too low (<3.15V)
-//#define LOW_VOLTAGE_CUTOFF
-
-float cutOffVoltage = 3.15;
extern Configuration Config;
extern uint32_t lastBatteryCheck;
@@ -65,24 +59,15 @@ namespace BATTERY_Utils {
}
void checkIfShouldSleep() {
- #ifdef LOW_VOLTAGE_CUTOFF
if (lastBatteryCheck == 0 || millis() - lastBatteryCheck >= 15 * 60 * 1000) {
lastBatteryCheck = millis();
float voltage = checkBattery();
- if (voltage < cutOffVoltage) {
- /* Send message over APRS-IS or over LoRa???
-
- APRS_IS_Utils::upload("battery is low = sleeping")
-
- LoRa_Utils::sendNewMessage("battery is low = sleeping");
-
- */
+ if (voltage < Config.lowVoltageCutOff) {
ESP.deepSleep(1800000000); // 30 min sleep (60s = 60e6)
}
}
- #endif
}
}
\ No newline at end of file
diff --git a/src/configuration.cpp b/src/configuration.cpp
index 2295997..e765787 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -97,6 +97,7 @@ void Configuration::writeFile() {
data["ota"]["password"] = ota.password;
data["other"]["lowPowerMode"] = lowPowerMode;
+ data["other"]["lowVoltageCutOff"] = lowVoltageCutOff;
serializeJson(data, configFile);
@@ -163,6 +164,7 @@ bool Configuration::readFile() {
tnc.acceptOwn = data["tnc"]["acceptOwn"].as();
lowPowerMode = data["other"]["lowPowerMode"].as();
+ lowVoltageCutOff = data["other"]["lowVoltageCutOff"].as();
int stationMode = data["stationMode"].as(); // deprecated but need to specify config version
@@ -336,6 +338,7 @@ void Configuration::init() {
externalVoltagePin = 34;
lowPowerMode = false;
+ lowVoltageCutOff = 0;
Serial.println("todo escrito");
}
diff --git a/src/configuration.h b/src/configuration.h
index d6c2acd..bef4ca9 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -115,6 +115,7 @@ public:
bool externalVoltageMeasurement;
int externalVoltagePin;
bool lowPowerMode;
+ double lowVoltageCutOff;
std::vector wifiAPs;
WiFi_Auto_AP wifiAutoAP;
Beacon beacon; // new
diff --git a/src/web_utils.cpp b/src/web_utils.cpp
index c93e89c..8a719e8 100644
--- a/src/web_utils.cpp
+++ b/src/web_utils.cpp
@@ -156,6 +156,7 @@ namespace WEB_Utils {
}
Config.lowPowerMode = request->hasParam("other.lowPowerMode", true);
+ Config.lowVoltageCutOff = request->getParam("other.lowVoltageCutOff", true)->value().toDouble();
Config.writeFile();