0
\$\begingroup\$

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.)

\$\endgroup\$
1
\$\begingroup\$

The purpose of the battery gauge, as usually stated in technical requirements, is to predict the remaining charge left in the battery. Calculating it only from current consumption (a.k.a "coulomb counting") has a lot of potential issues.

For example, you need to know what the actual charge is at all times. i.e. your device has to track the charging process as well. Then your algorithm has to account for real current draw, because it affects the capacity (not as part of watt equation, but as general shift of discharge curve). Add to this temperature dependency, battery efficiency and aging and you get yourself a real puzzle.

I am not saying that it cannot be done. In fact, many gauging systems do use current sensor to improve accuracy by integrating discharge current. But primary way of gauging remaining capacity is always based on voltage and temperature. You should read up on CEDV algorithms because the engineers already thought about those "lots of ideas" you've mentioned, and came up with quite interesting solutions.

Anyway, to answer your actual question, using hall effect current sensors like ACS711 works great in our scooter designs. We also used chips with I2C interface, like INA220, when line isolation was not required. Another compelling option is DS2438 (thanks, @Janka)

In past years we started exclusively using Roboteq motor controllers in scooters and even some robotic applications. Their interface provides accurate enough readings for motor current and battery voltage. Unless we need more precise data for some particular application these controllers remove the need for any additional parts.

Oh, forgot to mention one more option - use battery gauge IC, like BQ34110, if getting results faster is more important for you than DIY aspect of it.

\$\endgroup\$
  • 1
    \$\begingroup\$ I add the DS2438 to the list. \$\endgroup\$ – Janka Jul 26 '18 at 9:31
  • \$\begingroup\$ Interesting chip. I never liked 1-wire interface, which is probably the reason I haven't stumbled upon it before. But yes, it covers all measuring requirements nicely, even temperature. Tiny PCB can be mounted right on the battery itself with minimum wiring. \$\endgroup\$ – Maple Jul 26 '18 at 9:43
  • 1
    \$\begingroup\$ It works with the Raspberry pretty much out of the box, that's why I mentioned it. \$\endgroup\$ – Janka Jul 26 '18 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.