2023-05-18 12:10:48 +02:00
|
|
|
#include <Arduino.h>
|
|
|
|
|
2024-10-01 23:59:46 +02:00
|
|
|
const float MinimalSpannung = 3.60;
|
|
|
|
float korectur = 0.90021322;
|
2023-05-18 12:10:48 +02:00
|
|
|
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);
|
2024-10-02 10:29:54 +02:00
|
|
|
#ifdef Spannungsteiler
|
|
|
|
valA0 = valA0 * Spannungsteiler;
|
|
|
|
#else
|
|
|
|
valA0 = valA0 * 5.4;
|
|
|
|
#endif
|
|
|
|
// (R1 + r1 + r2) / r2
|
2023-05-18 12:10:48 +02:00
|
|
|
// r1 und r2 Spannungsteiler
|
|
|
|
// r1 = 270k, r2 = 100k
|
|
|
|
// Spannungsbereich = 5.2 Volt
|
|
|
|
valA0= valA0 / 1024;
|
|
|
|
valA0 = valA0 * kor;
|
|
|
|
dtostrf(valA0,7,2,floatString);
|
2024-09-28 22:01:53 +02:00
|
|
|
Serial.printf("Batterie:\t\t%s V\n", floatString);
|
2023-05-18 12:10:48 +02:00
|
|
|
return valA0;
|
|
|
|
}
|