mirror of
https://github.com/richonguzman/LoRa_APRS_iGate.git
synced 2026-08-07 09:22:57 +02:00
better battery code
This commit is contained in:
@@ -24,11 +24,11 @@ namespace BATTERY_Utils {
|
||||
float checkBattery() {
|
||||
int sample;
|
||||
int sampleSum = 0;
|
||||
#ifdef HELTEC_V3
|
||||
#ifdef ADC_CTRL
|
||||
digitalWrite(ADC_CTRL, LOW);
|
||||
#endif
|
||||
for (int i = 0; i < 100; i++) {
|
||||
#if defined(TTGO_T_LORA32_V2_1) || defined(HELTEC_V2) || defined(HELTEC_HTCT62) || defined(HELTEC_V3) || defined(ESP32_DIY_LoRa_A7670) || defined(TTGO_T_LORA32_V2_1_915)
|
||||
#ifdef BATTERY_PIN
|
||||
sample = analogRead(BATTERY_PIN);
|
||||
#endif
|
||||
#if defined(ESP32_DIY_LoRa) || defined(ESP32_DIY_1W_LoRa)
|
||||
@@ -38,7 +38,7 @@ namespace BATTERY_Utils {
|
||||
delayMicroseconds(50);
|
||||
}
|
||||
|
||||
#ifdef HELTEC_V3
|
||||
#ifdef ADC_CTRL
|
||||
digitalWrite(ADC_CTRL, HIGH);
|
||||
double inputDivider = (1.0 / (390.0 + 100.0)) * 100.0; // The voltage divider is a 390k + 100k resistor in series, 100k on the low side.
|
||||
return (((sampleSum/100) * adcReadingTransformation) / inputDivider) + 0.285; // Yes, this offset is excessive, but the ADC on the ESP32s3 is quite inaccurate and noisy. Adjust to own measurements.
|
||||
|
||||
+1
-4
@@ -134,10 +134,7 @@
|
||||
#define INTERNAL_LED_PIN 25 // Green Led
|
||||
#define BATTERY_PIN 35
|
||||
#endif
|
||||
#if defined(HELTEC_WS)
|
||||
#define INTERNAL_LED_PIN 35
|
||||
#endif
|
||||
#if defined(HELTEC_V3)
|
||||
#if defined(HELTEC_V3) || defined(HELTEC_WS)
|
||||
#define INTERNAL_LED_PIN 35
|
||||
#define BATTERY_PIN 1
|
||||
#define VEXT_CTRL 36
|
||||
|
||||
Reference in New Issue
Block a user