Reference.AnalogReference History

Hide minor edits - Show changes to markup

February 11, 2011, at 08:54 AM by David A. Mellis -
Changed lines 11-12 from:
  • EXTERNAL: the voltage applied to the AREF pin is used as the reference.
to:
  • EXTERNAL: the voltage applied to the AREF pin (0 to 5V only) is used as the reference.
Changed lines 26-27 from:

If you're using an external reference voltage (applied to the AREF pin), you must set the analog reference to EXTERNAL before calling analogRead(). Otherwise, you will short together the active reference voltage (internally generated) and the AREF pin, possibly damaging the microcontroller on your Arduino board.

to:

Don't use anything less than 0V or more than 5V for external reference voltage on the AREF pin! If you're using an external reference on the AREF pin, you must set the analog reference to EXTERNAL before calling analogRead(). Otherwise, you will short together the active reference voltage (internally generated) and the AREF pin, possibly damaging the microcontroller on your Arduino board.

December 16, 2010, at 05:17 PM by David A. Mellis -
Added lines 20-23:

Note

After changing the analog reference, the first few readings from analogRead() may not be accurate.

October 28, 2010, at 05:51 PM by David A. Mellis -
Changed lines 8-10 from:
  • INTERNAL: an built-in reference, equal to 1.1 volts on the ATmega168 or ATmega328 and 2.56 volts on the ATmega8.
to:
  • INTERNAL: an built-in reference, equal to 1.1 volts on the ATmega168 or ATmega328 and 2.56 volts on the ATmega8 (not available on the Arduino Mega)
  • INTERNAL1V1: a built-in 1.1V reference (Arduino Mega only)
  • INTERNAL2V56: a built-in 2.56V reference (Arduino Mega only)
Changed lines 15-16 from:

type: which type of reference to use (DEFAULT, INTERNAL, or EXTERNAL).

to:

type: which type of reference to use (DEFAULT, INTERNAL, INTERNAL1V1, INTERNAL2V56, or EXTERNAL).

July 11, 2010, at 12:04 AM by David A. Mellis - simplifying the explanation.
Changed lines 5-6 from:

Configures the reference voltage used for analog input. The analogRead() function will return 1023 for an input equal to the reference voltage. The options are:

to:

Configures the reference voltage used for analog input (i.e. the value used as the top of the input range). The options are:

Changed lines 20-35 from:

It is a good idea to connect external voltages to the AREF pin through a 5K resistor. This will prevent possible internal damage to the Atmega chip if analogReference() software settings are incompatible with the current hardware setup. Note that the resistor will alter the voltage that gets used as the reference because there is an internal 32K resistor on the AREF pin. The two act as a voltage divider, so, for example, 2.5V applied through the resistor will yield ~2.2V at the AREF pin.

Connecting external voltages through a resistor makes it possible to switch the AREF voltage on the fly, say from the 5 volt DEFAULT setting, to a 3.3 volt EXTERNAL setting (and applied voltage), without the hardware setup affecting either ADC configuration.

Use of the AREF pin

The voltage applied to the AREF pin directly governs the ADC and sets the voltage at which the ADC will report its highest reading, 1023. Lower voltages applied to ADC (analog) pins will be scaled proportionally, so at the DEFAULT setting (5 volt internal connection), 2.5 volts on an analog pin will report approximately 512.

The default configuration on all Arduino implementations is to have nothing connected externally to the AREF pin (Atmega pin 21). In this case the DEFAULT analogReference software setting connects the AVCC voltage, internally, to the AREF pin. This appears to be a low impedance connection (high current) and voltages, other than AVCC, applied (erroneously) to the AREF pin in the DEFAULT setting could damage the ATMEGA chip.

The AREF pin may also be connected internally to an (internal) 1.1 volt source (or 2.56 on the ATmega8) with analogReference(INTERNAL). With this setting voltages applied to the ADC (analog) pins that are at or above the reference will report 1023 when read with analogRead. Lower voltages will report proportional values, so 0.55 volts will report about 512.

