Measure correct input-voltage with arduino (analog)

So im trying to measure the correct voltage from an input stream on my analog pins. I already used a diode to restrict the maximum voltage to 5.0 volt. The problem is: The numbers that are measured and printed with Serial.print(), seem to be wrong. They are different values then the acutal ones. So for example: if we have 500 millivolts in reality, the arduino seem to measure something from 4.4-4.7 volt.

Anybody have an idea why this is happening? The code im using to measure the voltage is for example:

int closeposition = analogRead(A3);
// to convert it to volt
float closevoltage = closeposition * (5.0 /1023.0);

Is there anyhting that im not seeing that may be messing with the values?
Thank you in advance for all responses :slight_smile:

I am curious how you wired a diode to restrict the voltage to 5V. Could you post a schematic of your circuit?

And, using those code tag thingies, you read about how to use code tags, could you post all your code?

1 Like

This tells me that you're trying to measure a voltage ratio of the Arduino supply, which might not be 5.000volt. Which Arduino are you using.

I would also use 1024 there, not 1023.
Leo..

Hi,
When you read your analog inputs are you reading each input twice then using the last value.

There is only ONE ADC in the Arduino and it is multiplexed to the inputs.
It takes time for the ADC to read the next channel that it is connected to and due to a capacitor on the ADC input there is some lag in the channel voltage stabilizing.

value = analogRead(analogPin);
value = analogRead(analogPin);

Just doing this should help.

What model Arduino are you using?
Can you please post a circuit diagram of your project?
Please not a Fritzy image, a hand drawn schematic will be fine.

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

You really need to look at using the internal voltage reference , which ever way you do it , you will get the best result if you calibrate it against a known voltage