Working w/ battery

This commit is contained in:
Nico Schottelius 2017-01-04 09:37:07 +01:00
parent 65d77059a3
commit 58ffb0fbc6
1 changed files with 5 additions and 2 deletions

View File

@ -1,8 +1,11 @@
#include <Arduino.h>
#define ADC_AREF 3.3f
#define BATVOLT_R1 2.0f
#define BATVOLT_R2 2.0f
#define BATVOLT_PIN BAT_VOLT
int getB()
{
return (float)analogRead(BAT_VOLT);
return ((ADC_AREF / 1.023) * (BATVOLT_R1 + BATVOLT_R2) / BATVOLT_R2 * (float)analogRead(BATVOLT_PIN));
}