mirror of
https://github.com/richonguzman/LoRa_APRS_iGate.git
synced 2026-04-06 15:05:57 +00:00
HELTEC V3 battery input fix
This commit is contained in:
parent
b00b29a5da
commit
ce058ed424
4 changed files with 27 additions and 11 deletions
|
|
@ -25,19 +25,22 @@ namespace BATTERY_Utils {
|
|||
int sample;
|
||||
int sampleSum = 0;
|
||||
for (int i = 0; i < 100; i++) {
|
||||
#if defined(TTGO_T_LORA32_V2_1) || defined(HELTEC_V2) || defined(HELTEC_HTCT62)
|
||||
sample = analogRead(batteryPin);
|
||||
#if defined(TTGO_T_LORA32_V2_1) || defined(HELTEC_V2) || defined(HELTEC_HTCT62) || defined(HELTEC_V3)
|
||||
sample = analogRead(BATTERY_PIN);
|
||||
#endif
|
||||
#if defined(HELTEC_V3) || defined(ESP32_DIY_LoRa) || defined(ESP32_DIY_1W_LoRa)
|
||||
#if defined(ESP32_DIY_LoRa) || defined(ESP32_DIY_1W_LoRa)
|
||||
sample = 0;
|
||||
#endif
|
||||
sampleSum += sample;
|
||||
delayMicroseconds(50);
|
||||
}
|
||||
|
||||
float voltage = (2 * (sampleSum/100) * adcReadingTransformation) + voltageDividerCorrection;
|
||||
|
||||
return voltage; // raw voltage without mapping
|
||||
#ifdef HELTEC_V3
|
||||
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.
|
||||
#else
|
||||
return (2 * (sampleSum/100) * adcReadingTransformation) + voltageDividerCorrection; // raw voltage without mapping
|
||||
#endif
|
||||
|
||||
// return mapVoltage(voltage, 3.34, 4.71, 3.0, 4.2); // mapped voltage
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue