Monitoring battery voltages

I have a system with 3 x EmonTx3 and I am successfully monitoring AC rms voltage, and various AC power measurements to the raspberry pi HDD version. 

My house is off-grid and stores power in a bank of batteries.  There are 8 x 6V batteries connected in series to make a 48V system.  (The house itself runs off 230V AC just like a normal house.  There is a Victron Multiplus inverter/charger which sits between the battery string and the AC "micro-grid").

What I want to do - the reason for this forum post - is to monitor the voltage of each battery and feed the result into emon-cms.  I am reasonably confident with the software side of the raspberry pi; it's the hardware aspect of getting hold of these voltages, converting them to digital and feeding them to the pi that I would like some advice about.  Just to be clear: I want to do this monitoring while the batteries are in use, ie while they are connected together in a series string.

This is my first forum post, btw.

Robert Wall's picture

Re: Monitoring battery voltages

Is any point of the battery circuit grounded? This is a fairly critical point. If the battery is floating, there is a need to provide isolation between the battery and your RPi.

Do you really want to measure the voltage of each battery, or will you be content with measuring the voltage of the string and at 7 places in between into 8 inputs, then doing the sums to get the voltage of each battery?

If it's the former, I think you need 8 differential op-amps to give you 8 floating inputs to measure the 8 separate voltages. In this case, if the battery isn't grounded, the inputs need to be able to withstand whatever voltage the battery is floating at, plus some for safety.

If the latter, and the negative end of the battery is grounded, then the task becomes simpler. You can reference all 8 voltages to ground, you simply need 8 potential dividers to reduce the 48 V to within the range of your ADC(s). 

In both cases, you will need either 8 analogue inputs, or a multiplexer to select the input you want to measure, and one analogue input. If you don't want to construct your own analogue front-end, appears to do what you want as far as the ADC is concerned, and with the addition of 8 resistors should do the second option adequately. [Disclaimer: I have not tried this, I have no idea if it's OK, but it does appear that it should do what you want.]

Welcome, btw ;-)


Andrew Wedmore's picture

Re: Monitoring battery voltages

Robert, thanks very much for your help.

Yes, the battery string is grounded.  So I would basically be taking 8 measurements according to your suggestion:

1st measurement: battery 1

2nd measurement: battery 1 + battery 2

3rd measurement: battery 1 + battery 2 + battery 3

and so on all the way up to the 8th measurement which should normally be around 48V (but can be up to 60V), all measurements being back to the grounded end of the string (negative terminal of battery 1)

Then I can just get the individual measurements by subtracting - easy.

I don't want to do much soldering, so I would go for something like the ADC Pi converter that you suggest.

Can I ask a couple of follow-up questions:

1. Can I add this converter to my raspberry pi which has already got the RFM12Pi on it?  I can see that physically the ADC board can have other boards stacked on top of it, so would I be right in assuming that I can just "stack" the RFM12Pi on top of the ADC converter and it will carry on working?  (it won't fit my nice case, but that's too bad) 

2. I'm fairly sure I understand the principle of a voltage divider, eg if I put two resistors with a 9:1 ratio in series across the voltage I'm interested in, and then measure across the smaller resistor, I'll get 10% of the voltage I'm interested in.  My question is: what sort of size resistor would I use here?  My own guess is this: taking the 60V case as the worst case, let's say that I want this voltage divider to draw no more than 0.25W, that would imply a total resistance of this divider of 14400 ohms, I'd then need to split this 14400 ohms in something like a 30:1 ratio in order to get down to the 2.0V or so that the ADC appears to want.  Does that make sense?  Is the starting point of my calculations (draw no more than 0.25W) a reasonable starting assumption?  I'm cautious because although I understand bits of the theory I've never actually done this kind of thing before.  I know I will need to adjust the actual values to use available resistor sizes and leave a bit of a safety margin, and any fine-tuning of the calibration I can do afterwards in software.  I guess it's just that starting assumption that bothers me - it's a figure I pulled out of the air.

Any help will be very much appreciated.


Robert Wall's picture

Re: Monitoring battery voltages

1. I don't know very much about the RPi, so I'll leave an answer to this to someone who does.

2. If you look at the circuit diagram of that ADC board, you'll see there already is a potential divider on the front end - R8, R20 etc. For convenience, you can just have another resistor in series with the input. Here's the calculation:

For channel 1, already on the board is R8 = 10 kΩ, R20 = 6.8 kΩ.  The blurb tells us that the maximum input to the board is 5.06 V. Therefore the input current is presumably 5.06 V / (10 kΩ + 6.8 kΩ) = 0.301 mA.  We require to drop an additional 55 V at this current, giving a resistor of 182.6 kΩ.  That's a shame, because it is just over a standard value. If you can get a 200 kΩ, 1% resistor (E24 series), that's the best value to use, otherwise it will have to be a 220 kΩ. 

