MKR Family Battery Low Notification

Hi,
I have been researching the MKR family of boards. At some point I'm sure I saw that you can register a callback for when the system is about to power down because the battery is low. But for the life of me I can't now find it.

Am I imaging this or can someone point me in the right direction?

Thanks

I've had some success with the library called Arduino_BQ24195 which works with the battery charger chip used on the MKR series.

One of the library calls is CanRunOnBattery which flags up when the charger thinks the battery is too low. This works okay if you are not actually on battery but are considering switching to it.

But it doesn't work if you are already on battery because the board will shut down at the same time that it generates this alarm state. It might be possible to change this but I haven't found how to do it, or change the setpoint.

I use the same library quite a lot, and have found some limitations in it that are quite well described in the forum.

Like you mentioned, I've also seen that the CanRunOnBattery doesn't work on battery.
I believe this is due to the fact, that when the battery is below, in my experience, 3.33 V then V_ref starts diving with V_bat so it doesn't detect that it has gone below the threshold voltage.

Yes, it's a bit of a pain.

Some of the MKR boards have the battery voltage available as an AI, so for those it's pretty easy to set up a monitoring system that will do whatever you want at a voltage level just high enough that the board can send an alarm before it shuts down.

But the board that needs it most, and is most likely to be running in deep sleep on battery a lot of the time, the MKRWAN 1310, doesn't have it. And it's not particularly easy to get a wire to the battery terminal to feed to a voltage divider.