The connection between the 1.1 volt source and the AREF pin is a very high impedance (low current) connection, so that reading the 1.1 (internally supplied) voltage at the AREF pin may only be done with a more expensive, high-impedance multimeter. An external voltage applied (erroneously) to AREF pin while using the INTERNAL setting will not damage the chip, but will totally override the 1.1 volt source, and ADC readings will be governed by the external voltage. It is still desirable to connect any external voltage to the AREF pin however, through a 5K resistor to avoid the problem cited above.

The correct software setting for using the AREF pin with an external voltage is analogReference(EXTERNAL). This disconnects both of the internal references and the voltage applied externally to the AREF pin sets the reference voltage for the ADC.

to:

If you're using an external reference voltage (applied to the AREF pin), you must set the analog reference to EXTERNAL before calling analogRead(). Otherwise, you will short together the active reference voltage (internally generated) and the AREF pin, possibly damaging the microcontroller on your Arduino board.

Alternatively, you can connect the external reference voltage to the AREF pin through a 5K resistor, allowing you to switch between external and internal reference voltages. Note that the resistor will alter the voltage that gets used as the reference because there is an internal 32K resistor on the AREF pin. The two act as a voltage divider, so, for example, 2.5V applied through the resistor will yield 2.5 * 32 / (32 + 5) = ~2.2V at the AREF pin.

April 02, 2010, at 05:26 AM by David A. Mellis -
Changed lines 7-8 from:
  • DEFAULT: the default analog reference of 5 volts.
  • INTERNAL: an built-in reference, equal to 1.1 volts on the ATmega168 and 2.56 volts on the ATmega8.
to:
  • DEFAULT: the default analog reference of 5 volts (on 5V Arduino boards) or 3.3 volts (on 3.3V Arduino boards)
  • INTERNAL: an built-in reference, equal to 1.1 volts on the ATmega168 or ATmega328 and 2.56 volts on the ATmega8.
October 01, 2009, at 06:03 PM by David A. Mellis -
Changed lines 20-21 from:

It is a good idea to connect external voltages to the AREF pin through a 5K resistor. This will prevent possible internal damage to the Atmega chip if analogReference() software settings are incompatible with the current hardware setup. Connecting external voltages through a resistor also make it possible to switch the AREF voltage on the fly, say from the 5 volt DEFAULT setting, to a 3.3 volt EXTERNAL setting (and applied voltage), without the hardware setup affecting either ADC configuration.

to:

It is a good idea to connect external voltages to the AREF pin through a 5K resistor. This will prevent possible internal damage to the Atmega chip if analogReference() software settings are incompatible with the current hardware setup. Note that the resistor will alter the voltage that gets used as the reference because there is an internal 32K resistor on the AREF pin. The two act as a voltage divider, so, for example, 2.5V applied through the resistor will yield ~2.2V at the AREF pin.

Connecting external voltages through a resistor makes it possible to switch the AREF voltage on the fly, say from the 5 volt DEFAULT setting, to a 3.3 volt EXTERNAL setting (and applied voltage), without the hardware setup affecting either ADC configuration.

Changed lines 28-31 from:

The default configuration on all Arduino implementations is to have nothing connected externally to the AREF pin (Atmega pin 21). In this case the DEFAULT analogReference software setting connects the AVCC voltage, internally, to the AREF pin. This appears to be a low impedance connection (high current) and voltages, other than AVCC, applied (erroneously) to the AREF pin in the DEFAULT setting could damage the ATMEGA chip. For this reason, connecting external voltages to the AREF pin through a 5K resistor is a good idea.

The AREF pin may also be connected internally to an (internal) 1.1 volt source with analogReference(INTERNAL). With this setting voltages applied to the ADC (analog) pins that are 1.1 volts (or higher) will report 1023, when read with analogRead. Lower voltages will report proportional values, so .55 volts will report about 512.

to:

The default configuration on all Arduino implementations is to have nothing connected externally to the AREF pin (Atmega pin 21). In this case the DEFAULT analogReference software setting connects the AVCC voltage, internally, to the AREF pin. This appears to be a low impedance connection (high current) and voltages, other than AVCC, applied (erroneously) to the AREF pin in the DEFAULT setting could damage the ATMEGA chip.

