lorawan/sodaq_one/battery.ino
Nico Schottelius 70bd008498 Cleanup
2016-10-24 21:34:02 +02:00

11 lines
283 B
C++

#define ADC_AREF 3.3f
#define BATVOLT_R1 2.0f
#define BATVOLT_R2 2.0f
#define BATVOLT_PIN BAT_VOLT
uint16_t getBatteryVoltage()
{
uint16_t voltage = (uint16_t)((ADC_AREF / 1.023) * (BATVOLT_R1 + BATVOLT_R2) / BATVOLT_R2 * (float)analogRead(BATVOLT_PIN));
return voltage;
}