Hi @aknoefel ,
I am using your code to read the battery voltage.
But it only works if I use the USB voltage in addition to the 2x AA battery.
That means, if both voltages are present, the battery voltage is read out correctly (currently approx. 2.90 volts), but if I remove the USB voltage, then approx. 3.2 volts are measured.
Am I doing something wrong?
This is my code:
void ManageBattery() {
batvalue = analogRead(PIN_VBAT);
voltage = (batvalue * 3.3) / 1024;
if (voltage < 2.80) {
//Power-Led Blinken lassen
if ((millis() - lastblink) > 250){
digitalWrite(pbPwLed, !digitalRead(pbPwLed)); // LED wird ein- bzw. ausgeschaltet
lastblink = millis();
}
}
else{
digitalWrite(pbPwLed, HIGH); // turn ON the LED
}
Serial.print("Input Voltage = ");
Serial.println(voltage);
}