mirror of
https://github.com/richonguzman/LoRa_APRS_iGate.git
synced 2026-08-09 10:22:51 +02:00
comienzo dormir ext
This commit is contained in:
@@ -47,10 +47,12 @@ WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex];
|
||||
|
||||
bool isUpdatingOTA = false;
|
||||
uint32_t lastBatteryCheck = 0;
|
||||
String batteryVoltage;
|
||||
String batteryVoltage; // ????
|
||||
bool backUpDigiMode = false;
|
||||
bool modemLoggedToAPRSIS = false;
|
||||
|
||||
bool shouldSleep = false;
|
||||
|
||||
std::vector<ReceivedPacket> receivedPackets;
|
||||
|
||||
String firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine;
|
||||
@@ -94,7 +96,7 @@ void setup() {
|
||||
if (lastBeacon == 0 || time - lastBeacon >= Config.beacon.interval * 60) {
|
||||
Serial.println("Sending beacon");
|
||||
String comment = Config.beacon.comment;
|
||||
if (Config.battery.sendBatteryVoltage) comment += " Batt=" + String(BATTERY_Utils::checkBattery(),2) + "V";
|
||||
if (Config.battery.sendBatteryVoltage) comment += " Batt=" + String(BATTERY_Utils::checkInternalVoltage(),2) + "V";
|
||||
if (Config.battery.externalVoltageMeasurement) comment += " Ext=" + String(BATTERY_Utils::checkExternalVoltage(),2) + "V";
|
||||
STATION_Utils::addToOutputPacketBuffer(GPS_Utils::getiGateLoRaBeaconPacket() + comment);
|
||||
lastBeacon = time;
|
||||
@@ -183,4 +185,5 @@ void loop() {
|
||||
|
||||
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
|
||||
Utils::checkRebootTime();
|
||||
Utils::checkSleepByLowBatteryVoltage();
|
||||
}
|
||||
@@ -21,7 +21,7 @@ namespace BATTERY_Utils {
|
||||
return (voltage - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
||||
}
|
||||
|
||||
float checkBattery() {
|
||||
float checkInternalVoltage() {
|
||||
int sample;
|
||||
int sampleSum = 0;
|
||||
#ifdef ADC_CTRL
|
||||
@@ -70,7 +70,7 @@ namespace BATTERY_Utils {
|
||||
}
|
||||
|
||||
float voltage = ((((sampleSum/100)* adcReadingTransformation) + readingCorrection) * ((R1+R2)/R2)) - multiplyCorrection;
|
||||
|
||||
|
||||
return voltage; // raw voltage without mapping
|
||||
|
||||
// return mapVoltage(voltage, 5.05, 6.32, 4.5, 5.5); // mapped voltage
|
||||
@@ -80,7 +80,7 @@ namespace BATTERY_Utils {
|
||||
if (lastBatteryCheck == 0 || millis() - lastBatteryCheck >= 15 * 60 * 1000) {
|
||||
lastBatteryCheck = millis();
|
||||
|
||||
float voltage = checkBattery();
|
||||
float voltage = checkInternalVoltage();
|
||||
|
||||
if (voltage < Config.lowVoltageCutOff) {
|
||||
ESP.deepSleep(1800000000); // 30 min sleep (60s = 60e6)
|
||||
|
||||
+3
-3
@@ -6,9 +6,9 @@
|
||||
|
||||
namespace BATTERY_Utils {
|
||||
|
||||
float checkBattery();
|
||||
float checkExternalVoltage();
|
||||
void checkIfShouldSleep();
|
||||
float checkInternalVoltage();
|
||||
float checkExternalVoltage();
|
||||
void checkIfShouldSleep();
|
||||
|
||||
}
|
||||
|
||||
|
||||
+27
-9
@@ -32,6 +32,7 @@ extern String distance;
|
||||
extern bool WiFiConnected;
|
||||
extern int wxModuleType;
|
||||
extern bool backUpDigiMode;
|
||||
extern bool shouldSleep;
|
||||
|
||||
bool statusAfterBoot = true;
|
||||
bool beaconUpdate = true;
|
||||
@@ -123,18 +124,27 @@ namespace Utils {
|
||||
|
||||
#ifdef BATTERY_PIN
|
||||
if (Config.battery.sendInternalVoltage) {
|
||||
String batteryInfo = "Batt=" + String(BATTERY_Utils::checkBattery(),2) + "V";
|
||||
beaconPacket += " " + batteryInfo;
|
||||
secondaryBeaconPacket += " " + batteryInfo;
|
||||
sixthLine = " ( " + batteryInfo + ")";
|
||||
float internalVoltage = BATTERY_Utils::checkInternalVoltage();
|
||||
String internalVoltageInfo = "Batt=" + String(internalVoltage,2) + "V";
|
||||
beaconPacket += " " + internalVoltageInfo;
|
||||
secondaryBeaconPacket += " " + internalVoltageInfo;
|
||||
sixthLine = " ( " + internalVoltageInfo + ")";
|
||||
}
|
||||
#endif
|
||||
|
||||
if (Config.battery.sendExternalVoltage) {
|
||||
String externalVoltage = String(BATTERY_Utils::checkExternalVoltage(),2) + "V";
|
||||
beaconPacket += " Ext=" + externalVoltage;
|
||||
secondaryBeaconPacket += " Ext=" + externalVoltage;
|
||||
sixthLine = " (Ext V=" + externalVoltage;
|
||||
if (Config.battery.sendExternalVoltage || Config.battery.monitorExternalVoltage) {
|
||||
float externalVoltage = BATTERY_Utils::checkExternalVoltage();
|
||||
String externalVoltageInfo = String(externalVoltage,2) + "V";
|
||||
if (Config.battery.sendExternalVoltage) {
|
||||
beaconPacket += " Ext=" + externalVoltageInfo;
|
||||
secondaryBeaconPacket += " Ext=" + externalVoltageInfo;
|
||||
sixthLine = " (Ext V=" + externalVoltageInfo + ")";
|
||||
}
|
||||
if (Config.battery.monitorExternalVoltage && externalVoltage <= Config.battery.externalSleepVoltage) {
|
||||
beaconPacket += " **ExtBatWarning:SLEEP**";
|
||||
secondaryBeaconPacket += " **ExtBatWarning:SLEEP**";
|
||||
shouldSleep = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.aprs_is.active && Config.beacon.sendViaAPRSIS && !backUpDigiMode) {
|
||||
@@ -262,4 +272,12 @@ namespace Utils {
|
||||
}
|
||||
}
|
||||
|
||||
void checkSleepByLowBatteryVoltage() {
|
||||
if (shouldSleep) {
|
||||
// dormir
|
||||
shouldSleep = false;
|
||||
Serial.println("Durmiendo");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,6 +25,7 @@ namespace Utils {
|
||||
void println(const String& text);
|
||||
void checkRebootMode();
|
||||
void checkRebootTime();
|
||||
void checkSleepByLowBatteryVoltage();
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user