5v or 3.3v to analog input

I would like to know something.. what would happen if I connect a 5vpin or a 3.3vpin to a analog input.. it will break the arduino?

I would like to know something.. what would happen if I connect a 5vpin or a 3.3vpin to a analog input.. it will break the arduino?

WHICH arduino ?

raschemmel:
WHICH arduino ?

Arduino Mega 2560

No. The Mega analog input is rated for up to 5V:

The Mega 2560 has 16 analog inputs, each of which provide 10 bits of resolution (i.e. 1024 different values). By default they measure from ground to 5 volts, though is it possible to change the upper end of their range using the AREF pin and analogReference() function.

Mega2560 specs

raschemmel:
No. The Mega analog input is rated for up to 5V

True, but to be precise it's VCC +0.5volt, so no more than 5.5volt if the Arduino is on and the 5volt rail is 5volt.
It also means max 0.5volt if the Arduino is off.
So where is that 5volt or 3.3volt signal coming from.
Give us the whole story.
Leo..

Wawa:
True, but to be precise it's VCC +0.5volt, so no more than 5.5volt if the Arduino is on and the 5volt rail is 5volt.
It also means max 0.5volt if the Arduino is off.
So where is that 5volt or 3.3volt signal coming from.
Give us the whole story.
Leo..

well.. the signal is coming from the 5vpin or 3.3v of the same arduino.. ^^U

well.. the signal is coming from the 5vpin or 3.3v of the same arduino.. ^^U

In that case, it's 100% safe.

....And, it's 100% useless to connect the 5V pin because it should read always 1023 (or very close to 1023) and since the ADC reference is Vcc* it will continue to read 1023 if the voltage drops.

It might be useful to monitor the 3.3V pin if there's some reason the 3.3V line isn't "holding-up".

*There is a built-in optional 1.1V reference and with a voltage divider (2 resistors) it is possible to monitor/measure the Arduino's 5V supply. (Or, you can use an external reference.)

DVDdoug:
....And, it's 100% useless to connect the 5V pin because it should read always 1023 (or very close to 1023) and since the ADC reference is Vcc* it will continue to read 1023 if the voltage drops.

*There is a built-in optional 1.1V reference and with a voltage divider (2 resistors) it is possible to monitor/measure the Arduino's 5V supply. (Or, you can use an external reference.)

5volt/0volt on a pin is not exactly 5volt/0volt if the pin is sourcing/sinking a load.
So measuring it COULD be usefull.

We don't know WHY OP is asking this.
If it's to measure Arduino's supply, it's indeed useless.
XY problem.
Leo..

Wawa:
5volt/0volt on a pin is not exactly 5volt/0volt if the pin is sourcing/sinking a load.
So measuring it COULD be usefull.

We don't know WHY OP is asking this.
If it's to measure Arduino's supply, it's indeed useless.
XY problem.
Leo..

Well.. it was just a test.. what i'm going to do now.. is take from vin the voltage that i'm recieving and plug it into an Analog pin... i'm converting 12v into 5v.. externally.. I was hoping to know if everything is going to be ok, or if i have to take any measure before doing it?

12V will instantly destroy the Arduino whatever pin you connect it too, so you have to use a
voltage divider if trying to measure voltages outside the permissable range. Over-voltage
damage is instant and irreparable, so always take great care once you have 12V around.

MarkT:
12V will instantly destroy the Arduino whatever pin you connect it too, so you have to use a
voltage divider if trying to measure voltages outside the permissable range. Over-voltage
damage is instant and irreparable, so always take great care once you have 12V around.

Wow that would be awesome.. can you explain me.. what should I do to make a voltage divider?? I have a 12V battery with 20aH..

Wow that would be awesome

What, destroying it instantly or making a voltage divider ?

Wawa:
True, but to be precise it's VCC +0.5volt, so no more than 5.5volt if the Arduino is on and the 5volt rail is 5volt.
It also means max 0.5volt if the Arduino is off.
So where is that 5volt or 3.3volt signal coming from.
Give us the whole story.
Leo..

To be more precise, as datasheet says, the analog input limit is whatever you use for Aref, not related to supply voltage.

Ciao, Ale.

RazielReaver:
what i'm going to do now.. is take from vin the voltage that i'm recieving and plug it into an Analog pin...

i'm converting 12v into 5v.. externally..

So you're converting 12v into 5v externally with some other device like a buck module.

What does any of that have to do with Vin? What do you even mean "take from vin the voltage"?

If you want to measure the output of your external 12v to 5v device, use a multimeter.

I just picked up on this:-

is take from vin the voltage that i'm recieving and plug it into an Analog pin... i'm converting 12v into 5v.. externally