The AREF pin may also be connected internally to an (internal) 1.1 volt source (or 2.56 on the ATmega8) with analogReference(INTERNAL). With this setting voltages applied to the ADC (analog) pins that are at or above the reference will report 1023 when read with analogRead. Lower voltages will report proportional values, so 0.55 volts will report about 512.

Changed lines 39-40 from:
to:
May 11, 2008, at 06:58 PM by Paul Badger -
Changed lines 20-21 from:

It is a good idea to connect external voltages to the AREF pin through a 5K resistor. This will prevent possible internal damage to the Atmega chip if analogReference() software settings are incompatible with the current hardware setup.

to:

It is a good idea to connect external voltages to the AREF pin through a 5K resistor. This will prevent possible internal damage to the Atmega chip if analogReference() software settings are incompatible with the current hardware setup. Connecting external voltages through a resistor also make it possible to switch the AREF voltage on the fly, say from the 5 volt DEFAULT setting, to a 3.3 volt EXTERNAL setting (and applied voltage), without the hardware setup affecting either ADC configuration.

May 10, 2008, at 09:21 AM by David A. Mellis - this is the Arduino documentation.
Changed lines 26-27 from:

The default configuration on all Arduino and Freeduino implementations is to have nothing connected externally to the AREF pin (Atmega pin 21). In this case the DEFAULT analogReference software setting connects the AVCC voltage, internally, to the AREF pin. This appears to be a low impedance connection (high current) and voltages, other than AVCC, applied (erroneously) to the AREF pin in the DEFAULT setting could damage the ATMEGA chip. For this reason, connecting external voltages to the AREF pin through a 5K resistor is a good idea.

to:

The default configuration on all Arduino implementations is to have nothing connected externally to the AREF pin (Atmega pin 21). In this case the DEFAULT analogReference software setting connects the AVCC voltage, internally, to the AREF pin. This appears to be a low impedance connection (high current) and voltages, other than AVCC, applied (erroneously) to the AREF pin in the DEFAULT setting could damage the ATMEGA chip. For this reason, connecting external voltages to the AREF pin through a 5K resistor is a good idea.

May 10, 2008, at 09:00 AM by Paul Badger -
Changed lines 28-34 from:

The AREF pin may also be connected internally to an internal 1.1 volt source with analogReference(INTERNAL). With this setting voltages applied to the ADC (analog) pins that are 1.1 volts (or higher) will report 1023, when read with analogRead. Lower voltages will report proportional values, so .55 volts will report about 512.

The connection between the 1.1 volt source and the AREF pin is a very high impedance (low current) connection, so that reading the 1.1 (internally supplied) voltage at the AREF pin may only be done with a more expensive, high-impedance multimeter. An external voltage applied (erroneously) to AREF pin while using the INTERNAL setting will not damage the chip, but will totally override the 1.1 volt source, and ADC readings will be governed by the external voltage. It is still desirable to connect any external voltage to the AREF pin through a 5K resistor to avoid the problem cited above.

The correct software setting for using the AREF pin is analogReference(EXTERNAL). This disconnects both of the internal references and the voltage applied externally to the AREF pin sets the reference voltage for the ADC.

to:

The AREF pin may also be connected internally to an (internal) 1.1 volt source with analogReference(INTERNAL). With this setting voltages applied to the ADC (analog) pins that are 1.1 volts (or higher) will report 1023, when read with analogRead. Lower voltages will report proportional values, so .55 volts will report about 512.

The connection between the 1.1 volt source and the AREF pin is a very high impedance (low current) connection, so that reading the 1.1 (internally supplied) voltage at the AREF pin may only be done with a more expensive, high-impedance multimeter. An external voltage applied (erroneously) to AREF pin while using the INTERNAL setting will not damage the chip, but will totally override the 1.1 volt source, and ADC readings will be governed by the external voltage. It is still desirable to connect any external voltage to the AREF pin however, through a 5K resistor to avoid the problem cited above.

