# Internal Voltage Reference measurement

**URL:** <https://forum.arduino.cc/t/internal-voltage-reference-measurement/1162261>\
**Category:** Nano Every\
**Created:** [August 26, 2023, 5:48pm UTC](https://forum.arduino.cc/t/internal-voltage-reference-measurement/1162261 "2023-08-26T17:48:55Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![spv](https://avatars.discourse-cdn.com/v4/letter/s/a88e57/32.png) [@spv](https://forum.arduino.cc/u/spv)\
**Post date:** [August 26, 2023, 5:48pm UTC](https://forum.arduino.cc/t/internal-voltage-reference-measurement/1162261/1 "2023-08-26T17:48:55Z")

</div>

Hello!  
When I select `**analogReference(INTERNAL2V5);**`: how can I measure this voltage to check its error?

For example, when select `**analogReference(INTERNAL);**` on Arduino UNO, you can measure this voltage in pin AREF. In my case, this voltage is 1.069V, not ideal 1.1V, and knowing this value I can get more accurate analog measurements.

I would like to check the same in Nano Every. Is it posible?  
Thank you very much.

---

<div class="post-metadata">

**Author:** ![DVDdoug](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/dvddoug/32/671533_2.png) [@DVDdoug](https://forum.arduino.cc/u/DVDdoug)\
**Post date:** [August 26, 2023, 6:42pm UTC](https://forum.arduino.cc/t/internal-voltage-reference-measurement/1162261/2 "2023-08-26T18:42:27Z")

</div>

If you use the internal reference to measure & calculate a known external voltage, you can calculate the percentage error/difference from the known-actual external voltage.

---

<div class="post-metadata">

**Author:** ![spv](https://avatars.discourse-cdn.com/v4/letter/s/a88e57/32.png) [@spv](https://forum.arduino.cc/u/spv)\
**Post date:** [August 27, 2023, 5:41pm UTC](https://forum.arduino.cc/t/internal-voltage-reference-measurement/1162261/3 "2023-08-27T17:41:09Z")

</div>

Yes, I know this option, but I prefer to directly measure the internal voltage reference if posible, like Arduino UNO.  
Thank you for your post.

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [August 27, 2023, 6:21pm UTC](https://forum.arduino.cc/t/internal-voltage-reference-measurement/1162261/4 "2023-08-27T18:21:50Z")

</div>

On the Arduino Uno R3, the AREF voltage appears on the pin labeled AREF when the command `analogRead();` is executed.

To read the internal voltage reference, use the command analogReference() to select the desired reference voltage, before calling analogRead().

To determine whether this is possible with the Nano Every, consult the processor data sheet and the official schematic diagram.

---

<div class="post-metadata">

**Author:** ![spv](https://avatars.discourse-cdn.com/v4/letter/s/a88e57/32.png) [@spv](https://forum.arduino.cc/u/spv)\
**Post date:** [August 28, 2023, 1:13pm UTC](https://forum.arduino.cc/t/internal-voltage-reference-measurement/1162261/5 "2023-08-28T13:13:37Z")

</div>

According to the schematic diagram of ADC, I understand that the Internal Vref is not posible to connect to any pin, like the UNO. This Internal Reference is an input of a multiplexer, and the Vref goes directly to ADC.

 ![4809](https://europe1.discourse-cdn.com/arduino/original/4X/0/1/0/010028c9718688164adcd36afe05ff6d17b4aebe.jpeg)

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [August 28, 2023, 3:00pm UTC](https://forum.arduino.cc/t/internal-voltage-reference-measurement/1162261/6 "2023-08-28T15:00:50Z")

</div>

You never need to measure the internal Vref. It can easily be calculated based on measurements.

---

<div class="post-metadata">

**Author:** ![Doc\_Arduino](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/doc_arduino/32/215810_2.png) [@Doc\_Arduino](https://forum.arduino.cc/u/Doc_Arduino)\
**Post date:** [January 30, 2024, 4:58pm UTC](https://forum.arduino.cc/t/internal-voltage-reference-measurement/1162261/7 "2024-01-30T16:58:33Z")

</div>

Hi,

maybe too late, but I'll show it anyway and connect your voltmeter on AREF Pin.

```arduino
const uint8_t VREF_0V55 {0};
const uint8_t VREF_1V1 {VREF_ADC0REFSEL_0_bm};
const uint8_t VREF_2V5 {VREF_ADC0REFSEL_1_bm};
const uint8_t VREF_4V3 {VREF_ADC0REFSEL_1_bm | VREF_ADC0REFSEL_0_bm};
const uint8_t VREF_1V5 {VREF_ADC0REFSEL_2_bm};

void setup()
{  
  VREF.CTRLB = VREF_ADC0REFEN_bm;
  ADC0.CTRLC = ADC_REFSEL_VREFA_gc;
  
  VREF.CTRLA = VREF_0V55;
  delay(2000);  
  VREF.CTRLA = VREF_1V1;
  delay(2000);  
  VREF.CTRLA = VREF_1V5;
  delay(2000); 
  VREF.CTRLA = VREF_2V5;
  delay(2000);  
  VREF.CTRLA = VREF_4V3;
}

void loop()
{
  
}

```

---

<div class="post-metadata">

**Author:** ![stitech](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/stitech/32/1016377_2.png) [@stitech](https://forum.arduino.cc/u/stitech)\
**Post date:** [February 2, 2024, 1:37pm UTC](https://forum.arduino.cc/t/internal-voltage-reference-measurement/1162261/8 "2024-02-02T13:37:03Z")

</div>

> [@Doc\_Arduino](#):
>
> connect your voltmeter on AREF Pin

The ATmega4809 on the Nano Every does not output anything at AREF (see post #5).  
The ATmega328 on the UNO does under certain circumstances, and that allows you to blow up that circuit.

---

<div class="post-metadata">

**Author:** ![Doc\_Arduino](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/doc_arduino/32/215810_2.png) [@Doc\_Arduino](https://forum.arduino.cc/u/Doc_Arduino)\
**Post date:** [February 2, 2024, 2:03pm UTC](https://forum.arduino.cc/t/internal-voltage-reference-measurement/1162261/9 "2024-02-02T14:03:03Z")

</div>

Hi,

You haven't tested the code from #7?  
Test it and see for yourself.  
What it cannot do is measure its internal bandgap.

---

<div class="post-metadata">

**Author:** ![stitech](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/stitech/32/1016377_2.png) [@stitech](https://forum.arduino.cc/u/stitech)\
**Post date:** [February 2, 2024, 6:25pm UTC](https://forum.arduino.cc/t/internal-voltage-reference-measurement/1162261/10 "2024-02-02T18:25:17Z")

</div>

> [@Doc\_Arduino](#):
>
> Test it and see for yourself.

Your sketch didn’t compile. So I wrote my own testprogram. I didn’t measure anything at the AREF pin. Now I wonder: did you run your sketch?

 ![OutputVref](https://europe1.discourse-cdn.com/arduino/original/4X/6/2/b/62b3b3e7706ea2d1aed363984199c56426aef6b0.png)

```arduino

// Does Nano Every output anything at AREF?????
// multimeter at pin AREF using different reference voltages
// voltage divider 10k/1k from 3V3 output to A0 input to prove changing reference

float fmap(float x, float in_min, float in_max, float out_min, float out_max) {
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
void measureVolt(String strVref, float refVolt) {
  delayMicroseconds(50); // allow VREF to settle
  ADC0.COMMAND = 1; // start measurement
  while (ADC0.COMMAND) {}; // wait for end of measurement
  Serial.print("Ref = ");
  Serial.print(strVref);
  Serial.print(", A0 = ");
  Serial.print(fmap(ADC0.RES, 0, 1023, 0, refVolt));
  Serial.println(" Volt.");
}
void setup() {
  Serial.begin(9600);
  ADC0.MUXPOS = ADC_MUXPOS_AIN3_gc; // AIN3 = pin A0
  ADC0.CTRLC = ADC_REFSEL_INTREF_gc | ADC_PRESC_DIV128_gc; // internal reference and 125kHz clock
  ADC0.CTRLA = ADC_ENABLE_bm;

  VREF.CTRLA = VREF_ADC0REFSEL_0V55_gc;
  measureVolt("0V55", 0.55);
  delay(2000);
  VREF.CTRLA = VREF_ADC0REFSEL_1V1_gc;
  measureVolt("1V1", 1.1);
  delay(2000);
  VREF.CTRLA = VREF_ADC0REFSEL_1V5_gc;
  measureVolt("1V5", 1.5);
  delay(2000);
  VREF.CTRLA = VREF_ADC0REFSEL_2V5_gc;
  measureVolt("2V5", 2.5);
  delay(2000);
  VREF.CTRLA = VREF_ADC0REFSEL_4V34_gc;
  measureVolt("4V34", 4.34);
  delay(2000);
}
void loop(){};

```

---

<div class="post-metadata">

**Author:** ![Doc\_Arduino](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/doc_arduino/32/215810_2.png) [@Doc\_Arduino](https://forum.arduino.cc/u/Doc_Arduino)\
**Post date:** [February 2, 2024, 6:50pm UTC](https://forum.arduino.cc/t/internal-voltage-reference-measurement/1162261/11 "2024-02-02T18:50:06Z")

</div>

Hi

I changed it, compiled it, I had used a newer toolchain with a newer header file.  
Now you can use it to measure AREF with DMM.  
The only thing I had also written is that the megaAVR0 cannot measure its own Ub.  
Here now 2 different things came together.  
One more thing. You don't post code as a picture. Never!

You always measure 0.3V with 10k/1k at 3.3V.  
The 0.33V is always below the smallest VREF.  
That's okay with all VREFs.  
Did you expect something else?

You can also make life easier for yourself with [analogReference()](https://www.arduino.cc/reference/en/language/functions/analog-io/analogreference/)  
That was just my own test code with direct access, because I wanted to test something else at the time.

```arduino
const uint8_t VREF_0V55 {0};
const uint8_t VREF_1V1 {VREF_ADC0REFSEL0_bm};
const uint8_t VREF_2V5 {VREF_ADC0REFSEL1_bm};
const uint8_t VREF_4V3 {VREF_ADC0REFSEL1_bm | VREF_ADC0REFSEL0_bm};
const uint8_t VREF_1V5 {VREF_ADC0REFSEL2_bm};

void setup()
{  
  VREF.CTRLB = VREF_ADC0REFEN_bm;
  ADC0.CTRLC = ADC_REFSEL_VREFA_gc;
  
  VREF.CTRLA = VREF_0V55;
  delay(2000);  
  VREF.CTRLA = VREF_1V1;
  delay(2000);  
  VREF.CTRLA = VREF_1V5;
  delay(2000); 
  VREF.CTRLA = VREF_2V5;
  delay(2000);  
  VREF.CTRLA = VREF_4V3;
}

void loop()
{ }

```

---

<div class="post-metadata">

**Author:** ![DVDdoug](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/dvddoug/32/671533_2.png) [@DVDdoug](https://forum.arduino.cc/u/DVDdoug)\
**Post date:** [February 2, 2024, 7:19pm UTC](https://forum.arduino.cc/t/internal-voltage-reference-measurement/1162261/12 "2024-02-02T19:19:04Z")

</div>

> [@spv](#):
>
> on Arduino UNO, you can measure this voltage in pin AREF. In my case, this voltage is 1.069V, not ideal 1.1V, and knowing this value I can get more accurate analog measurements.

The standard calibration method would be to feed-in a known voltage and make a calibration/correction. You don't need to know what's happening inside the chip. 😉

A basic straight-line calibration is an **offset** , which is a value added/subtracted from the readings. Usually the offset is measured at (or near) zero. If no zero calibration is needed the offset is zero. (The Arduino probably will read zero and won't need an offset correction).

Then while applying the offset correction, a 2nd measurement is made at, or near, the maximum, or at the most-likely or most important value, and a **slope** (multiplication factor) correction is made. If the reading is perfect, the slope is 1.0.

Since multiplying by zero equals zero, the slope correction doesn't mess-up the offset correction.

---

<div class="post-metadata">

**Author:** ![stitech](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/stitech/32/1016377_2.png) [@stitech](https://forum.arduino.cc/u/stitech)\
**Post date:** [February 2, 2024, 7:41pm UTC](https://forum.arduino.cc/t/internal-voltage-reference-measurement/1162261/13 "2024-02-02T19:41:05Z")

</div>

> [@Doc\_Arduino](#):
>
> ` ADC0.CTRLC = ADC_REFSEL_VREFA_gc;`

means AREF is an input and you’re going to apply a voltage to it.

This time around I did measure voltages at the AREF pin. According to the schematics in post #5 this shouldn’t be possible. Apparently the circuitry used is not a ‘clean’ analog switch.

There’s a piece of text in the datasheet I never understood, but it’s making slightly more sense now.

 ![4809ADC](https://europe1.discourse-cdn.com/arduino/original/4X/1/9/c/19cd5aac774b035fdbd49f24599cdfe408329225.png)

But it makes me wonder: is it meant to protect the VREF circuitry or to avoid affecting the external voltage?

---

<div class="post-metadata">

**Author:** ![Doc\_Arduino](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/doc_arduino/32/215810_2.png) [@Doc\_Arduino](https://forum.arduino.cc/u/Doc_Arduino)\
**Post date:** [February 2, 2024, 8:04pm UTC](https://forum.arduino.cc/t/internal-voltage-reference-measurement/1162261/14 "2024-02-02T20:04:52Z")

</div>

Hi,

everything it describes is correct. Your measured values also match what you have done.  
The AREF pin is the reference voltage for the ADC. At the same time, the selected VREF voltage specifies the maximum input voltage that can be measured by the ADC on its channels. The selected VREF, which can be measured at the AREF pin using a DMM, is only the reference voltage for the ADC. There are several internal VREFs to choose from and you can also connect your own to the AREF pin. Note Ub! But not all at the same time. Either an internal VREF which is then applied to AREF or an external one. Only 2 capacitors are connected to the AREF pin on the Every Board to stabilize the selected reference voltage.  
The ADC measures everything that is applied to its channels only in relation to the selected VREF.  
Have the ADC output the raw values in the code shown in the picture.  
They must be less in this order.

3.3V / 10 = 0.33V at the ADC channel

VREF 0.55V \> 1024 / 0.55V \* 0.33V = 614  
VREF 1.1V \> 1024 / 1.1V \* 0.33V = 307  
VREF 2.5V \> 1024 / 2.5V \* 0.33V = 135  
VREF 4.3V \> 1024 / 4.3V \* 0.33V = 78

These values should be shown.

---

<div class="post-metadata">

**Author:** ![stitech](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/stitech/32/1016377_2.png) [@stitech](https://forum.arduino.cc/u/stitech)\
**Post date:** [February 4, 2024, 6:19pm UTC](https://forum.arduino.cc/t/internal-voltage-reference-measurement/1162261/15 "2024-02-04T18:19:44Z")

</div>

> [@stitech](#):
>
> I did measure voltages at the AREF pin.

I’ve been thinking about this. The more I think about it, the less likely it seems that this is an oversight of the chipmaker. If it is deliberate it is either to mimic some properties of the 328 or to enable testing in the factory. The latter makes more sense.

---

<div class="post-metadata">

**Author:** ![paulc\_allspace](https://avatars.discourse-cdn.com/v4/letter/p/b5ac83/32.png) [@paulc\_allspace](https://forum.arduino.cc/u/paulc_allspace)\
**Post date:** [February 22, 2024, 3:14pm UTC](https://forum.arduino.cc/t/internal-voltage-reference-measurement/1162261/16 "2024-02-22T15:14:00Z")

</div>

This doesn't seem to be quite correct (post 8). I have a DMM connected to the AREF pin and can clearly see voltage steps when executing a slightly tweaked version of Doc\_Arduino's code:

```arduino
analogReference(INTERNAL2V5);
  VREF.CTRLB = VREF_ADC0REFEN_bm;
  ADC0.CTRLC = ADC_REFSEL_VREFA_gc;
  
  VREF.CTRLA = VREF_ADC0REFSEL_1V1_gc;
  delay(2000);  
  VREF.CTRLA = VREF_ADC0REFSEL_2V5_gc;
  delay(2000); 
  VREF.CTRLA = VREF_ADC0REFSEL_4V34_gc;
  delay(2000);  
  VREF.CTRLA = VREF_ADC0REFSEL_1V5_gc;

```

The Nano Every schematic does show the module AREF pin connected to the ATMEGA4809's pin 27. Thanks Doc\_Arduino.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [August 20, 2024, 3:14pm UTC](https://forum.arduino.cc/t/internal-voltage-reference-measurement/1162261/17 "2024-08-20T15:14:34Z")

</div>

Closed on August 20, 2024, 3:14pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
