Measuring vin
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- af1797
- Posts: 7
- Joined: Sun Aug 05, 2012 4:17 pm
Measuring vin
If I use a 9 volt battery to power the arduino, can I run the vin pin through say for example a 10k resistor and then run that into a analog pin to read the voltage? To find out what the voltage actually is I would just multiply the analog reading by a contestant. If the voltage dropped below say 7 volts I would light up an led to let you know to change the battery. Does anyone see a problem with this? And also if it is possible how big of a resistor should I use?
- john444
- Posts: 443
- Joined: Sun Mar 04, 2012 2:42 pm
Re: Measuring vin
Hi Af,
If you use the 5-V reference for the Arduino's A/D (there are several)
it is necessary to reduce the measured voltage since it is higher than the reference.
This is easy to do. Because 9V is almost 2x the reference voltage,
simply divide the 9V by 2. Use two 10K resistors connected in series.
Connect the voltage to be measured to the end of one 10K, the end of the other resistor goes to the Arduino GND.
The connection between the resistors will be at 4.5V and connects to the A/D input.
Just remember that the number (0-1023) represents 0-5V. The 4.5V (between the resistors) should show up as about 920.
Lady Ada shows how to input & convert voltages to the A/D at:
http://learn.adafruit.com/tmp36-tempera ... emp-sensor
Good luck with your project,
John
If you use the 5-V reference for the Arduino's A/D (there are several)
it is necessary to reduce the measured voltage since it is higher than the reference.
This is easy to do. Because 9V is almost 2x the reference voltage,
simply divide the 9V by 2. Use two 10K resistors connected in series.
Connect the voltage to be measured to the end of one 10K, the end of the other resistor goes to the Arduino GND.
The connection between the resistors will be at 4.5V and connects to the A/D input.
Just remember that the number (0-1023) represents 0-5V. The 4.5V (between the resistors) should show up as about 920.
Lady Ada shows how to input & convert voltages to the A/D at:
http://learn.adafruit.com/tmp36-tempera ... emp-sensor
Good luck with your project,
John
- af1797
- Posts: 7
- Joined: Sun Aug 05, 2012 4:17 pm
Re: Measuring vin
Thanks for your help. I know this is basic electronics, but why do you need the 2nd 10k resistor to ground?
- john444
- Posts: 443
- Joined: Sun Mar 04, 2012 2:42 pm
Re: Measuring vin
The two series resistors are called a "voltage divider".
Has to do with voltage, current and Ohm's law.
Let's use your project as an example.
Two 10K resistors connected to 9V allows 0.45mA to flow.
(9V / 20,000ohm = 0.00075A)
From GND to the other side of the 10K is: 10K * .45mA.
(10,000 * 0.00045 = 4.5V)
The 10K resistors are common and easily available making this a
popular method to reduce a voltage for measurement.
A single series resistor will cause a voltage drop across it when current flows.
An Arduino's A/D draws little current as it charges an internal capacitor when it takes a measurement.
The equlivelent resistance of this capacitor seems to change as the capacitor charges.
There are two big issues with a single resistor to reduce the voltage.
The series resistor would need to have a very large resistance (due to the low current)
and the current changes as the internal capacitors charge.
(the voltage indicated by the A/D would rise the longer it is connected)
Check out the section on Ohm's Law at http://www.ladyada.net/learn/arduino/LEDs.html.
I hope my explanation clarifies why a single resistor will not work as you hoped.
John
Has to do with voltage, current and Ohm's law.
Let's use your project as an example.
Two 10K resistors connected to 9V allows 0.45mA to flow.
(9V / 20,000ohm = 0.00075A)
From GND to the other side of the 10K is: 10K * .45mA.
(10,000 * 0.00045 = 4.5V)
The 10K resistors are common and easily available making this a
popular method to reduce a voltage for measurement.
A single series resistor will cause a voltage drop across it when current flows.
An Arduino's A/D draws little current as it charges an internal capacitor when it takes a measurement.
The equlivelent resistance of this capacitor seems to change as the capacitor charges.
There are two big issues with a single resistor to reduce the voltage.
The series resistor would need to have a very large resistance (due to the low current)
and the current changes as the internal capacitors charge.
(the voltage indicated by the A/D would rise the longer it is connected)
Check out the section on Ohm's Law at http://www.ladyada.net/learn/arduino/LEDs.html.
I hope my explanation clarifies why a single resistor will not work as you hoped.
John
- af1797
- Posts: 7
- Joined: Sun Aug 05, 2012 4:17 pm
Re: Measuring vin
That makes sence. Thank you for all of your help.
Please be positive and constructive with your questions and comments.