The correct software setting for using the AREF pin with an external voltage is analogReference(EXTERNAL). This disconnects both of the internal references and the voltage applied externally to the AREF pin sets the reference voltage for the ADC.

May 10, 2008, at 08:56 AM by Paul Badger -
Changed lines 26-27 from:

The default configuration on all Arduino and Freeduino implementations is to have nothing connected externally to the AREF pin (Atmega pin 21). In this case the DEFAULT analogReference software setting connects the AVCC voltage, internally, to the AREF pin. This appears to be a low impedance connection (high current) and voltages, other than AVCC, applied (erroneously) to AREF pin in the DEFAULT setting could damage the ATMEGA chip. For this reason, connecting external voltages to the AREF pin through a 5K resistor is a good idea.

to:

The default configuration on all Arduino and Freeduino implementations is to have nothing connected externally to the AREF pin (Atmega pin 21). In this case the DEFAULT analogReference software setting connects the AVCC voltage, internally, to the AREF pin. This appears to be a low impedance connection (high current) and voltages, other than AVCC, applied (erroneously) to the AREF pin in the DEFAULT setting could damage the ATMEGA chip. For this reason, connecting external voltages to the AREF pin through a 5K resistor is a good idea.

May 10, 2008, at 08:54 AM by Paul Badger -
Changed lines 26-27 from:

The default configuration on all Arduino and Freeduino implementations is to have nothing connected externally to the AREF pin (Atmega pin 21). In this case the DEFAULT analogReference software setting connects the AVCC voltage, internally, to the AREF pin. This appears to be a low impedance conncetion (high current) and voltages, other than AVCC, applied to AREF pin in the DEFAULT setting could damage the ATMEGA chip. For this reason, connecting external voltages to the AREF pin through a 5K resistor is a good idea.

to:

The default configuration on all Arduino and Freeduino implementations is to have nothing connected externally to the AREF pin (Atmega pin 21). In this case the DEFAULT analogReference software setting connects the AVCC voltage, internally, to the AREF pin. This appears to be a low impedance connection (high current) and voltages, other than AVCC, applied (erroneously) to AREF pin in the DEFAULT setting could damage the ATMEGA chip. For this reason, connecting external voltages to the AREF pin through a 5K resistor is a good idea.

Changed lines 30-32 from:

The connection between the 1.1 volt source and the AREF pin is a very high impedance (low current) connection, so that reading the 1.1 (internally supplied) voltage at the AREF pin may only be done with a more expensive, high-impedance multimeter. An external voltage applied to AREF pin in this setting will not damage the chip, but will totally override the 1.1 volt source, and ADC readings will be governed by the external voltage.

to:

The connection between the 1.1 volt source and the AREF pin is a very high impedance (low current) connection, so that reading the 1.1 (internally supplied) voltage at the AREF pin may only be done with a more expensive, high-impedance multimeter. An external voltage applied (erroneously) to AREF pin while using the INTERNAL setting will not damage the chip, but will totally override the 1.1 volt source, and ADC readings will be governed by the external voltage. It is still desirable to connect any external voltage to the AREF pin through a 5K resistor to avoid the problem cited above.

The correct software setting for using the AREF pin is analogReference(EXTERNAL). This disconnects both of the internal references and the voltage applied externally to the AREF pin sets the reference voltage for the ADC.

May 10, 2008, at 07:55 AM by Paul Badger -
Changed lines 24-32 from:

The voltage applied to the AREF pin directly governs the ADC and sets the voltage at which the ADC will report its highest reading, 1023. Lower voltages applied to ADC (analog) pins will be scaled proportionally, so 2.5 volts on an analog pin will report approximately 512.

The default configuration on all Arduino and Freeduino implementations is to have nothing connected externally to the AREF pin (Atmega pin 21). In this case the DEFAULT analogReference software setting connects the AVCC voltage, internally, to the AREF pin. This appears to be a low impedance conncetion (high current) and other voltages applied to AREF pin in the default setting could damage the ATMEGA chip.

The AREF pin may also be connected internally to an internal 1.1 volt source with analogReference(INTERNAL). With this setting voltages at the analog pins that are 1.1 volts (or higher) will report 1023, when read with analogRead. Lower voltages will report proportional values, so .55 volts will report about 512.

