arduino aref


In the last video I used a trick to enhance the accuracy of the analog to digital converter in the Arduino. I thought this is worth a small video for all the guys which just want to solve this particular issue. Arduino have a built in 10, bit analog to digital converter, abbreviated ADC. They can be used to read analog values on pin a 0 to a 7. A DC’s need an exact reference voltage to be precise. Unfortunately, the Arduino s use the supply voltage as their reference, because supply voltage voltage can vary. The reading of the ADC also varies to show this. I supply an Arduino with a variable supply voltage and measure a fixed voltage of 3 volts. The measured value is displayed on the TFT screen. You see the supply voltage on the yellow multimeter and the measured voltage on the red one. I start with a supply voltage of exactly 5 volts as foreseen. The reading of the Arduino is correct. If I change the supply voltage to 4.8 volt, the Arduino measures a higher value, it is imprecise. The same applies if I change the supply voltage to 5.2 volt. It is quite clear that this is not acceptable if you need precise measurements. This is, for example, true. If you want to measure any sensors with analog outputs as the ampere meter in my last video, fortunately, a trick exists to correct this value. Arduino have a right, precise, built in voltage reference of 1.

1 volt. If we measure this voltage with our imprecise ADC, we get, of course, a wrong value. We saw this in our last test, but because we know that the internal reference is really 1 point 1 volt. We can use the following formula to calculate the real supply voltage. Vcc equals one point one times, one thousand 23 times one thousand divided by the measured result. We see VCC gets bigger when the measured result get smaller, and this is exactly what we need by the way. The factors 1023 and 1000 are because the ADC has 10 bits, which means 1024. Distinctive values can be measured, let’s check in reality. Again i supply 5 volts arduino measures also 5 volts supply voltage. If i go to 5 point 3 volts, the reading of the arduino is quite correct. Of course, a 10 bit ADC is not completely accurate. If i go down to 4.5 volts, the reading is still correct, even with 4 volts, it stays correct. Now let’s use the measured VCC to correct our initial measurement. The formula is: corrected: measurement equals VCC divided by 5, multiplied times the value measured let’s check this. In reality, I can change the supply voltage between 4 and 5 point 3 volt and the reading stays correct at 3 volts much better than the original. The original value changes between two point: eight volts and 3.7 volts, which is a measuring error of minus 72 plus 23. The code to measure supply voltage is enclosed in the comment it uses some bit panning and works on most of the Arduino.


arduino aref Video







arduino aref news








arduino aref Social






👋 Want to bring Tony Stark-like gesture control to your projects? Learn how with the BLE-enabled MKR WiFi 1010 and Nano 33 BLE Sense boards using the ArduinoBLE library.
safe image.php?d=AQDyi1ELcW4VGzhx&w=720&h=720& dChOhNMmeF - arduino aref

Arduin-yo ho ho! A fairground favorite, the pirate ship is a fun way to explore the oscillation of a pendulum. How much fun, you ask? Access our Science Kit Physics Lab preview and see for yourself:

🔬 Now that you’ve gotten your feet wet, dive into the kit and enjoy all nine experiments. Order yours today:

70537898 550174072395145 8798850142103928832 n.jpg? nc cat=102& nc oc=AQmCfMPwMf1oPpYqFhzbxfnGdbrmsjZXrEEBy1ox5Z8EJtiYMADoFNZ5mnSNRgCCY74& nc ht=scontent - arduino aref



(Visited 68 times, 1 visits today)

About The Author

You might be interested in

