Do you need to know how much Energy a device is consuming? How about producing? Maybe you want to keep track of how much juice is left in a battery pack? Now you can know!
Cliff Note version:
Take a Amp reading every second (Coulombs). Add those readings together (running total). Divide total by 3600 gives you Amp Hours. Multiply by the Volts to get Watt Hours.
Building battery “Fuel Gauges” is simple when you use Coulomb counting. A Coulomb is equal to 1A * 1s, so if your current sensor records a 5A draw this second, that’s 5 Coulombs. If draw is steady for a minute, that would be 300 Coulombs (5 * 60), and if for an hour, 18000 Coulombs (5 * 60 * 60). 18000 / 60 / 60 = 5 Ah
If over two hours, you count 36000 Coulombs, 36000 / 60 / 60 = 10 Ah. So take the total Coulombs you have counted for whatever period of time period you choose, and divide by 3600 (60 * 60), that gives you your Ah charge (or discharge).
Become the Maker you were born to be. Try Arduino Academy for FREE!
The following code simulates a current sensor reading as a fixed rate (0.5A). It prints the Coulomb totals every second, and the running Ah total.
Stay tuned as we combine this with a current sensor and a voltage divider to get Amps, Volts, Ah, and Wh readings.