reading voltage

As the arduino uses 5v how do you reading higher voltages such as sensors that run at 12v? Do you use a shield? I am new to Arduino

Thankyou

Use 2 resistors as a voltage divider:
High voltage - R1 - R2 - Gnd

Junction of R1/R2 goes to Analog pin.

Selecting the resistors:
Vout = Vin * R2/(R1 + R2)

So for 5V Vout, 12V Vin, R2 = 10K, solve for R1:
Vout (R1 + R2) = Vin R2
VoutR1 + VtouR2 = VinR2
VoutR1 = VinR2 - VoutR2
R1 = (Vin - Vout)R2/Vout
R1 = (12 - 5) * 10000/5 = 14000

Thank you crossroads

I guess you want to pick your resistors so they are less than the ADC impedance by some factor? Otherwise why not go with 100's of k or megohms and waste less juice?

You have a sample & hold cap to charge up in the ADC converter. Go bigger if you want, may need to sample 3-4 times to get a stable voltage reading.

Maybe a good idea if not so sure, to test what kind of data you get before settling on values then?

You can calculate the value of R1 and R2 here online

http://www.calculatoredge.com/electronics/voltage%20divide.htm

http://hyperphysics.phy-astr.gsu.edu/hbase/electric/voldiv.html

If I may tag along on this thread… this is something I’m very interested in. However, I need to accurately measure DC voltage in the range of 120 to 180 VDC. Is there a practical way to do this with an Arduino?

I’d like to build an amp-hour counter and to do that I need to know the voltage of the circuit and current through the circuit. Current I can measure with a 500 Amp circuit. Voltage at that level, I haven’t been able to do yet.

Thanks,
Pete

phoyt: If I may tag along on this thread... this is something I'm very interested in. However, I need to accurately measure DC voltage in the range of 120 to 180 VDC. Is there a practical way to do this with an Arduino?

I'd like to build an amp-hour counter and to do that I need to know the voltage of the circuit and current through the circuit. Current I can measure with a 500 Amp circuit. Voltage at that level, I haven't been able to do yet.

Thanks, Pete

There are basically two methods you can use to measure DC voltages higher then the 0-+5vdc limit used for an arduino analog input pin. First is to use a simple two resistor voltage divider to scale say a 0 to + 200vdc measurement range down to 0 to +5vdc suitable for wiring to an arduino analog input pin. This will give you a measurement resolution of .2vdc steps for the 10 bit A/D conversion.

The second method if you require better resolution is to use a combination of voltage divider and op-amp to create a external scaling factor such that any voltage in the range of +120 to +200vdc is converted to a 0 to +5vdc, giving you a measurement resolution of 78 millivolts step size. This method is more complex, so the choice should be based on what measurement resolution (step size) your application requires.

Lefty

Bear in mind, the ADC have only 1024 steps. 0 to 1023. That is the ADC value of a analogRead() function. The Voltage at AVref will affect this value. 1 step is equal to 5 / 1023 = 4.887585 mV.

I did a project to measure 120 Vac using a transformer and op-amp circuit wired as a peak detector to give me a DC value.

Here how I did this : I measure 120 Vac , the Vout dc is 3 V So 120 = 3 and the value for the ADC is 613 at 3 V. So I use a ratio of 120 / 3 = 40.

Example : The ADC read 412 ===> 412 X ( 5 / 1023 ) = 2.01368 V ====> X 40 ← ratio = 80.54 V ac
The accuracy is : 1 X ( 5 / 1023 ) = 4.887 mV ===> X 40 = 0.195 V ac ← tolerence value

The higher the voltage is, the higher the tolerance value is. You can measured a 1000 V if you want, but the ration in the calculation will be higher.