Measure battery state with Cosmic Unicorn + Amigo Pro

I have a Cosmic Unicorn, LiPo Amigo Pro and a 8800 battery. I’m currently trying to figure out how to get the battery state. I went through many places for example Measure battery state, Plus 2W + Amigo Pro - #11 by alphanumeric or even pimoroni’s examples pimoroni-pico/micropython/examples/pimoroni_pico_lipo/battery_pico_display.py at main · pimoroni/pimoroni-pico · GitHub but still can’t figure out how to do it. And I’m at my wit end…

Can someone give me some pointers how to fetch the battery state out of Amigo Pro via the Cosmic Unicorn?

I’m going to tag along to see how you make out. I struggled with trying to do it, as mentioned in the thread you linked too. I did eventually get it to work but it wasn’t easy.
@hel Hel Gibbons may be able to help?

Do you just have the LiPo Amigo connected up via the battery connector? If you want to read the vsys of the Unicorn to estimate the battery voltage I’d expect something like this to work:

Note that as this method measures the system voltage, it won’t report the true voltage of the battery whilst the LiPo Amigo has USB power.

2 Likes

What you see is the voltage under load, and that value while not being perfect is “good enough” to judge if it is time to reload the LiPo.

The “percentage”-figure is more problematic (or better: not useful), because there is no linear relationship between voltage and available capacity:

This is for two AA-batteries, but you have the same sort of graphic for a LiPo.

Thank you guys. Life’s been busy so now I can only get back to this.

Thanks @hel for giving me the example.

@bablokb I tested the code and also charged the battery for a while, and the battery does not get passed over 70% (if we use the example code from Hel). I suspect that we can never get the correct voltage for this purpose. What a shame! :(

What voltages do you see after a few hours of loading? The AmigoPro is a slow loading device, so it takes some time to load your LiPo.

With my LiPos, I can see up to 4.2V, which is in line what a full LiPo can provide. If you don’t see this voltage, you either have many peripherals that draw a lot of current, or your LiPo is defunct. You should then test with peripherals turned off during measurement.

I’ve left it on charge for over two days and the voltage only fluctuates at 3.84V max as you can see on my here. I only connect it to the cosmic unicorn and even underclock to reduce power consumption.

You should also measure your LiPo without load, i.e. take it out of the system and measure it. This should be about 4.2V. It could be that the voltage you see is from the load that is put on the system by the RGB matrix.

Doing this measurement at different stages of discharge, you can create a curve that will tell you the charge percentage based on your realistic load szenario. In your example the curve would start with 3.83V so this is 100% full. But this is only valid if your LiPo is ok, that is why you should check the “no-load” voltage as well.