[The presumption is the input current to the ADC is negligible.]

Unless the circuit board is susceptible to damp or similar adverse conditions, that's an entirely reasonable value to use. If it was 10 times that, I'd say no, we'll do it differently because that would be open to inaccuracies given a bit of contamination on connectors, and whatever PCB you use to mount the resistors. The dissipation in the resistor is 16 mW, so any size resistor is plenty big enough. I'd use 0.25 W, 1% metal film.

You can use the same resistor for each, and then all the inputs have the same scale factor, or you can use progressively smaller resistors as you work your way down the chain so that the voltage at the ADC board input remains below but as close to 5 V as possible given the maximum voltage you expect at that node, in which case you'll need to calculate the calibration for each.

The data states that the input is 5.06 V = 17 bits (131072 counts). With the 200 kΩ, I make the calibration 131072 counts = (200 + 10 + 6.8) x 5.06 / ( 10 + 6.8) = 65.3 V, which is the maximum voltage you can measure, it also means you can resolve down to half a millivolt or so (1 count = 0.498 mV). The resistors won't be that stable, let alone that accurate, so there is no advantage in having the complication of different values for each channel.

Each channel will be accurate to 2% (the resistor tolerance, assuming the on-board divider is also using 1% resistors - it's not stated) so each battery voltage could be inaccurate by up to 4% on top of the board's own inaccuracy. That should however be consistent, so you should be able to tweak the calibration of each input so that they all read the same when connected to the same voltage source. Then if all run at about the same temperature, temperature drift should also be the same (a good reason for keeping the dissipation down) and that's about the best you will achieve.

pb66's picture

Re: Monitoring battery voltages

The RFM2Pi and ADC-Pi should work ok together the ADC-Pi only uses I²C pins (P2-3 & P2-5) whilst the RFM2Pi uses the serial port (P2-8 & P2-10) plus a reset pin on GPIO7 (P2-7).

How are you intending to interface this ? will use a python script to poll and forward or some other method ?

I ask because sometime ago I started experimenting with a project using I²C between a Pi and 3 ATmega328p's which I shall be returning to soon, that sent the data to oem gateway via a socket, which forwarded to emoncms, maybe compare notes.


Andrew Wedmore's picture

Re: Monitoring battery voltages

Thank you both very much for your help - it has given me the confidence to go ahead.  I'll order up the parts and report back when I've put it together - probably in a few weeks.

Shane Carriere's picture

Re: Monitoring battery voltages

Hi Andrew,


have you had any success with your design? I am interested in a similar setup.


Sven Ruin's picture

Re: Monitoring battery voltages

We at TEROC Independent Power are doing something similar. Presently we are trying Yoctopuce sensors connected by USB for the measurements.

Andrew Wedmore's picture

Re: Monitoring battery voltages

I see that this thread has been kicked into life again recently, so I'd like to take the opportunity to record that YES it was successful. 

Robert Wall's original suggestions were 100% on target, and the thing has been running for some time.

I have written it up at

It did take me a very great deal longer than originally anticipated; I've had to learn soldering, electronics, Linux and Python so perhaps I was a bit optimistic in my original estimate of a few weeks.

Graphs of battery voltages

You can see various things here: from left to right, first steady discharge, then a few of the batteries "collapse", then the generator cuts in (the curve rises steeply) then steady discharge again, then the graph gets a little more jiggly, that's the solar input, then another collapse and generator input again.  It was not a very sunny day today, not at all.

Robert Wall's picture

Re: Monitoring battery voltages

"I'll order up the parts and report back when I've put it together - probably in a few weeks MONTHS."

FTFY ;-)

But isn't that always the way? A rule I once read for estimating time was "double it, then move to the next higher unit" (e.g. a 5-minute job (estimate) = 10 hours (reality)).

Anyway, I'm pleased that it was successful in the end.

Andrew Wedmore's picture

Re: Monitoring battery voltages

Robert - thank you again for that. 

Yes the project did take months rather than weeks and then what took even more months was getting round to writing it up.  (As always, the urge to forget about documentation and press on with the next project is very strong).

In the spirit of that thought, I've just posted some conclusions about what I learned from the whole exercise at which you may find interesting.

Bill Thomson's picture

Re: Monitoring battery voltages

e.g. a 5-minute job (estimate) = 10 hours (reality)

Ah, yes. Mr Murphy.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.