Inaccuracy with AnalogRead and Voltage Divider Circuit

I am trying to measure the voltage from 0-100V. I am using a voltage divider, namely a 1M resistor and a 40K resistor and I am using analog read off the 40k resistor. It is fairly accurate at high voltages like 70 V, 80 V, or 90V, but is wildly inaccurate at low voltage. The arduino is reading 3.2V and the actual voltage is just 2V.

Any tips to bring down this error?

What are the tolerances of the two resistors? You have to add the tolerances together to get the tolerance of the voltage divider. Is you voltage readings within the tolerance of you voltage divider pair?

Paul

What happens if yoou short the top of the 1M resistor to ground - do you have ground problems?

Allan

I would add a 100n cap from pin to ground with those high resistor values.
Leo..

You could also try reducing the resistor values.
Often seen for the analog pin is 10K which would mean a resistor chain of 250 Ohms and 9.75K Ohms to reduce the voltage in the ration of 1:40. However, with a voltage of 100V, that means 10mA which is on the high side. Maybe find a compromise between these values and the ones you are using.

Another thing to try is reading the analog pin twice and discarding the first reading.

Edit: from Atmel Datasheet ATmega328p

The ADC is optimized for analog signals with an output impedance of approximately 10 k ohms or less. If such a source is used, the sampling time will be negligible. If a source with higher impedance is used, the sampling time will depend on how long time the source needs to charge the S/H capacitor, with can vary widely. The user is recommended to only use low impedance sources with slowly varying signals, since this minimizes the required charge transfer to the S/H capacitor. [S/H: sample/hold]