mirror of
https://github.com/richonguzman/LoRa_APRS_iGate.git
synced 2026-01-22 08:40:16 +01:00
20 lines
464 B
C++
20 lines
464 B
C++
#include "battery_utils.h"
|
|
#include "pins_config.h"
|
|
|
|
float adcReadingTransformation = (3.3/4095);
|
|
float voltageDividerCorrection = 0.288;
|
|
|
|
namespace BATTERY_Utils {
|
|
|
|
float checkVoltages() {
|
|
float sample;
|
|
int sampleSum = 0;
|
|
for (int i=0; i<100; i++) {
|
|
sample = analogRead(batteryPin);
|
|
sampleSum += sample;
|
|
delayMicroseconds(50);
|
|
}
|
|
return (2 * (sampleSum/100) * adcReadingTransformation) + voltageDividerCorrection;
|
|
}
|
|
|
|
} |