User avatar
davidcoton
Posts: 4904
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
Contact: Website

Re: Want to measure battery volts

Mon Jul 15, 2019 1:40 pm

chipace wrote:
Mon Jul 15, 2019 6:07 am
I was also thinking about the effective voltage range that you are going to measure on each battery. I am thinking that if the 12V battery drops to 6V, it will be in deep cycle. Also, open circuit measurement of a 12V battery can be as high as 13V. Maybe your effective measurement range would be between 6V to 13V.
A lead-acid battery on charge reaches 13.8V. Allow 15V to give a margin.
Signature retired

ertank
Posts: 42
Joined: Sat Feb 18, 2017 4:44 pm

Re: Want to measure battery volts

Mon Jul 15, 2019 3:27 pm

https://www.aliexpress.com/item/3291407 ... 76c7ooFbkn

How about something like that? It says its communicating using serial. In theory it should be usable with RPi.

BTW, I am after measuring total volts on the serial connected batteries.

User avatar
davidcoton
Posts: 4904
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
Contact: Website

Re: Want to measure battery volts

Mon Jul 15, 2019 4:43 pm

ertank wrote:
Mon Jul 15, 2019 3:27 pm
https://www.aliexpress.com/item/3291407 ... 76c7ooFbkn

How about something like that? It says its communicating using serial. In theory it should be usable with RPi.

BTW, I am after measuring total volts on the serial connected batteries.
I would try to download the User Manual from the supplier. The software they supply is probably Windows not Linux, and there is probably no ARM version. It seems to come with a USB adapter that will connect to the Pi. The serial comms are RS485/Modbus, you may need appropriate software on the Pi to read that. Probably easier than making your own A2D.
Signature retired

User avatar
IOTON
Posts: 99
Joined: Tue Jul 02, 2019 1:00 pm
Contact: Website

Re: Want to measure battery volts

Mon Jul 15, 2019 5:39 pm

ertank wrote:
Mon Jul 15, 2019 9:35 am
I appreciate all help.

I have a basic question: Can I read individual batteries which are serial connected to each other?

What I understand from this drawing is this is fine: https://imgur.com/LN99Wux

Just want to be sure about it.

Thanks & regards,
Ertan
To measure with schematic like this you will need adc with differential inputs. So, 4ch ads1115 can be configured as 2ch differential input ADC.

Also, delete LDO from your schematic, you don't need it.
Normally use standart 1% resistors.
If you need a precise measurement, use precision, low temperature drift resistors.

Also, you will need to calculate resistors values and power dissipation. Old uncle Ohm will help you in it.

ed_attfield
Posts: 2
Joined: Mon Sep 10, 2018 8:53 pm

Re: Want to measure battery volts

Tue Jul 16, 2019 5:09 pm

One thing I didn't see mentioned in the replies was a warning.

If your D/A converters have any direct connection from the analog voltage side to the digital side, such as a shared ground, then when you attach them to the serially connected batteries you will be inadvertently connecting big batteries through your digital wiring.

User avatar
rin67630
Posts: 1017
Joined: Fri Mar 04, 2016 10:15 am

Re: Want to measure battery volts

Tue Jul 16, 2019 7:12 pm

If you don't mind using a technique from the last century: using two reed relays per battery + two reed relays to measure and a condenser to transfer the charge would solve all the problems.
You can buy ten relays here for ~ 3€,
https://www.ebay.de/itm/5PCS-4PIN-5V-Re ... 3540228780
You can then make a measuring cycle every x minutes:
- open the measuring relay, close the relay for battery 1, open it after 1 second, close the measuring relay, measure the value.
- repeat for battery 2, 3, 4. Done!
Needless to say: you need only one ADC and a voltage divider.

ertank
Posts: 42
Joined: Sat Feb 18, 2017 4:44 pm

Re: Want to measure battery volts

Sun Jul 28, 2019 12:03 pm

chipace wrote:
Sun Jul 14, 2019 4:00 pm
Here is how I wired it up to the RPi.
MCP3008 Pin --> Raspberry Pi Header Pin
Vdd --> 5V
Vref --> 5V
AGND --> (floating, not connected)
CLK --> SCLK (SPI)
Dout --> MISO (SPI)
Din --> MOSI (SPI)
CS/SHDN --> CE0 (SPI)
DGND --> Ground

If you want to repeat my setup (and use AAA batteries).
MCP3008 Pin --> AAA Batteries
CH0 --> BATTERY #1 Positive
CH1 --> BATTERY #1 Negative
CH2 --> BATTERY #2 Positive
CH3 --> BATTERY #2 Negative
CH4 --> BATTERY #3 Positive
CH5 --> BATTERY #3 Negative
CH6 --> BATTERY #4 Positive
CH7 --> BATTERY #4 Negative
Hello,

I received my MCP3008 thru a very long route. It was delivered to another address and it took quite sometime until I actually receive it.

I am using WiringPi library for reading values. Battery I am trying to measure is a 1.5V. Multimeter measure around 1.4V from battery. Unfortunately, my Pi readings thru mcp3008 are always 0 (zero). I also tried following command line with same result:

Code: Select all

