So I want to use a reference voltage of 3.3 volts for my project. It looks pretty simple, connect the 3.3 volt source on my Arduino to pin AREF, issue the command analogRefernce(EXTERNAL) and I am in business.
But wait…
The analogReference() documentation has the following ominous and cryptic statement:
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.
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.
This sounds dangerous.
I understand very little about circuit design so I cannot make sense of the statement, “short together the active reference voltate (internally generated) and the AREF pin”. But fortunately they provide a safe alternative, add a 5k ohm resistor.
Many questions come to mind.
- What is special about a 5k ohm resistor?
- If I put a 5k ohm resistor between the 3.3 volt pin and AREF my reference voltage is 2.85 volts. What happens if I try to measure 3.3 volts?
- Where does the 32k ohm number come in?
I think I have figured it out.
If I attach an ohmmeter to AREF and ground I get the following readings:
- At power up: 32.83k ohm
- After analogReference(DEFAULT) and analogRead() commands: 0 ohms
- After analogReference(EXTERNAL) and analogRead() commands: 32.83k ohm.
So I have concluded the following:
- When analogReference() function is called nothing happens until the next analogRead() command.
- If the external reference voltage is not used the AREF pin is connected to ground. If a voltage source is connected to AREF then you have a ‘blue smoke’ situation.
- There is an internal resistance of ~32k ohm between AREF and ground.
- There is nothing special about 5k ohm. This was a resistance deemed sufficient to eliminate a short circuit situation.
- The documentation is confusing.
For me this means that to get a safe 3.3 volt reference I need to use the 5 volt source and employ a voltage divider. A 16.5k ohm resistor between the 5 volt source and AREF will provide me with a 3.3 volt reference. I have checked this with my meter to make sure it is correct.
Of course there are a few caveats to add:
- If the Arduino source voltage is less than 5 volts then you will see less than 5 volts on the 5 volt pin. When connected to the USB port you can expect a bit less than 5 volts. On my computer I measure 4.95 volts.
- If you switch reference voltages from internal to external it will take a few analogRead() commands before the voltage settles down. I guess there is a capacitor involved somewhere to filter out noise and it will take a bit of time for it to discharge.