Dear sir

i've got a problem with an arduino nano V3.0

The strange think is that with a voltage of 4.81v (checked with voltmeter) the analogRead gets me 1023 bits.

if the voltags drops down to 4.72v analogRead gets me 1023 bits (~ 4.96v)

any idea?

This is mycode:

// the setup routine runs once when you press reset:
void setup() {
pinMode(A0, INPUT);
Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {

Serial.println(sensorValue);
float voltage= sensorValue * (5.0 / 1023.0);
Serial.print("V=");
Serial.println(voltage);
delay(1000);

}

PS:
i've altro tried to change A1 using A0 but the result is the same.

How do you power the Arduino?

i'm using an "EasyAcc" with an output of 5.13 V connected to pins GND and VIN.

PS: the arduino is also connected via USB to my pc as i'm using Serial to debug signals reads

if the voltags drops down to 4.72v

Which voltage?
The input voltage, or the supply voltage?

``````  float voltage= sensorValue * (5.0 / 1024.0);
``````

Assuming the supply voltage is 5volts.

you are true, but i was assuming that picking the Vin from the 5v pin it will be correct...and i've noticed that is not true.

nik600:
you are true, but i was assuming that picking the Vin from the 5v pin it will be correct...and i've noticed that is not true.

Yes you can by means of a voltage divider.

i've noticed that is not true.

But have you measured it?

You won't get 5.0V out of the regulator if you only feed it 5.13V. You're supposed to feed it 7V to 12V. You'll be lucky if you get s much as 4V out of the regulator. Measure it at the "+5V" pin.

If you connect your 5.13V VIN to the top end of your voltage divider you will have to turn the input down below the regulator output before you get a reading below 1023.

If you aren't getting 5.0V on the "+5V" pin then you won't be measuring voltages correctly using 5.0 / 1024.0

Thanks to all for your replies.

I understand that the assumption on 5v is wrong.

I've checked and i have:

5.15v on the vin/gnd
4.78v on the 5v/gnd
4.35v on the A0/gnd (using the voltage divider circuit)

So, basically, as i want to mesure the value of a NTC 5k resistor using the voltage divider i need to:

• read the "real" vin value on A0 (connecting +5.15v to A0 and GND to GND)
• read the vout value on A1

finally, i won't power the arduino with the same circuit used for the voltage divider, (ie. i'll use the usb of the laptop).

correct?

Thanks

Use USB or 7+ volts on vin. Regulators have a drop out voltage of 1 to 1.5 hence the 7 volt minimum.

nik600:
So, basically, as i want to mesure the value of a NTC 5k resistor using the voltage divider i need to:

• read the "real" vin value on A0 (connecting +5.15v to A0 and GND to GND)
• read the vout value on A1

finally, i won't power the arduino with the same circuit used for the voltage divider, (ie. i'll use the usb of the laptop).

correct?

Incorrect. Your USB supply might not be exactly 5.0V. Even if it is you can't measure 5.15V using a 5.0V supply.

To determine resistance with a voltage divider you need the ratio of (A) the voltage across the divider to (B) the voltage across the variable side of the divider. Typically you would use the Arduino "+5V" pin for (A) and thus you know the first number is 1023. The other number would be whatever analog input you read from between the fixed and variable resistors.

If you use a separate power supply for the voltage divider that voltage must be LESS THAN OR EQUAL TO the voltage on the "+5V" pin if you want to use an analog input to get (A). Using 5V on the Arduino and 5.15V on the voltage divider gives you no way to measure the 5.15V relative to the Arduino power.

Can your 5.15V supply power the Arduino via the "+5V" pin? If so you can use 1023 for the first number since the Arduino supply voltage and the voltage divider supply voltage are again the same.