I have a project I'm trying to design and build that involves a "more accurate/useful" battery gauge for an electric scooter. The scooter runs on 24V off of two AGM cells in series. The details of the project are pretty interesting, but the one part I am stuck on is how to actually get the current readings into a Raspberry Pi for recording.
Basically I have the following idea so far:
- Use a current shunt ammeter to read the current the scooter is using. Also need to get the voltage too, for proper watt calculation. Sample this current/voltage value often (once per second?) and use this to compute the watt-hours used. This is the part I'm not sure how to approach.
- Write code on the RasPi to drive a character LCD, read the current and read input switches, and to perform data logging and computation to determine the remaining battery capacity.
- Wrap this whole thing up in some kind of project box, hook up all the wires, add in a 24V-to-5V buck converter to power the Pi, and enjoy.
I do currently have a current shunt ammeter on the scooter, but it's just one of those manual ones that displays to a dedicated screen. I've done calculations to figure out the minimum available battery capacity based on the scooter's maximum current draw and the battery's internal resistance during discharge. Then I currently do the calculation in my head to figure out the percentage remaining based on Wh used on the display. But with a RasPi driving this I could do all sorts of fun stuff - GPS tagging, battery "odometer" (total Wh used since battery was installed), and even a podcast/music player because why not.
The only thing holding me up is figuring out the best (and safest) way to get the current and voltage readings. The scooter's maximum possible current draw is around 20 A at 24 V, going up a steep hill at full speed. I'm not sure if the RasPi itself is sensitive enough to get decent voltage readings that can detect the miniscule changes a current shunt registers, and the only other device I have is a multimeter with a USB optical interface, but that seems way overkill and would require more work. Ideally I'd find some sort of ammeter like the one I currently have, but with a USB port (or an RS232, since I can convert that easily) so the RasPi can read the current ratings in real time.
Anyone have any insight? I'm guessing someone has to have done some sort of ammeter project around a RasPi before?
(PS: I actually want to develop this project even further, possibly working out algorithms to account for the varying current the scooter draws over time, and the battery's natural aging and capacity loss, and also to read incoming charge current from the charger as well as discharge current. I have lots of ideas - but all of it hinges on being able to read current from the 24V system into the RasPi as numeric values.)