Powering over battery?

I’m really having difficulty figuring this out - I want to find a way to portably power the rock 5b, have a way to send battery data (percentage) to the rock 5b. i don’t care if its hackish or if i have to connect something to the gpio and write a script to get the battery information, as long as it works. also, i would like a way to recharge it, during use. and finally, i would like the usb-c port not to be used fully for this, e.g breakout board for other things, or connect the power to gpio / poe and somehow let usb-c charge it?? I’ve looked everywhere and can’t find a solution that just works and meets my requirements. Thanks

Now the easiest solution would be to hook it up to a pd capable power bank. I have tested this with an anker one I have here. What works:
Powering the Rock
Charging the power bank while using it(even though I dont recommend it for the lifecycle of the power bank)
What doesnt work for u:
No querying the power bank as far as I know - you could break the case of the power bank and hook the status indicator of the power bank up to the gpio - we’re at hackish solutions here already
It uses the PD Port of the board.

Things to note: You could always supply the 5v from a regular power bank this way to the GPIO Pins 2+4 as per the wiki
You could also hook up the power bank to a usb-c dock and put that into the rock - i currently run mine like this because my type c power supply itself doesnt work with the rock 5, with the dock in between it does.
Finally: I have not been able to get anything out of the type c port. I have not tried HDMI even though my dock offers a port for this, but I have tried the card reader, ethernet and the usb ports on the dock and have not been able to get any response out of the rock. This might be because of the dock, it might also be because of the rock. I honestly dont know.

1 Like

Rock5b allready has saradc input connected to the vbus supply voltage with a voltage divider, you can check here Realtime power usage on how this works and read the saradc data with any scripting language and convert it to the actual voltage of the battery.

When you have the voltage, you have enough input to model the percantage of the charge status.

that would be true if lithium batteries discharged linearly. The truth of the matter is however that they do not. They start at 4.22V, then go down rather sharply to about 3.7 where they stay for a longer while and then quickly drop down to around 3V(battery use should be cut around 3.2 at the latest imho):

Then theres the thing that the op most likely doesnt wanna have to deal with the charge electronics of a lithium battery. Since we are most likely talking PD here, he needs a battery management system for charging and discharging(idealy balanced charging of 2-3 cells in series), a buck/boost converter for getting the right voltage and a PD controller. While all of that can be achieved with off the shelf components, we are talking about rather advanced stuff with dangerous components(the batteries).

For actual battery percentage a battery gauge circuit is needed on top.

Btw, you can read the actual supply voltage from sysfs in linux as the kernel exports these. No need for fancy calculations. Current is a different topic again

yep true that, thats why i mentioned about modelling, and also discharge and charge curves are different, so possible algo must check if it is draining and then match to the curve.
Also the protection stages are crucially important if you dont want to spark some fireworks with your batt., the internal pmic has some protection registers if my memory does not fool me. but the pmic is behind the voltage regulators so that makes it useless for the OP’s application and IO things are not necesserily powered by the PMIC.

How does that work? I am not aware of such a thing, you mean fusb-chip registers? i think those are negotiated voltage rather than the measurement of the actual voltage.

try:

awk ‘{printf ("%0.2f\n",$1/172.5); }’ </sys/devices/iio_sysfs_trigger/subsystem/devices/iio:device0/in_voltage6_raw

ah ok thanks, now i got what you mean. this is actually reading saradc and multipliying with 172, which is the gain of voltage divider.

For a professional approach, get something like this:

APC Smart-UPS SC 420VA 230V - APC Netherlands

An ups with rs232 communication that has (un)offical documented protocol.

But I think you are looking for something like this:

Can even install on linux:

and

I actually just remembered something that might help the OP: The good old StromPI3: https://strompi.joy-it.net/en/strompi-family

this is originally a hat for Raspberry pi systems, providing a wide range of power sources as options, including a battery hat with a LiFePo3 battery. I have one at home, the gpio/POE Layout matches that of the Raspberry PI, so it should in theory work. The Hat will put out 5V3A, which should be safe with the rock 5B, and can take power from either a micro-USB Plug, a so called WIDE power in which accepts any power source providing 6-61Volts or the battery. Power sources can be prioritized. Now for the battery HAT it comes with a 1000mA LiFePo battery attached, which isnt much tbh, but the Battery can easily be replaced by soldering another battery on to it.(make sure you add a LiFePo and NOT a LiPo) Replacement was fairly easy when I did that back in the day, and since its lifepo its safe to do so.

I did not test a direct connection to the rock 5b with the gpio/poe pins, however. I did test the powered usb out from that hat to power up the rock 5b. Voltage remains a stable 5V even under load.

So yeah, this board has everything you need, and on top of that it comes with a STM32 microcontroller that establishes a serial connection on the GPIO. This allows further programming, like safe power down if main power gets interrupted(did I mention theres a buffer cap on the board as well for uninterrupted switching of power sources?), send an alarm or run a script on power source change, query battery life etc.

Give it a try!

Thanks for your help! Quick question: would any of these solutions work like this: plugging the usb-c charger into the board = gpio batteries charge? Im working on a project and i don’t want to modify the form factor too much cause if i add port extenders or whatever for a few things, i’ll end up having to do it for the rest, but i really like the way the ports are set up on the rock 5 and don’t want to add too much junk surrounding it. thank you so much for your replies, they’re very helpful

qb826g and your problem solved, since almost none of powerbank support uninterruptible power when you insert/detach power cable.

But as for % charge you need to create solution. For example you can use photoresistor or dissembly the qb826g to get to the control board

1 Like

At least with the strompi this will not work out of the box. Reason being gpio can only be used to power the board. And the strompi needs to be powered through it’s own inputs. On the raspberry pi systems I ended up wiring the USB input of the pi to the USB input of the strompi, from behind the connector but before the voltage regulator. When doing this sort of hack with a rock be aware of those two things: unlike the pi the rock gets power via USB power delivery, so make sure you ever only power the rock with a source that isn’t capable of more than 5 volt when hooking it up to the microusb input of the strompi, or make sure to use a 12v barrel DC to usb-c adapter and wire it to the wide input of the strompi. DO NOT feed more than 5volts to the USB input as this might break things and do NOT feed less than 6 volts to the wide input(as the bucktconverter won’t be able to convert it and you won’t have power on the board. On the bright side when just using the wide input from the strompi you can just add two cables(no soldering required) to move the power input wherever you want without altering the form factor

Thanks for this. Been looking for a bank with proper uninterrupted passthrough. I just wish for a model with easily replaceable 21700 cells.