AB01 always reports same battery value

I’m using an HTCC-AB01. When I call getBatteryVoltage() the first time, I get a reading that seems to make sense. That reading goes down if I run my sketch on battery power for a while, and it goes back up when I plug in the USB.

But there’s a problem. If I call getBatteryVoltage() inside loop() every few seconds, I always get the same reading. If I reset the device, the device will report a new value, but whatever it reports on the first call to getBatteryVoltage(), it will continue to report the same value until I reset the device again.

Has anyone else seen this issue?

It can be seen from the schematic diagram of AB01 that when the USB is connected, the battery will be charged, so the value obtained by getBatteryVoltage() is not the battery voltage, but the charging voltage.

It was a bug in my code - declaring the variable I was going to use in the same statement as the assignment from getBatteryVoltage(), but I had added “static” to the variable declaration. So of course that call was treated as an initial value, not as a value to be reassigned each time through the loop. Dumb mistake.

Thanks for your response!