MKR 1010 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);  
}

Hi @afnansb_233, I would suggest you this Arduino tutorial to follow. It is quite easy to read and guides you through the steps to solve your issue in another way.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.