Go Down

#### RehabIsForQuitters

##### Jul 10, 2014, 12:53 am
Hey all,

Tried to search this site and Google but nothing is coming up and it may be that I just don't know what the exact name of this is. I just can't imagine that it doesn't exist.

Here is some background. I have a project where I need my Arduino to read voltage a power supply and if that changes up or down to have it react accordingly. I have everything planned out but I see that reading voltage with an Arduino involves re-inventing the wheel of the 100+ year old technology of the volt meter.

My question is if anyone out there knows of an add on or a module or ANYTHING for the Arduino that I can just purchase, hook it in and have it give me the value of the voltage on a circuit? I don't care what data type it gives me in the Arduino... it could be int, float, double, long double... anything! I just need that value in my code.

My project wasn't to re-invent the volt meter and I'm not looking forward to re-doing what 100's of people have already done for over a century. Anyone know of a product that does this?

#### larryd

#1
##### Jul 10, 2014, 01:01 am
The Arduino will do this, it has an A/D converter onboard.
What voltages do you need to measure?
No technical PMs.
The last thing you did is where you should start looking.

#### retrolefty

#2
##### Jul 10, 2014, 01:11 am
As stated the standard arduino Uno board has 6 analog input pins capable of reading any voltage in a 0 to +5vdc range. No negative voltages allowed and no voltages over +5vdc. If you need to read a voltage higher then +5vdc then you need to scale the external voltage down usually using a two resistor voltage divider so the resulting voltage cannot climb above +5vdc. You can then rescale the voltage back to it's 'real' value in software.

So what is the DC voltage range you need to measure?

#### fungus

#3
##### Jul 10, 2014, 10:37 am
Huh?

int v = analogRead(0);   won't take you a century to type.

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

#### DVDdoug

#4
##### Jul 10, 2014, 11:46 pm
Yeah... We do need to know what voltage range you want to measure, and if it's AC or DC.

The code fungus gave you won't actually give you the voltage...  It will give you a number between 0 and 1023 that's proportional to 0-5V.   In other words, 5V will give you a full-scale ADC reading of 1023, and 2.5V will give you an ADC reading of 512.

To get voltage, multiply by 5/1023.

Code: [Select]
`int v = analogRead(0) *5/1023 ;`

That assumes you are reading a DC voltage less than 5V, and that you are using the default 5V internal reference.

#### retrolefty

#5
##### Jul 11, 2014, 01:09 am
I think our legs are being pulled.

#### cjdelphi

#6
##### Jul 11, 2014, 06:29 am

Yeah... We do need to know what voltage range you want to measure, and if it's AC or DC.

The code fungus gave you won't actually give you the voltage...  It will give you a number between 0 and 1023 that's proportional to 0-5V.   In other words, 5V will give you a full-scale ADC reading of 1023, and 2.5V will give you an ADC reading of 512.

To get voltage, multiply by 5/1023.

Code: [Select]
`int v = analogRead(0) *5/1023 ;`

That assumes you are reading a DC voltage less than 5V, and that you are using the default 5V internal reference.

Not strictly true, 5/1024...

And well analogRead does read voltage what else could it be? The battery's IQ?

#### fungus

#7
##### Jul 11, 2014, 11:11 am

The code fungus gave you won't actually give you the voltage...  It will give you a number between 0 and 1023 that's proportional to 0-5V.

Unless it's a 3.3V Arduino.
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Go Up