# How to monitor 12 Battery with microcontroller?

Discussion in 'General Electronics Chat' started by french_guy, Jun 3, 2013.

1. ### french_guy Thread Starter Active Member

Apr 16, 2009
42
0
How can I simply monitor battery voltage (12V deep cycle battery) with a microcontroller that has 0-5V only ADC?
Well, actually I want to use the microcontroller to monitor the battery voltage and prevent a sump pump to run if the voltage is too low (I dont want to damage the battery with a too deep discharge.)
Kind of a low-voltage battery cut-off.......

2. ### Stuntman Active Member

Mar 28, 2011
213
55
Google "voltage divider" and see if this guides you to a solution.

3. ### Dr.killjoy Well-Known Member

Apr 28, 2013
1,199
178
Why can't you use a cheap ebay led or lcd voltage display ????

4. ### GopherT AAC Fanatic!

Nov 23, 2012
7,983
6,774
Because he would have to check it on a regular basis, he wants to design a system where a Microcontroller to do it for him.

5. ### absf AAC Fanatic!

Dec 29, 2010
1,906
535
I would use a LM393 voltage comparator to compare the battery voltage with a reference voltage from TL431. Output from comparator would operate a relay to cut off the battery from the load.

But if you like to use a micro, I'll pick 12F675 which has an ADC built-in.

Allen

6. ### Brownout Well-Known Member

Jan 10, 2012
2,364
1,000
A 12V battery can put out almost 14V when fully charged. Therefore, use a 3:1 or 4:1 divider to make sure you have the voltage down below 5V. You can use a 10K and 3.3K resistro divider, for example. After converting the voltage, multiply the result by 4 to convert it back to the correct voltage.

I have the exact same project in the works. I want to use a UC to monitor a battery and cut off the load when the battery gets low. But I'm using a 3.3V uC so I need more voltage division. I'm also monitoring the current and calculating the amp-hours. Anyway, you're going in the right direction.

7. ### ErnieM AAC Fanatic!

Apr 24, 2011
7,969
1,828
One thing to realize before it bites you is the battery voltage WILL rise as soon as you turn the pump off... so you need a different, larger voltage to turn it back on.

Generally it's called hysteresis, which means you want the comparator (or program reading the D2A) to be hysterical.

8. ### Brownout Well-Known Member

Jan 10, 2012
2,364
1,000
Or else once the uC turns it off, it stays off until manually reset.

9. ### tracecom AAC Fanatic!

Apr 16, 2010
3,936
1,428
The 12F683 is a newer version of the 12F675, and is supposed to be easier to use.

absf likes this.
10. ### french_guy Thread Starter Active Member

Apr 16, 2009
42
0
I was thinking about an Arduino, easy to program.......I don't want to use a uC that programs in assembler

11. ### french_guy Thread Starter Active Member

Apr 16, 2009
42
0
In that case, the monitoring of the battery should be done when the pump is ON, and not when it's OFF. Thus I will have real voltage measure of the battery under load

12. ### tracecom AAC Fanatic!

Apr 16, 2010
3,936
1,428
PICs can be programmed in C or basic as well, however there is a learning curve (which I am trying to climb.) PICAXE is another option that you might consider. Here's a discussion that might be interesting. http://www.picaxeforum.co.uk/showthread.php?15960-PICAXE-to-measure-a-12v-Battery