Incorrect Battery Percentage Reading on MKR 1010 with 3.7V Lithium Battery

Hi I am using the following code to monitor a 3.7V 800MAH lithium battery to power my MKR 1010, and I have all the required library. However, this code always shows the battery percentage as 100, do you have any idea how to solve? #include "Battery.h" Battery battery(2750, 4200, ADC_BATTERY); void setup() { Serial.begin(9600); while (!Serial); analogReference(AR_EXTERNAL); analogReadResolution(10); battery.begin(3300, 1.47); } void loop() { Serial.print("Battery voltage is "); Serial.print(battery.voltage()); Serial.print(" ("); Serial.print(battery.level()); Serial.println("%)"); delay(1000); }
2 Replies
Nayel
Nayel2mo ago
Hi Aymen can you add this to your code is for debugging purpose ; void loop() { int rawADC = analogRead(ADC_BATTERY); Serial.print("Raw ADC value: "); Serial.println(rawADC); Serial.print("Battery voltage is "); Serial.print(battery.voltage()); Serial.print(" ("); Serial.print(battery.level()); Serial.println("%)"); delay(1000); }
aymen ammari
aymen ammari2mo ago
Could you please explain what difference it could make?
Want results from more Discord servers?
Add your server