From d40057ebbd54a031444ca1e8c006a72d19d09a32 Mon Sep 17 00:00:00 2001 From: richonguzman Date: Thu, 6 Jul 2023 00:14:26 -0400 Subject: [PATCH] 1.1 --- README.md | 4 ++-- src/LoRa_APRS_iGate.cpp | 3 +++ src/battery_utils.cpp | 22 ++++++++++++++++++++++ src/battery_utils.h | 12 ++++++++++++ src/pins_config.h | 2 ++ 5 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 src/battery_utils.cpp create mode 100644 src/battery_utils.h diff --git a/README.md b/README.md index 3c6b982..438a83a 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ g) BME section: __________________________________________ LoRa APRS iGATE/Digirepeater working on this boards: -- LILYGO ESP32 LoRa32 v2-1-1.6 +- LILYGO ESP32 LoRa32 v2-1-1.6 and T3 - ESP32 Wroom + SX1278 LoRa Module for a DIY Version. - HELTEC_WIFI_LORA_32_V2 (check "pins_config.h" and "display.cpp" for aditional configuration). __________________________________________ @@ -91,7 +91,7 @@ Versions: - 2023.06.12 Syslog added. - 2023.06.17 Support for BME280 Module (Temperature, Humidity, Pressure) added. - 2023.06.18 Info on Oled Screen mayor update, added RSSI and Distance to Listened Station. -- 2023.06.19 Failsafe mods to configuration to ensure correct OTA updates. +- 2023.07.05 Adding monitor info of Battery connected __________________________________________ Special Thanks to the help in testing and developing to Manfred (DC2MH) , for showing me the "way of good coding" to Tihomir (CA3TSK) and much more Ham Licence Ops all over the world. diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index dc0cdac..282dafe 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -32,6 +32,8 @@ uint32_t lastBeaconTx = 0; uint32_t previousWiFiMillis = 0; uint32_t lastScreenOn = millis(); +String batteryVoltage; + std::vector lastHeardStation; std::vector lastHeardStation_temp; @@ -39,6 +41,7 @@ String firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seven void setup() { Serial.begin(115200); + pinMode(batteryPin, INPUT); pinMode(greenLed, OUTPUT); delay(1000); Utils::setupDisplay(); diff --git a/src/battery_utils.cpp b/src/battery_utils.cpp new file mode 100644 index 0000000..c259b3e --- /dev/null +++ b/src/battery_utils.cpp @@ -0,0 +1,22 @@ +#include "battery_utils.h" +#include "pins_config.h" + +extern String batteryVoltage; + +float adcReadingTransformation = (4095/3.3); + +namespace BATTERY_Utils { + +String checkVoltages() { + float sample; + int sampleSum = 0; + for (int i=0; i<100; i++) { + sample = analogRead(batteryPin); + sampleSum += sample; + delayMicroseconds(50); + } + batteryVoltage = 2.1571 *(sampleSum/100) * adcReadingTransformation; + return String(batteryVoltage); +} + +} \ No newline at end of file diff --git a/src/battery_utils.h b/src/battery_utils.h new file mode 100644 index 0000000..78b52a1 --- /dev/null +++ b/src/battery_utils.h @@ -0,0 +1,12 @@ +#ifndef BATTERY_UTILS_H_ +#define BATTERY_UTILS_H_ + +#include + +namespace BATTERY_Utils { + +String checkVoltages(); + +} + +#endif \ No newline at end of file diff --git a/src/pins_config.h b/src/pins_config.h index 08dea52..b3478cf 100644 --- a/src/pins_config.h +++ b/src/pins_config.h @@ -15,6 +15,8 @@ #define greenLed 25 // Green Led +#define batteryPin 35 + /* (Same pins for LILYGO LoRa32 and ESP32 Wroom Dev ) SX1278-------------------> ESP32 ttgo-lora32-v21 and ESP32 WROOM Dev GND GND