Efficient Battery Monitoring with RPI
1503 Views - Created 30/04/2020
I have a RPI in a golf cart that I would like to use to efficently monitor battery level. I came accross the ADC Pi and wanted to see if this would work? The maximum DC voltage on the cart is 60V so I presume I would have to use a resistor.
According to the ADC Pi Input Voltage Calculator it appears I only need a single 187KΩ instead of two resistors to divide the voltage. Is this understanding correct?
I'm currently using GPIO21 for a relay? Is this PIN passthroughed?
With regards to wiring it seems that I simply need to connect the posstive battery terminal to R1 and R1 connects to PIN1 on the ADC? And the battery ground terminal connects to the GND PIN on the ADC?
With regards to the software config, I want to monitor the voltage for 1 minute every 5 minutes. I want to this to be as efficent as possible (as the Pi is battery powered)? Can you please explain the difference between contious and one time?
Appreciate the help!
Adding a 187K? in series with the ADC input will give you a voltage range of 0 to 61.38V.
Is the 60V maximum based on the battery voltage or the charging voltage? A 60V battery will have a charging voltage of around 72V in which case you will need to change the resistor value so that the ADC max voltage is higher than 72V.
GPIO 21 is passed through on the ADC Pi header. The only pins used by the ADC Pi are GPIO2 (SDA), GPIO3 (SCL), 3.3V, 5V and Ground. All other GPIO pins are passed through and can be used for other purposes.
You are correct that the battery positive will connect to R1 and R1 connects to the ADC input. The battery ground connects to the Raspberry Pi ground or the ADC Pi ground which are both connected together.
In continuous conversion mode, the ADC samples the input continuously and will have a sample ready to be read from the I2C bus. In one-time mode, the ADC will sleep until you request a sample at which point it will wake up, take the sample and go back to sleep.
The main difference between the two modes is the power usage and the sample rate. In continuous conversion mode, each ADC chip will consume around 135 μA and will be able to sample at the full speed for each bit rate. In one-time mode, the ADC chip will use around 36 μA between samples but the sample rate will be slower depending on the bit rate. We have a page in our knowledge base that goes into detail on the different sample rates and how they compare in continuous conversion and one-time mode.
In either continuous conversion or one-time mode, the power consumption from the ADC Pi will be minimal compared to the power used by the Raspberry Pi. If you are only going to use the Raspberry Pi to monitor the battery voltage then you may be better off using a lower-power platform like an Arduino which will use a fraction of the power that a Raspberry Pi uses.
The battery voltage is 48V (6x8v batteries). I believe 60V should provide sufficient overhead?
The RPI is also used for access control so I suppose monitoring with continuous mode shouldn't have much of an impact.
If I'm sampling for one minute and then sleeping for 5 minutes. I'd assume I should use the continuous sampling for the one minute but how do I pause sampling while I'm sleeping for 5 (should I set conversion mode to 0)?
The best way to do your sampling would be to set the conversion mode to continuous, sample for a minute and then set the mode to one-time and do one more sample.
Our ADC libraries set the conversion mode when a sample is read from the ADC so you will need to do the one extra read after setting the conversion mode to put the ADC into one-time mode.
Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view, download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.