Comment (48)

  1. Very good video, but I just have to point out that this is making it more accurate not more precise. The number of decimal places is the same each time, so the precision is constant, but the measured value is not close to the actual value, so it is not accurate.
    I’m sure you know this already, just pointing this out to others out there…

    1. English is my third language, so I probably mixed the words. So, you are absolutely right and I hope, the video itself is clear.

  2. Nice video. Just a tiny correction – in formula one should use 1024 instead of 1023. It’s not the highest value that one should be multiplying, it’s the number of values (resolution), and the number of 10-bit values is 1024. So the formula should be VCC=1.1*1024/measured result

    1. Actually, I was wrong, and you were right! 🙂 One person explained the issue with my “correction” – it should be 1023 because the maximum value is 1023, and we are basically calculating percentage, not resolution. One should divide by 1024 if one wants to find out resolution – if one wants to know size of the step ADC can resolve.

  3. Thank you for this video, Andreas! Could you please explain me the formula
    Vcc = 1.1*1023*1000/measured result ?
    God bless you!

    1. I do not remember, how I calculated this (it is a long time since then). It has to do that you measure a value which should be 1.1 volts (internal reference voltage), but in reality, is not, because you measuring is wrong. Maybe you can figure it out if you look at the other calculations in the code…

  4. Maybe its too late after two years and you figure it youself already, but. if you write
    analogReference(INTERNAL); // it will limit analogRead to 1.1v maximum input with 1023 value.
    And you can use simple resistor voltage divider to limit any of your input voltage to 1.1v maximum.
    You made a huge job with register tweaking… but is it worth it?

    1. I think, it is worth it, because you use the internal connection and do not need a divider for that purpose.
      BTW: I did not do the work of tweaking. My contribution is just the communication 😉

  5. HEEDS UP. All arduous have a small divination on the internal 1.1 voltage reference. If you want a perfect reference number, you can use this code here(see link below) to find your chips internal voltage ref ( needs to be done for all the chips you will use because it is not a fixed 1.1 on even the same batch of chips)
    Edit: Could not link directly to it, so you need to scroll down and find the topic:
    “Detecting low voltage”

    Quote from nick gammon writer: “For example, I got 1.062 volts when I tried it”

    Hope this helps someone in getting more precise measurements /alleckz 🙂

    1. Andreas Spiess Nice that I could share!

      I was just going to share directly to Gammons microcontroller section (

      But then I saw this link on there, which is exactly what we want in this case 🙂

      In reference to that I wrote earlier in the first post scroll down too the topic “Reference voltage”.

      Have another quote that will help us. “In all cases Atmel advises putting a capacitor between AREF and ground to smooth out the voltage on that pin. The datasheet doesn’t seem to say, but probably 0.1 µF would do the job.”

      I like you videos between! Keep it up

      /alleckz 🙂

  6. I have gone from 3 volts to 5 volts with 98 percent accuracy. As long as you tie one of the ground ports of the Arduino to whatever you are measuring, its 98-99 percent accurate. Am i wrong in doing this?

  7. Trying to use an Arduino for a high speed, “high” accuracy application, and getting fluctuation on the first digit, is this fluctuation likely due to the supply voltage from the Arduino fluctuating or is it just inherent noise in the system? Like, would adding a capacitor to smooth out the supply voltage make it more accurate? 🙂

    1. If the first bit is the one with the highest weight your setup is completely screwed up. If it is the one with the least weight this is what you have to expect. Any source, also the ones you describe can be the reason for that.

  8. Sir, recently i’m facing a problem when i connect ACS712 20a current sensor to my node mcu 8266 microcontroller.The reading value is not accurate at some points.then i searched on the internet and find out that the current sensor is 5v module while the esp8266 is only giving 3.3v. so how do i fix this?

  9. Dear sir, again a very good work on reading very precise voltage with fluctuating usb voltages. I had this problem as during testing my uno from the supply of my pc usb, the voltage fluctuats around 4.95 to 5.1 volts according to the pc cpu load etc. After uploading the sketch and when it’s built outside the readings are all off. So again to plug to the pc and rewrite the values as per the external 7805 regulator. This video lesson will really help me. I will give it a try. Thank you so much again.

  10. your videos #9 and #10 were extremely helpful: i am putting together my first data logger and the bits of information are good. i will probably apply the code for the keyboard and the OLED to the next project. 🙂 . thank you!

    1. Andreas Spiess i think i found the problem. I need to use a voltage divider to lower my input V to match the internal reference

  11. Does the ESP8266 have an internal reference voltage which would enable it to apply this method to the analog in readings too?

  12. Hi, Mr Spiess, I’m trying to use the ADC if the nodemcu, which accepts only a maximum of 1V input, so how would this formula be affected?

  13. I know you posted this sometime ago, but I just wanted to thank you for doing so. Has significantly improved the accuracy of my Arduinos readings. Brilliant.

  14. Thanks for the post. Is there any such kind of trick for MKR family mine is 1010? I have tested the analogRead(ADC_BATTERY) .

    1. @Andreas Spiess Thanks for the fast feedback. Yes the MKR 1010 is based on SAMD21 Cortex-M0+ 32bit chip.

    1. I was already compared with Arnold Schwarzenegger 😉 He is also Austrian and our native languages are similar, so our accents.


Your email address will not be published. Required fields are marked *