mirror of
https://github.com/richonguzman/LoRa_APRS_iGate.git
synced 2026-03-15 17:54:45 +01:00
adding meassureExternalBattery
This commit is contained in:
parent
86ab157952
commit
5462521418
|
|
@ -56,6 +56,8 @@
|
|||
"other": {
|
||||
"beaconInterval": 15,
|
||||
"rememberStationTime": 30,
|
||||
"sendBatteryVoltage": false
|
||||
"sendBatteryVoltage": false,
|
||||
"externalVoltageMeasurement" : true,
|
||||
"externalVoltagePin": 13
|
||||
}
|
||||
}
|
||||
|
|
@ -37,6 +37,8 @@ void Configuration::readFile(fs::FS &fs, const char *fileName) {
|
|||
beaconInterval = data["other"]["beaconInterval"].as<int>();
|
||||
rememberStationTime = data["other"]["rememberStationTime"].as<int>();
|
||||
sendBatteryVoltage = data["other"]["sendBatteryVoltage"].as<bool>();
|
||||
externalVoltageMeasurement = data["other"]["externalVoltageMeasurement"].as<bool>();
|
||||
externalVoltagePin = data["other"]["externalVoltagePin"].as<int>();
|
||||
|
||||
digi.comment = data["digi"]["comment"].as<String>();
|
||||
digi.latitude = data["digi"]["latitude"].as<double>();
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ public:
|
|||
int beaconInterval;
|
||||
int rememberStationTime;
|
||||
bool sendBatteryVoltage;
|
||||
bool externalVoltageMeasurement;
|
||||
int externalVoltagePin;
|
||||
std::vector<WiFi_AP> wifiAPs;
|
||||
DIGI digi;
|
||||
APRS_IS aprs_is;
|
||||
|
|
|
|||
|
|
@ -53,6 +53,21 @@ void notFound(AsyncWebServerRequest *request) {
|
|||
request->send(404, "text/plain", "Not found");
|
||||
}
|
||||
|
||||
String meassureExternalBattery() {
|
||||
int16_t sample;
|
||||
int sampleNum = 50;
|
||||
float readingCorrection = 0.0018;
|
||||
float batteryVoltage, sampleSum;
|
||||
sampleSum = 0;
|
||||
for (int i=0; i<sampleNum; i++) {
|
||||
sample = analogRead(Config.externalVoltagePin);
|
||||
sampleSum += sample;
|
||||
delayMicroseconds(50);
|
||||
}
|
||||
batteryVoltage = ((sampleSum/sampleNum) - readingCorrection);
|
||||
return "VBat=" + String(batteryVoltage,2) + ")";
|
||||
}
|
||||
|
||||
void processStatus() {
|
||||
String status = Config.callsign + ">APLRG1";
|
||||
if (stationMode==1 || stationMode==2 || (stationMode==5 && WiFi.status() == WL_CONNECTED)) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
namespace Utils {
|
||||
|
||||
String meassureExternalBattery();
|
||||
void processStatus();
|
||||
String getLocalIP();
|
||||
void setupDisplay();
|
||||
|
|
|
|||
Loading…
Reference in a new issue