BaronV
Posts: 12
Joined: Fri Jun 19, 2015 9:40 am

Hardware suggestions for battery monitoring

Wed Sep 22, 2021 7:51 am

Hey guys,

I'd like to use my Pi to build a monitoring system for my off grid solar power system. It consists of 3 8v batteries connected together in series to give a total system voltage of 24v. however when charging this goes up to 30v under max sunshine.

I'd like to be able to monitor the individual voltages of each battery, as well as use a clamp on probe to measure the total current being drawn under load.

Can I get some hardware recommendations?

For sensing the voltage I thought of using something like an ADS1115 ADC, but not only is it kinda expensive at $15 on adafruit, I'm concerned whether this setup would actually be suitable as batteries in series will not have a common ground. I'd need to read the potential difference between say Input 1 and Input 0, rather than between Input 1 and ground.

Any suitable ADC thats in the sub $10 range? how about recommendations for a DC clamp on current probe? Current under load is unlikely to ever exceed 30 amps, and in fact is usually under 10A.

ame
Posts: 3902
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Hardware suggestions for battery monitoring

Wed Sep 22, 2021 8:23 am

Are you using a charge controller? If so, does it have a programming interface where you can extract data like this?
Hmm. What can I put here?

User avatar
Gavinmc42
Posts: 6307
Joined: Wed Aug 28, 2013 3:31 am

Re: Hardware suggestions for battery monitoring

Wed Sep 22, 2021 8:26 am

LTC2945 will go up to 80V, voltage, current and power.
Been running for 6 years, some system have 4 of them, 9 is max.

I also use i2C isolators in some cases, ADUM1250.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
Gavinmc42
Posts: 6307
Joined: Wed Aug 28, 2013 3:31 am

Re: Hardware suggestions for battery monitoring

Wed Sep 22, 2021 8:27 am

I use shunt resistors, 50, 100, 200Amps, they only drop 50mv.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

BaronV
Posts: 12
Joined: Fri Jun 19, 2015 9:40 am

Re: Hardware suggestions for battery monitoring

Wed Sep 22, 2021 8:32 am

ame wrote:
Wed Sep 22, 2021 8:23 am
Are you using a charge controller? If so, does it have a programming interface where you can extract data like this?
yes I'm using a morningstar TS-MPPT that has a serial interface and uses the MODBUS protocol. So i'll be using that to get info related to charging such as panel voltage, total AH, total battery voltage etc.

However for monitoring individual batteries, or load current, that doesnt go through the charge controller, so i need separate sensors for that

BaronV
Posts: 12
Joined: Fri Jun 19, 2015 9:40 am

Re: Hardware suggestions for battery monitoring

Wed Sep 22, 2021 8:36 am

Gavinmc42 wrote:
Wed Sep 22, 2021 8:27 am
I use shunt resistors, 50, 100, 200Amps, they only drop 50mv.
hmm for measuring current i'd really prefer something non invasive like a clamp on hall effect sensor. I don't want to mess too much with the main wiring to the batteries as it's thick and bulky and meant to handle high currents. We're talking about 7.5mm diameter wires here. It's quite unwieldy to deal with.

BaronV
Posts: 12
Joined: Fri Jun 19, 2015 9:40 am

Re: Hardware suggestions for battery monitoring

Wed Sep 22, 2021 8:40 am

Gavinmc42 wrote:
Wed Sep 22, 2021 8:26 am
LTC2945 will go up to 80V, voltage, current and power.
Been running for 6 years, some system have 4 of them, 9 is max.

I also use i2C isolators in some cases, ADUM1250.
hmm just the SMD chip for a LTC2945 is already $5+, so I imagine a board will cost even more. I'm no good at soldering SMDs due to my shaky hands.

anyway i still don't see how this can be used to measure the individual voltages of 3 batteries that are connected in series?

BaronV
Posts: 12
Joined: Fri Jun 19, 2015 9:40 am

Re: Hardware suggestions for battery monitoring

Wed Sep 22, 2021 8:43 am

Would something like this MCP3424 based ADC work? It is 4 channel but has separate +ve and -ve inputs for each channel, which is perfect for measuring individual battery voltages.
And it's pretty cheap too!
https://www.ebay.com/itm/164273925610?h ... SwKrJe~yZN

User avatar
Gavinmc42
Posts: 6307
Joined: Wed Aug 28, 2013 3:31 am

Re: Hardware suggestions for battery monitoring

