Go Down

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

#### bizjak

##### May 04, 2014, 04:49 pm
Hey does anyone know how to wire a arduino to measuring Car battery voltage ?

#### spycatcher2k

#1
##### May 04, 2014, 04:52 pm
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 & Assembly work undertaken - Arduino repairs & testing - PM for details.

#### dave-in-nj

#2
##### May 04, 2014, 04:54 pm
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

#3
##### May 04, 2014, 04:57 pm
I should have been a smart-a-- and just relied  "YES"

#### Hackscribble

#4
##### May 04, 2014, 07:17 pm
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 resultsfloat batteryVoltage = conversionFactor * analogRead(BATTERY_PIN);`

Regards

Ray

arduino@hackscribble.com | www.hackscribble.com

#### bizjak

#5
##### May 04, 2014, 07:44 pm
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

#6
##### May 04, 2014, 08:30 pm
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.
arduino@hackscribble.com | www.hackscribble.com

#### MarkT

#7
##### May 04, 2014, 08:57 pm
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
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Go Up

Please enter a valid email to subscribe