What will happen, if I try to measure voltage higher than ARef? For example, my ref is 3.3V, and I try to measure 4.5V. Will it damage adc?
The datasheet of the Atmega328P does not give a direct answer to this, but
Single ended channels that exceed V REF will result in codes close to 0x3FF.
(Datasheet Chapter 24.5.2)
sounds, as it would not destroy the ADC, but only result in a value very close to the maximum. I also found another side, where this is also stated. They linked to the Arduino forum, where a similar question is handled in this thread.
So all in all it should be save to provide more than the reference voltage at the ADC pins, as long as it does not exceed the supply voltage (for the UNO 5V).
As Majenko pointed out in his answer, the datasheet states, that it is safe to provide VCC+0.5V at any pin (except for reset). I just wasn't sure, if this can easily be applied to this special hardware, but it seems, that it can.
Contrary to what @chrisl says, the datasheet does give a direct answer to this:
- Voltage on any Pin except RESET with respect to Ground: -0.5V to VCC+0.5V
So when running at 5V anything up to 5.5V is safe - regardless of what VRef has fed into it.
The VRef just sets the range of the ADC when comparing the incoming voltage to a DAC generated voltage, so anything over the VRef voltage will just read as "max" (1023).