The connection between the 1.1 volt source and the AREF pin is a very high impedance (low current) connection, so that reading the (internal) voltage at the AREF pin may only be done with a more expensive, high-impedance multimeter. An external voltage applied to AREF pin in this setting will not damage the chip, but will totally override the 1.1 volt source, and the analog readings will be governed by the external voltage.

to:

The voltage applied to the AREF pin directly governs the ADC and sets the voltage at which the ADC will report its highest reading, 1023. Lower voltages applied to ADC (analog) pins will be scaled proportionally, so at the DEFAULT setting (5 volt internal connection), 2.5 volts on an analog pin will report approximately 512.

The default configuration on all Arduino and Freeduino implementations is to have nothing connected externally to the AREF pin (Atmega pin 21). In this case the DEFAULT analogReference software setting connects the AVCC voltage, internally, to the AREF pin. This appears to be a low impedance conncetion (high current) and voltages, other than AVCC, applied to AREF pin in the DEFAULT setting could damage the ATMEGA chip. For this reason, connecting external voltages to the AREF pin through a 5K resistor is a good idea.

The AREF pin may also be connected internally to an internal 1.1 volt source with analogReference(INTERNAL). With this setting voltages applied to the ADC (analog) pins that are 1.1 volts (or higher) will report 1023, when read with analogRead. Lower voltages will report proportional values, so .55 volts will report about 512.

The connection between the 1.1 volt source and the AREF pin is a very high impedance (low current) connection, so that reading the 1.1 (internally supplied) voltage at the AREF pin may only be done with a more expensive, high-impedance multimeter. An external voltage applied to AREF pin in this setting will not damage the chip, but will totally override the 1.1 volt source, and ADC readings will be governed by the external voltage.

May 10, 2008, at 07:47 AM by Paul Badger -
Added lines 18-21:

Warning

It is a good idea to connect external voltages to the AREF pin through a 5K resistor. This will prevent possible internal damage to the Atmega chip if analogReference() software settings are incompatible with the current hardware setup.

Changed lines 26-27 from:

The default configuration on all Arduino and Freeduino implementations is to have nothing connected externally to the AREF pin (Atmega pin 21). In this case the DEFAULT analogReference software setting connects the AVCC voltage, internally, to the AREF pin.

to:

The default configuration on all Arduino and Freeduino implementations is to have nothing connected externally to the AREF pin (Atmega pin 21). In this case the DEFAULT analogReference software setting connects the AVCC voltage, internally, to the AREF pin. This appears to be a low impedance conncetion (high current) and other voltages applied to AREF pin in the default setting could damage the ATMEGA chip.

Changed lines 30-36 from:

The connection between the both of the internal connections and the AREF pin is a very high resistance (impedance) connection, so that reading the voltage at the AREF pin may only be done with a more expensive high impedance multimeter.

A voltage connected to the AREF pin, externally, will override either of the

to:

The connection between the 1.1 volt source and the AREF pin is a very high impedance (low current) connection, so that reading the (internal) voltage at the AREF pin may only be done with a more expensive, high-impedance multimeter. An external voltage applied to AREF pin in this setting will not damage the chip, but will totally override the 1.1 volt source, and the analog readings will be governed by the external voltage.

Added line 34:
May 10, 2008, at 07:28 AM by Paul Badger -
Changed lines 18-21 from:

Warning

It is a good idea to connect the external analog reference voltage to the AREF pin through a 1k resistor. This will prevent inadvertent short circuits caused because the pin defaults to an internal connection to 5 volts. This is a low impedance connection meaning that a short circuit to another voltage will draw significant current and possibly damage the analog system in the chip.

to:

Use of the AREF pin

The voltage applied to the AREF pin directly governs the ADC and sets the voltage at which the ADC will report its highest reading, 1023. Lower voltages applied to ADC (analog) pins will be scaled proportionally, so 2.5 volts on an analog pin will report approximately 512.

