This commit is contained in:
richonguzman 2023-07-06 01:01:10 -04:00
parent d40057ebbd
commit 8e85da253c
7 changed files with 29 additions and 18 deletions

View File

@ -48,7 +48,8 @@
},
"other": {
"beaconInterval": 15,
"rememberStationTime": 30
"rememberStationTime": 30,
"sendBatteryVoltage": false
},
"bme": {
"active": false

View File

@ -20,14 +20,14 @@ Configuration Config;
WiFiClient espClient;
String versionDate = "2023.07.05";
String versionDate = "2023.07.06";
int myWiFiAPIndex = 0;
int myWiFiAPSize = Config.wifiAPs.size();
WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex];
int stationMode = Config.stationMode;
bool statusAfterBoot = true;
bool beacon_update = true;
bool beaconUpdate = true;
uint32_t lastBeaconTx = 0;
uint32_t previousWiFiMillis = 0;
uint32_t lastScreenOn = millis();

View File

@ -1,13 +1,12 @@
#include "battery_utils.h"
#include "pins_config.h"
extern String batteryVoltage;
float adcReadingTransformation = (4095/3.3);
float adcReadingTransformation = (3.3/4095);
float voltageDividerCorrection = 0.288;
namespace BATTERY_Utils {
String checkVoltages() {
float checkVoltages() {
float sample;
int sampleSum = 0;
for (int i=0; i<100; i++) {
@ -15,8 +14,7 @@ String checkVoltages() {
sampleSum += sample;
delayMicroseconds(50);
}
batteryVoltage = 2.1571 *(sampleSum/100) * adcReadingTransformation;
return String(batteryVoltage);
return (2 * (sampleSum/100) * adcReadingTransformation) + voltageDividerCorrection;
}
}

View File

@ -5,7 +5,7 @@
namespace BATTERY_Utils {
String checkVoltages();
float checkVoltages();
}

View File

@ -36,6 +36,7 @@ void Configuration::readFile(fs::FS &fs, const char *fileName) {
iGateComment = data["iGateComment"].as<String>();
beaconInterval = data["other"]["beaconInterval"].as<int>();
rememberStationTime = data["other"]["rememberStationTime"].as<int>();
sendBatteryVoltage = data["other"]["sendBatteryVoltage"].as<bool>();
digi.comment = data["digi"]["comment"].as<String>();
digi.latitude = data["digi"]["latitude"].as<double>();

View File

@ -66,6 +66,7 @@ public:
String iGateComment;
int beaconInterval;
int rememberStationTime;
bool sendBatteryVoltage;
std::vector<WiFi_AP> wifiAPs;
DIGI digi;
APRS_IS aprs_is;

View File

@ -5,6 +5,7 @@
#include <WiFi.h>
#include "configuration.h"
#include "station_utils.h"
#include "battery_utils.h"
#include "syslog_utils.h"
#include "pins_config.h"
#include "wifi_utils.h"
@ -30,7 +31,7 @@ extern String sixthLine;
extern String seventhLine;
extern uint32_t lastBeaconTx;
extern uint32_t lastScreenOn;
extern bool beacon_update;
extern bool beaconUpdate;
extern int stationMode;
extern String iGateBeaconPacket;
extern std::vector<String> lastHeardStation;
@ -89,10 +90,11 @@ void activeStations() {
void checkBeaconInterval() {
uint32_t lastTx = millis() - lastBeaconTx;
String beaconPacket;
if (lastTx >= Config.beaconInterval*60*1000) {
beacon_update = true;
beaconUpdate = true;
}
if (beacon_update) {
if (beaconUpdate) {
display_toggle(true);
Serial.println("---- Sending iGate Beacon ----");
STATION_Utils::deleteNotHeard();
@ -106,10 +108,14 @@ void checkBeaconInterval() {
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, "SENDING iGate BEACON", 1000);
seventhLine = " listening...";
if (Config.bme.active) {
espClient.write((iGateBeaconPacket.substring(0,iGateBeaconPacket.indexOf(":=")+20) + "_" + BME_Utils::readDataSensor() + iGateBeaconPacket.substring(iGateBeaconPacket.indexOf(":=")+21) + " + WX" + "\n").c_str());
beaconPacket = iGateBeaconPacket.substring(0,iGateBeaconPacket.indexOf(":=")+20) + "_" + BME_Utils::readDataSensor() + iGateBeaconPacket.substring(iGateBeaconPacket.indexOf(":=")+21) + " + WX";
} else {
espClient.write((iGateBeaconPacket + "\n").c_str());
beaconPacket = iGateBeaconPacket;
}
if (Config.sendBatteryVoltage) {
beaconPacket += " (Batt=" + String(BATTERY_Utils::checkVoltages(),2) + "V)";
}
espClient.write((beaconPacket + "\n").c_str());
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
} else if (stationMode==3 || stationMode==4) {
String Rx = String(Config.loramodule.digirepeaterRxFreq);
@ -128,17 +134,21 @@ void checkBeaconInterval() {
LoRa_Utils::changeFreqTx();
}
if (Config.bme.active) {
LoRa_Utils::sendNewPacket("APRS",iGateBeaconPacket.substring(0,iGateBeaconPacket.indexOf(":=")+20) + "_" + BME_Utils::readDataSensor() + iGateBeaconPacket.substring(iGateBeaconPacket.indexOf(":=")+21) + " + WX");
beaconPacket = iGateBeaconPacket.substring(0,iGateBeaconPacket.indexOf(":=")+20) + "_" + BME_Utils::readDataSensor() + iGateBeaconPacket.substring(iGateBeaconPacket.indexOf(":=")+21) + " + WX";
} else {
LoRa_Utils::sendNewPacket("APRS",iGateBeaconPacket);
beaconPacket = iGateBeaconPacket;
}
if (Config.sendBatteryVoltage) {
beaconPacket += " (Batt=" + String(BATTERY_Utils::checkVoltages(),2) + "V)";
}
LoRa_Utils::sendNewPacket("APRS", beaconPacket);
if (stationMode == 4) {
LoRa_Utils::changeFreqRx();
}
}
lastBeaconTx = millis();
lastScreenOn = millis();
beacon_update = false;
beaconUpdate = false;
}
if (statusAfterBoot) {