Go Down

Topic: Arduino Voltmeter (Read 390 times) previous topic - next topic

bizjak

Hey does anyone know how to wire a arduino to measuring Car battery voltage ?

spycatcher2k

Yes - do a google search for voltage divider - you will find what you need. :-)
Drew.
http://www.uk-pcb.co.uk - My UK Based PCB Fab & Assembly Company
Design work undertaken
SMD & Thru-Hole assembly

dave-in-nj

charging is about 14-15 volts, so you would want to allow for a higher voltage than just the battery.

if you set the maximum for 20v to be safe,
and you have a 5v input,  
then R1=4/5 and R2-1/5

4k and 1 k ?

12v will be near the middle of the range so you should be able to see that maximum value when charging.

you would want to add a zenier to limit the voltage in the event the charging circuit failed.


dave-in-nj

I should have been a smart-a-- and just relied  "YES"

Hackscribble

I think with a 4k and 1k resistor, the voltage at the Arduino will be 20V multiplied by 1k divided by 5k (i.e. the value of the two resistors added) which is 4V.  To get 5V from 20V, the resistors would be 3k and 1k.

But one of the nice things about using the Arduino for this is that you don't have to worry about getting exact value resistors anyway. 

You could use the more common 3.3k and 1k values, test the voltage divider with the battery, measure the actual battery voltage with a multimeter and see what corresponding value you get from analogRead().

Then adjust the value you use in your code to convert from analogRead() result to volts.  Something like this ...

Code: [Select]

const float conversionFactor = 0.xxxx  // set this value depending on test results
float batteryVoltage = conversionFactor * analogRead(BATTERY_PIN);


Regards

Ray

Hackscribble.  Writing about making things.
arduino@hackscribble.com | www.hackscribble.com

bizjak

So

V in = Arduino Battery pin
R1 = 4k Resistor
R2 = 1k Resistor
V out = Battery + terminal ?

Then i need a code in vodi loop to give me info about voltage

Hackscribble

No.  In the diagram that dave-in-nj posted, Vin is the car battery + terminal.  Vout = Arduino analog pin.  R1 is for example 3.3k or 3.9k resistor, R2 is 1k resistor.  You will also need to connect an Arduino GND to the car battery - terminal.

But please take note of the advice to use a zener diode to protect the input from an unusually high voltage from the car battery charging circuit.
Hackscribble.  Writing about making things.
arduino@hackscribble.com | www.hackscribble.com

MarkT

Having the lower resistor about 10k will be more power-efficient and isn't too large
for the ADC.  10k and 33k would divide by 4.3, 10k and 22k would divide by 3.2

You can use larger resistances (might be useful if you want to avoid long term
current drain), but you then should add a 0.1uF capacitor too to reduce the impedance
seen by analog input (otherwise readings can be rather off the correct value).
[ I won't respond to messages, use the forum please ]

Go Up