Wed Sep 22, 2021 11:40 am

We're talking about 7.5mm diameter wires here. It's quite unwieldy to deal with.
Gets up to 500Amp cable 70mm2 :D
Making PCBs is part of the job.
Soldering under stereo microscope steadies the hands.

I'm surprised nobody has made PCBs for this family of chips.
TI have similar ones too.
There are some battery monitoring chips from TI.

8V is probably Lead Golf cart cells?
We use LiFePO4 most of the time with onboard BMS.
Battery life is so much better, costs more but higher capacity and better load/discharge curves.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

BaronV
Posts: 12
Joined: Fri Jun 19, 2015 9:40 am

Re: Hardware suggestions for battery monitoring

Wed Sep 22, 2021 3:16 pm

Gavinmc42 wrote:
Wed Sep 22, 2021 11:40 am
We're talking about 7.5mm diameter wires here. It's quite unwieldy to deal with.
Gets up to 500Amp cable 70mm2 :D
Making PCBs is part of the job.
Soldering under stereo microscope steadies the hands.

I'm surprised nobody has made PCBs for this family of chips.
TI have similar ones too.
There are some battery monitoring chips from TI.

8V is probably Lead Golf cart cells?
We use LiFePO4 most of the time with onboard BMS.
Battery life is so much better, costs more but higher capacity and better load/discharge curves.
sorry but this is a big digression from the main question

drgeoff
Posts: 12416
Joined: Wed Jan 25, 2012 6:39 pm

Re: Hardware suggestions for battery monitoring

Wed Sep 22, 2021 3:47 pm

BaronV wrote:
Wed Sep 22, 2021 8:43 am
Would something like this MCP3424 based ADC work? It is 4 channel but has separate +ve and -ve inputs for each channel, which is perfect for measuring individual battery voltages.
No.

Read and understand the data sheet downloadable at https://www.microchip.com/en-us/product/MCP3424. Page 5. None of the +ve or -ve inputs should be more than 0.4 volts outside the chip's supply rails. Those are 0 and 7 volts absolute maximum.
Quis custodiet ipsos custodes?

User avatar
scootergarrett
Posts: 87
Joined: Sat Apr 19, 2014 2:36 pm

Re: Hardware suggestions for battery monitoring

Wed Sep 22, 2021 3:50 pm

I have messed around with a deep cycle battery (12V) and I used an Adafruit current sensor https://www.adafruit.com/product/1164. that went into one of the ADS1115 ADC channels. I don't think current clamps around a wire work for DC (I think there is such thing but they are expensive and might be for large currents > 10A)

Also add a Fuse

User avatar
neilgl
Posts: 3668
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near The National Museum of Computing

Re: Hardware suggestions for battery monitoring

Wed Sep 22, 2021 5:32 pm

I am measuring the voltage of a 12v battery being charged from a solar panel using a voltage divider (2 resistors) and a cheap (£3) Wemos D1 mini clone (esp8266) that has an ADC. It sends the data via mqtt to a pi3+ which records it, draws graphs etc.

drgeoff
Posts: 12416
Joined: Wed Jan 25, 2012 6:39 pm

Re: Hardware suggestions for battery monitoring

Wed Sep 22, 2021 9:20 pm

scootergarrett wrote:
Wed Sep 22, 2021 3:50 pm
I don't think current clamps around a wire work for DC (I think there is such thing but they are expensive and might be for large currents > 10A)
There are current clamp sensors for measuring DC and they cannot be that expensive as I have a £25 clamp meter for AC and DC current . (It also does the typical multimeter things such as voltage, resistance, capacitance, temperature and NCV.) The sensors do have the drawback that working on the magnetic field they are affected by the earth's magnetic field. When measuring DC current the orientation of the meter needs to be maintained between pressing its "Zero" button and taking the reading. It does resolve down to 1 mA.

That said, I'm not suggesting that the OP use such type of current sensor.
Quis custodiet ipsos custodes?

dustnbone
Posts: 544
Joined: Tue Nov 05, 2019 2:49 am

Re: Hardware suggestions for battery monitoring

Wed Sep 22, 2021 9:43 pm