The default configuration on all Arduino and Freeduino implementations is to have nothing connected externally to the AREF pin (Atmega pin 21). In this case the DEFAULT analogReference software setting connects the AVCC voltage, internally, to the AREF pin.

The AREF pin may also be connected internally to an internal 1.1 volt source with analogReference(INTERNAL). With this setting voltages at the analog pins that are 1.1 volts (or higher) will report 1023, when read with analogRead. Lower voltages will report proportional values, so .55 volts will report about 512.

The connection between the both of the internal connections and the AREF pin is a very high resistance (impedance) connection, so that reading the voltage at the AREF pin may only be done with a more expensive high impedance multimeter.

A voltage connected to the AREF pin, externally, will override either of the

April 26, 2008, at 05:55 AM by Paul Badger -
Changed lines 20-21 from:

It is a good idea to connect the external analog reference voltage to the AREF pin through a 5k resistor. This will prevent inadvertent short circuits caused because the pin defaults to an internal connection to 5 volts. This is a low impedance connection meaning that a short circuit to another voltage will draw significant current and possibly damage the analog system in the chip.

to:

It is a good idea to connect the external analog reference voltage to the AREF pin through a 1k resistor. This will prevent inadvertent short circuits caused because the pin defaults to an internal connection to 5 volts. This is a low impedance connection meaning that a short circuit to another voltage will draw significant current and possibly damage the analog system in the chip.

April 26, 2008, at 05:54 AM by Paul Badger -
Changed lines 20-21 from:

It is a good idea to connect the external analog reference voltage to the AREF pin through a 1k resistor. This will prevent inadvertent short circuits caused because the pin defaults to an internal connection to 5 volts. This is a low impedance connection meaning that a short circuit to another voltage will draw significant current and possibly damage the analog system in the chip.

to:

It is a good idea to connect the external analog reference voltage to the AREF pin through a 5k resistor. This will prevent inadvertent short circuits caused because the pin defaults to an internal connection to 5 volts. This is a low impedance connection meaning that a short circuit to another voltage will draw significant current and possibly damage the analog system in the chip.

April 26, 2008, at 05:52 AM by Paul Badger - This is a better solution than a code fix - I still need to check data sheet for details
Changed lines 20-21 from:

Be sure to call analogReference() with the value that corresponds to the physical configuration of your board. In particular, if you have a voltage other than 5V connected to the AREF pin, you must call analogReference(EXTERNAL) before any calls to analogRead(). If the analog reference is at the default value of 5V or at the internal reference, that voltage will be applied to the AREF pin, creating a short with the externally-supplied voltage.

to:

It is a good idea to connect the external analog reference voltage to the AREF pin through a 1k resistor. This will prevent inadvertent short circuits caused because the pin defaults to an internal connection to 5 volts. This is a low impedance connection meaning that a short circuit to another voltage will draw significant current and possibly damage the analog system in the chip.

April 18, 2008, at 08:23 PM by David A. Mellis -
Changed lines 18-19 from:

Example

to:

Warning

Be sure to call analogReference() with the value that corresponds to the physical configuration of your board. In particular, if you have a voltage other than 5V connected to the AREF pin, you must call analogReference(EXTERNAL) before any calls to analogRead(). If the analog reference is at the default value of 5V or at the internal reference, that voltage will be applied to the AREF pin, creating a short with the externally-supplied voltage.

March 29, 2008, at 12:13 AM by David A. Mellis -
Changed lines 1-2 from:

void analogReference(type)

to:

analogReference(type)

March 29, 2008, at 12:12 AM by David A. Mellis -
Added lines 1-23:

void analogReference(type)

Description

Configures the reference voltage used for analog input. The analogRead() function will return 1023 for an input equal to the reference voltage. The options are:

  • DEFAULT: the default analog reference of 5 volts.
  • INTERNAL: an built-in reference, equal to 1.1 volts on the ATmega168 and 2.56 volts on the ATmega8.
  • EXTERNAL: the voltage applied to the AREF pin is used as the reference.

Parameters

type: which type of reference to use (DEFAULT, INTERNAL, or EXTERNAL).

Returns

None.

Example

See also

Share