lorawan/sodaq_one/ns_battery.ino

12 lines
250 B
Arduino
Raw Normal View History

2017-02-19 10:06:05 +00:00
#include <Arduino.h>
#define ADC_AREF 3.3f
#define BATVOLT_R1 2.0f
#define BATVOLT_R2 2.0f
#define BATVOLT_PIN BAT_VOLT
int getBattery()
{
return ((ADC_AREF / 1.023) * (BATVOLT_R1 + BATVOLT_R2) / BATVOLT_R2 * (float)analogRead(BATVOLT_PIN));
}