24 lines
609 B
C
24 lines
609 B
C
#include <Arduino.h>
|
|
|
|
const float MinimalSpannung = 2.85;
|
|
float koa = 0.984326019;
|
|
char floatString[15] = {0};
|
|
float AKKU;
|
|
|
|
float getBattery(float kor = 1.000)
|
|
{
|
|
#if (NOBATT == 1)
|
|
Serial.print("Batterie:\t\t 3.05 V\n");
|
|
return 3.05;
|
|
#endif
|
|
float valA0 = analogRead(A0);
|
|
valA0 = valA0 * 3.7; // (R1 + r1 + r2) / r2
|
|
// r1 und r2 Spannungsteiler
|
|
// r1 = 270k, r2 = 100k
|
|
// Spannungsbereich = 5.2 Volt
|
|
valA0= valA0 / 1024;
|
|
valA0 = valA0 * kor;
|
|
dtostrf(valA0,7,2,floatString);
|
|
Serial.printf("Batterie:\t\t %s V\n", floatString);
|
|
return valA0;
|
|
} |