ADC not stable when reading DC voltage from divider

Hi guys,
I’m newbie on Arduino, just have a Arduino Mega 2560 and try to read DC voltage. I’m using voltage divider to reduce 12V to 5V but analogRead(A0) provide a unstable value. Pleas help on this.

How stable is your 12v6 supply, any change in that will affect your reading.


Rob

How unstable is the reading?

The analog input impedance is 100MOhm, so that shouldn't be the problem.

I advise you to place a 220nF capacitor between the analog input and the ground (so: parallel to the 220K resistor).

Another thought: if you don't need the full 10 bit resolution, you can also shiftRight one, two or three bits, to get a smoother value.

The recommended ADC input impedance shall be <<10kohm. With those resistors you can hardly get a stable result.

Thank everybody for lots of help.
It fixed by add 0.1uF capacitor from ADC A0 to ground. Now it's stable.

But i got another symptom: as in my drawing, power for arduino getting from 5V regulator to Vin pin, it's from 12V power source (a Computer Power Unit). When i connect Mega board by USB cable to my laptop, ADC gave me a difference value as below:

  • External power 5.1V: result is 15.6V (after calculated of course) => wrong
  • External power and USB cable plugged: result is 12.3V => right. Voltage of USB cable by voltmeter is 5.0V.

Anyone know about this please stretch some light.

Thanks so much.
Duy

1 Like

allforum:
Thank everybody for lots of help.
It fixed by add 0.1uF capacitor from ADC A0 to ground. Now it's stable.

But i got another symptom: as in my drawing, power for arduino getting from 5V regulator to Vin pin, it's from 12V power source (a Computer Power Unit). When i connect Mega board by USB cable to my laptop, ADC gave me a difference value as below:

  • External power 5.1V: result is 15.6V (after calculated of course) => wrong
  • External power and USB cable plugged: result is 12.3V => right. Voltage of USB cable by voltmeter is 5.0V.

Anyone know about this please stretch some light.

Thanks so much.
Duy

Vin must be of recommend value:

Input Voltage (recommended) 7-12V
Input Voltage (limits) 6-20V

Lefty

Thanks Lefty, i got the answer finally. The reason was i provided power source to Vin pin (not mini power jack) from 5V regulator, but the components quality are not good, it produces 5.1V. After power Mega board with 12V to mini powerjack, everything back on track. The voltage of Vin pin must exactly 5.0V so ADC make a correct AREF.

Cheers
Duy

i provided power source to Vin pin (not mini power jack) from 5V regulator

Yes, I didn't notice on your drawing but that regulator where it is is wrong.

but the components quality are not good, it produces 5.1V

Probably within spec for the components you are using.

The voltage of Vin pin must exactly 5.0V

You are confusing the heck out of me, an Arduino will never work properly with 5v on VIN. VIN should be 7-12V or thereabouts.

Can you draw what you currently have?


Rob

You are confusing the heck out of me, an Arduino will never work properly with 5v on VIN. VIN should be 7-12V or thereabouts.
Can you draw what you currently have?

Dear Rob,
I just new to arduino, and following this guide to power the board. Vin i'm using is the VIN pin, not power jack, followed by this guide:

"VIN. The input voltage to the Arduino board when it's using an external power source (as opposed to 5 volts from the USB connection or other regulated power source). You can supply voltage through this pin, or, if supplying voltage via the power jack, access it through this pin."

I read the manual out wrong. My bad

Thanks you guys very much