pi@raspberrypi:~ $ gpio -x mcp3004:100:0 aread 100
0
Most likely I did mixed up the wiring. Following how my wiring is (board/chip printed pin numbers):

Code: Select all

MCP3008      -> Pi
16 (Vdd)     -> 1 (3v3)
15 (Vref)    -> 1 (3v3)
14 (AGND)    -> (not used, empty)
13 (CLK)     -> 12 (PCM_CLK, GPIO1)
12 (Dout)    -> 21 (MISO SPI, GPIO13)
11 (Din)     -> 19 (MOSI SPI, GPIO12)
10 (CS/SHDN) -> 24 (CE0 SPI, GPIO10)
9 (DGND)    -> 6 (ground on Pi)
1            -> (battery +)
2            -> (battery -)
Would you check if above wiring is identical to yours, please?

Thanks & regards,
Ertan

ertank
Posts: 42
Joined: Sat Feb 18, 2017 4:44 pm

Re: Want to measure battery volts

Thu Aug 01, 2019 10:19 pm

I think I fixed my wiring. Used same connections as in here: http://www.noveldevices.co.uk/rp-mcp3008

Battery + is connected to pin 1 of mcp3008
Battery - is connected to Raspberry Pi ground

I get a reading once and then I don't have a reading (0 reading) for quite a long time. There is 3 seconds delay between readings.

I am sure my battery and cabling is good. I also tested using gpio utility from shell and same thing happens in there, too. I could not understand what problem maybe for such a result.

Any help is appreciated.

Thanks & regards,
Ertan

User avatar
davidcoton
Posts: 4904
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
Contact: Website

Re: Want to measure battery volts

Thu Aug 01, 2019 11:15 pm

The one obvious thing is that AGND should not be left disconnected, it should be joined to Pi 0V and battery -ve.

Remember this arrangement is only good for a maximum input (pin 1) of less than 3V3. If you connect a 12V or 48V battery directly you will do a lot of damage.

There is another issue in the pipeline with using the Pi's 3V3 as Vref, but that is not critical yet.
Signature retired

ertank
Posts: 42
Joined: Sat Feb 18, 2017 4:44 pm

Re: Want to measure battery volts

Fri Aug 02, 2019 12:02 am

davidcoton wrote:
Thu Aug 01, 2019 11:15 pm
The one obvious thing is that AGND should not be left disconnected, it should be joined to Pi 0V and battery -ve.
That link I shared and my connections are as following:
AGND is connected to Raspberry Pi Ground
Battery (-) connected to Raspberry Pi Ground

chipace
Posts: 117
Joined: Sat Jun 29, 2019 2:56 am
Location: brown paper bag in a septic tank

Re: Want to measure battery volts

Fri Aug 02, 2019 3:57 am

Is your SPI interface enabled? You can check with check with "Raspberry Pi Configuration" program or by looking at /boot/config.txt
If you connect the battery (-) to GND then you are not doing differential measurements. Other than that your connections appear to be correct.
I wish I could help you with the WiringPi library, but I never use it. I just import spidev in Python.

ertank
Posts: 42
Joined: Sat Feb 18, 2017 4:44 pm

Re: Want to measure battery volts

Fri Aug 02, 2019 9:25 am

chipace wrote:
Fri Aug 02, 2019 3:57 am
Is your SPI interface enabled? You can check with check with "Raspberry Pi Configuration" program or by looking at /boot/config.txt
My SPI interface is enabled.
chipace wrote:
Fri Aug 02, 2019 3:57 am
If you connect the battery (-) to GND then you are not doing differential measurements.
I did not understand what you mean by that. I would like to measure volts in each time. I did not understand "differential measurements"

User avatar
davidcoton
Posts: 4904
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
Contact: Website

Re: Want to measure battery volts

Fri Aug 02, 2019 3:31 pm

ertank wrote:
Fri Aug 02, 2019 9:25 am
I did not understand "differential measurements"
"Differential measurement" is setting the A2D chip to measure the difference between a pair of inputs, rather than measuring each input against AGND. You would need it if (as someone proposed) you wanted to measure each 12V battery in a 48V stack. I don't think it's relevant now, but just check your code is not setting the A2D into the wrong mode.
Signature retired

ertank
Posts: 42
Joined: Sat Feb 18, 2017 4:44 pm

Re: Want to measure battery volts

Wed Aug 21, 2019 10:28 am

Finally, I had a somewhat success using ADS1115 A/D converter.

I used two resistors 100kohm (R1, for + leg), 10kohm (R2, for -leg) for reducing high battery voltage. That design theoretically reduce 50V down to 4.545V. This is as to online calculator here: http://www.ohmslawcalculator.com/voltag ... calculator

My tests using multi-meter readings are divided voltage is 1% accurate. Which is good. However, my readings with ADS1115 are about 10%-15% (13% on average) accurate. So far it is always measuring lower.

Oddly enough, I use identical code and measure 1.5V battery with ADS1115. My multimeter measure and ADS1115 measure is nearly identical.

Being an electrics/electronics newbie, I cannot explain what maybe the problem to have so much difference

I appreciate any help.

Thanks & regards,
Ertan

Return to “General discussion”