BaronV wrote:
Wed Sep 22, 2021 8:36 am
Gavinmc42 wrote:
Wed Sep 22, 2021 8:27 am
I use shunt resistors, 50, 100, 200Amps, they only drop 50mv.
hmm for measuring current i'd really prefer something non invasive like a clamp on hall effect sensor. I don't want to mess too much with the main wiring to the batteries as it's thick and bulky and meant to handle high currents. We're talking about 7.5mm diameter wires here. It's quite unwieldy to deal with.
A shunt won't offer much resistance, probably less than the equal length of wire. A hall sensor setup is more complicated as the sensors themselves need to be powered, and they're also more prone to interference causing bad readings. I guess it really depends on priorities, it's a tiny bit more work but a shunt set up will be more reliable. Hall sensors die sometimes, shunts don't.

User avatar
Gavinmc42
Posts: 6307
Joined: Wed Aug 28, 2013 3:31 am

Re: Hardware suggestions for battery monitoring

Wed Sep 22, 2021 11:46 pm

Hall sensors die sometimes, shunts don't.
Shunt resistor sensors used with my Pi's since 2012, they work.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

BaronV
Posts: 12
Joined: Fri Jun 19, 2015 9:40 am

Re: Hardware suggestions for battery monitoring

Thu Sep 23, 2021 4:22 am

dustnbone wrote:
Wed Sep 22, 2021 9:43 pm
BaronV wrote:
Wed Sep 22, 2021 8:36 am
Gavinmc42 wrote:
Wed Sep 22, 2021 8:27 am
I use shunt resistors, 50, 100, 200Amps, they only drop 50mv.
hmm for measuring current i'd really prefer something non invasive like a clamp on hall effect sensor. I don't want to mess too much with the main wiring to the batteries as it's thick and bulky and meant to handle high currents. We're talking about 7.5mm diameter wires here. It's quite unwieldy to deal with.
A shunt won't offer much resistance, probably less than the equal length of wire. A hall sensor setup is more complicated as the sensors themselves need to be powered, and they're also more prone to interference causing bad readings. I guess it really depends on priorities, it's a tiny bit more work but a shunt set up will be more reliable. Hall sensors die sometimes, shunts don't.
Alright, i guess I'll explore the shunt approach a little more. I do infact have a shunt sitting in storage.
this very same one in fact - viewtopic.php?t=276015

Need to try and find the datasheet on this to see how I'd configure the ADC for calculating the current.

BaronV
Posts: 12
Joined: Fri Jun 19, 2015 9:40 am

Re: Hardware suggestions for battery monitoring

Thu Sep 23, 2021 4:30 am

For measuring the voltage I thought about just using a 16 bit ADC and measuring the positive terminal voltage of each battery against a common ground, and then figuring out the voltage of the individual batteries by simple subtraction, but...

the problem with that approach is I'd need to calibrate the resistor divider for about 30V, which would give me a resolution of 1.875v which is far too low for monitoring 8v batteries.

what I really need is a means to measure the potential difference between 2 points, rather than an input and ground. I've yet to find an affordable ADC that does that.

BaronV
Posts: 12
Joined: Fri Jun 19, 2015 9:40 am

Re: Hardware suggestions for battery monitoring

Thu Sep 23, 2021 4:31 am

drgeoff wrote:
Wed Sep 22, 2021 3:47 pm
BaronV wrote:
Wed Sep 22, 2021 8:43 am
Would something like this MCP3424 based ADC work? It is 4 channel but has separate +ve and -ve inputs for each channel, which is perfect for measuring individual battery voltages.
No.

Read and understand the data sheet downloadable at https://www.microchip.com/en-us/product/MCP3424. Page 5. None of the +ve or -ve inputs should be more than 0.4 volts outside the chip's supply rails. Those are 0 and 7 volts absolute maximum.
but that's where you'd use a resistor divider no? I could have 1 per battery.

Edit: scratch that. i see what you're trying to tell me now. Unless I use a Vss that is not 0, my negative channel will always be out of the allowed range for all but the 1st battery. So I'd need to use 3 ADCs to measure 3 batteries which is overkill.

BaronV
Posts: 12
Joined: Fri Jun 19, 2015 9:40 am

Re: Hardware suggestions for battery monitoring

Thu Sep 23, 2021 4:57 am

Would something like this work for measuring the voltage of individual batteries?
https://www.ebay.com/itm/182839079445?h ... SwEH9ZaD8N

it's unclear whether the GND on the input and output sides are common, but if they are then i suppose the board's Vcc can be supplied directly by the battery rather than from the pi?

drgeoff
Posts: 12416
Joined: Wed Jan 25, 2012 6:39 pm

Re: Hardware suggestions for battery monitoring

Thu Sep 23, 2021 9:38 am

BaronV wrote:
Thu Sep 23, 2021 4:30 am
For measuring the voltage I thought about just using a 16 bit ADC and measuring the positive terminal voltage of each battery against a common ground, and then figuring out the voltage of the individual batteries by simple subtraction, but...

the problem with that approach is I'd need to calibrate the resistor divider for about 30V, which would give me a resolution of 1.875v which is far too low for monitoring 8v batteries.

what I really need is a means to measure the potential difference between 2 points, rather than an input and ground. I've yet to find an affordable ADC that does that.
How have you concluded that the resolution would be 1.875 volts? 30/16? That is wrong.

A 16 bit ADC should resolve 65536 levels. If you use a resistor divider for 32 volts the resolution would be 32/65536 which is 1/2048 or half a millivolt. Far more than adequate for monitoring 8 volt batteries.
Quis custodiet ipsos custodes?

BaronV
Posts: 12
Joined: Fri Jun 19, 2015 9:40 am

Re: Hardware suggestions for battery monitoring

Fri Sep 24, 2021 12:18 pm

drgeoff wrote:
Thu Sep 23, 2021 9:38 am
BaronV wrote:
Thu Sep 23, 2021 4:30 am
For measuring the voltage I thought about just using a 16 bit ADC and measuring the positive terminal voltage of each battery against a common ground, and then figuring out the voltage of the individual batteries by simple subtraction, but...

the problem with that approach is I'd need to calibrate the resistor divider for about 30V, which would give me a resolution of 1.875v which is far too low for monitoring 8v batteries.

what I really need is a means to measure the potential difference between 2 points, rather than an input and ground. I've yet to find an affordable ADC that does that.
How have you concluded that the resolution would be 1.875 volts? 30/16? That is wrong.

A 16 bit ADC should resolve 65536 levels. If you use a resistor divider for 32 volts the resolution would be 32/65536 which is 1/2048 or half a millivolt. Far more than adequate for monitoring 8 volt batteries.
oh god i can't believe the stupidity of my post. its been awhile since ive done something like this and i forgot that 16 bits = 2^16 states...
i'm so embarrassed lol :oops:

dustnbone
Posts: 544
Joined: Tue Nov 05, 2019 2:49 am

Re: Hardware suggestions for battery monitoring

Sat Sep 25, 2021 9:57 pm

Gavinmc42 wrote:
Wed Sep 22, 2021 11:46 pm
Hall sensors die sometimes, shunts don't.
Shunt resistor sensors used with my Pi's since 2012, they work.
I've probably depolyed hundreds of current shunts over the years, and the only one I ever recall failing was because someone dropped a hammer on it. Probably more than once.

I replace failed hall sensors fairly often, they are sensitive to heat and to a lesser extent shock.

dustnbone
Posts: 544
Joined: Tue Nov 05, 2019 2:49 am

Re: Hardware suggestions for battery monitoring

Sat Sep 25, 2021 10:02 pm

BaronV wrote:
Thu Sep 23, 2021 4:22 am
Need to try and find the datasheet on this to see how I'd configure the ADC for calculating the current.
Measuring current with a shunt is just a matter of measuring the voltage drop across it. The shunt will have a specific voltage drop (usually 50mV, sometimes 100) for a specific current, and the scale is linear.

So a 50mV 100A shunt will drop 50mV with 100A going through, 25mV with 50A, 5mV at 10A and so on. It's best to size the shunt as closely as possible to your maximum expected load, as you will get more precision on your readings (which will be limited by the resolution of whatever is measuring the voltage drop)

cleverca22
Posts: 4920
Joined: Sat Aug 18, 2012 2:33 pm

Re: Hardware suggestions for battery monitoring

Sun Sep 26, 2021 5:26 am

BaronV wrote:
Thu Sep 23, 2021 4:30 am
what I really need is a means to measure the potential difference between 2 points, rather than an input and ground. I've yet to find an affordable ADC that does that.
ive seen teardowns of electric car battery packs on youtube before, and those need to solve basically the same problem, with 300v between the lowest and highest battery terminal!

the basic solution ive seen there, is to have a separate voltage measuring board, powered off of each bank of cells, that is 100% isolated from the main gnd, so it only sees say a 12v difference across itself

its then opto-isolator routed back to the main control board
i think one case i saw, used full on fiber-optics, to basically just stretch the opto-isolator and give better seperation

Return to “Automation, sensing and robotics”