mirror of
https://github.com/richonguzman/LoRa_APRS_iGate.git
synced 2026-02-01 05:14:32 +01:00
22 lines
477 B
C++
22 lines
477 B
C++
|
|
#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);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|