mirror of
https://github.com/richonguzman/LoRa_APRS_iGate.git
synced 2026-04-06 06:55:07 +00:00
1.1
This commit is contained in:
parent
23302ab75a
commit
d40057ebbd
5 changed files with 41 additions and 2 deletions
22
src/battery_utils.cpp
Normal file
22
src/battery_utils.cpp
Normal file
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue