Become a leader in the IoT community!
Join our community of embedded and IoT practitioners to contribute experience, learn new skills and collaborate with other developers with complementary skillsets.
Join our community of embedded and IoT practitioners to contribute experience, learn new skills and collaborate with other developers with complementary skillsets.
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 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);
}
Could you please explain what difference it could make?
CONTRIBUTE TO THIS THREAD