Aref: voltage changes as I connect the pin?

Hi

I am trying to use Aref as 2.5V on Arduino Leonardo.

I obtain 2.5V with a simple potential divider from Arduino power and ground. For some weird reason the 2.5V become around 1 V once the pin is connected to the AREF and the Arduino switched on.

I tested it in many ways, especiallly: if I leave the reference to 5V and connect the 2.5V pin to an analogue pin, it still reads 2.5V.

Has this happened to anyone or anyone has a clue what is going on here????

Thanks,
Cristina

The impedance of your voltage divider is too high. That means the current Aref is sucking is dragging your voltage down.
Try using a voltage referance chip or follow the resistor dividor with an emitter follower transistor.

You need to make sure you set the analog reference to EXTERNAL in your setup(). Otherwise you may run the risk of shorting power sources.
From the Atmel reference:

If the user has a fixed voltage source connected to the AREF pin, the user may not use the other
reference voltage options in the application, as they will be shorted to the external voltage.

If you don't set the analog reference then it will default to the internal AVCC source.

So you should have this in your sketch.

void setup()
{
  analogReference(EXTERNAL); //  AREF to external source.
}

Voltage dividers are not very stable for a reference source.
Alternatively you can leave the AREF pin unconnected and use the internal 2.56v (32U4) reference source.

void setup()
{
  analogReference(INTERNAL); //  AREF to internal 2.56v source
}