I hope you're not applying the externally-regulated +5V to the Vin pin? You can't do that, because the ATMega2560 won't actually 'see' +5V due to the voltage drop across the regulator. Then if you connect that 5V to an analogue input pin, you will be exceeding the upper limit. If you're connecting an external +5V, you must connect it to the +5V pin.

I might be wrong, but just thought I'd better mention it. It wouldn't be the first time someone has done this.

And if you are connecting it to +5V, you still can't measure it accurately at the Vin pin. There will be a voltage drop across the regulator's internal protection diode.

ilguargua:
To be more precise, as datasheet says, the analog input limit is whatever you use for Aref, not related to supply voltage.

Ciao, Ale.

Wrong.
You can connect the analogue input to any voltage up to the chip's supply voltage.
If the voltage is above the reference voltage all that happens is that you get a reading of 1023, or a "full house" as it is known.

So this parameter (Vin) indicates just the max measurable voltage, not the absolute maximum?

Ciao, Ale.

ilguargua:
So this parameter (Vin) indicates just the max measurable voltage, not the absolute maximum?
Ciao, Ale.

Yes. From Section 26.5.2 of the ATMega2560 datasheet:-

The reference voltage for the ADC (VREF) indicates the conversion range for the ADC. Single ended channels that exceed VREF will result in codes close to 0x3FF.

And at the beginning of Section 26.1, under "Features":-

0V - VCC ADC Input Voltage Range

This is how I see it. Please correct me if it's wrong.

VCC is the power supply of the board/chipset, and is normally about 5volt for an Uno/Mega.
The voltage that you can safely connect to a pin has to be within the window of GND-VCC, but 0.5volt outside that range is allowed. So GND -0.5volt to VCC +0.5volt.
So true maximum voltage on a pin is depends on VCC.
VCC might be 4.75volt on USB, or 5,2volt on external power.

The table lists AVcc. The reference voltage for the A/D converter.
That has to be within a narrower window of GND -0.3volt and VCC +0.3volt.
Normally nothing to worry about, because the chip connects Aref by default internally to VCC.
You can however use/switch to an external reference voltage. Then that safe window is important.

Vin on that table is the useable range of the A/D. GND to Aref gives 0-1023.
Aref is VCC by default, so 0volt input gives an A/D value of zero, and VCC (whatever that is) gives 1023.
So if default Aref is changed to the internal 1.1volt bandgap Aref, and it happens to be 1.075volt, then 1.075volt and higher gives an A/D value of 1023.

Don't confuse Vin on that table with the V-in power pin.
The V-in pin is the input of the voltage regulator, and needs to be >6.6volt for the onboard regulator to produce a stable 5volt.

OP wanted to measure a 12volt battery. That can be done with a ~1:13 voltage divider.
~14volt dropped to ~1volt can than be measured with the more stable internal ~1.1volt bandgap Aref.
Leo..

Wawa:
This is how I see it. Please correct me if it's wrong.

VCC is the power supply of the board/chipset, and is normally about 5volt for an Uno/Mega.
The voltage that you can safely connect to a pin has to be within the window of GND-VCC, but 0.5volt outside that range is allowed. So GND -0.5volt to VCC +0.5volt.
So true maximum voltage on a pin is depends on VCC.
VCC might be 4.75volt on USB, or 5,2volt on external power.

The table lists AVcc. The reference voltage for the A/D converter.
That has to be within a narrower window of GND -0.3volt and VCC +0.3volt.
Normally nothing to worry about, because the chip connects Aref by default internally to VCC.
You can however use/switch to an external reference voltage. Then that safe window is important.

Vin on that table is the useable range of the A/D. GND to Aref gives 0-1023.
Aref is VCC by default, so 0volt input gives an A/D value of zero, and VCC (whatever that is) gives 1023.
So if default Aref is changed to the internal 1.1volt bandgap Aref, and it happens to be 1.075volt, then 1.075volt and higher gives an A/D value of 1023.

Don't confuse Vin on that table with the V-in power pin.
The V-in pin is the input of the voltage regulator, and needs to be >6.6volt for the onboard regulator to produce a stable 5volt.

OP wanted to measure a 12volt battery. That can be done with a ~1:13 voltage divider.
~14volt dropped to ~1volt can than be measured with the more stable internal ~1.1volt bandgap Aref.
Leo..

Sounds pretty good to me, except for one thing, a typo I think:-

The table lists AVcc. The reference voltage for the A/D converter.

AVcc is the supply pin for the ADC. AREF is the reference.
Edit: But I guess AVcc is also technically the reference, since it supplies the voltage to the reference unless the internal references or an external voltage reference are used.