0

If I connect a 12V / 12V+ battery to the arduino (uno) analog, will it be damaged ? What if I connect 230-240V to it ? Don't worry I haven't tried it yet. :D

Thanks in advance.

asked Jul 22, 2015 at 14:28

2 Answers 2

1

Yes, it will be damaged. Especially if you connect mains direct to it.

The Arduino is designed to take up to 5V on any of its IO pins. Any more than that is asking for trouble. A slight amount above (as in say 5.5V) is usually tolerated OK, but anything more than that WILL cause irreparable damage.

And with mains, maybe even death.

For low DC voltages, like +12V, you can use a voltage divider to reduce the voltage to a 0-5V range.

For mains you will need to first reduce it down massively to a safe level (for example through a transformer) then re-scale and adjust it from there. Note that mains is AC not DC so it has a negative value of voltage as well, so you will either need to rectify and smooth it to create a DC voltage or, if you are interested in the waveform itself, reduce the voltage even more and add a DC offset into it to move the mid-point of the AC waveform up to around 2.5V.

answered Jul 22, 2015 at 14:44
2
  • The inputs have clamping diodes, so you can put more that 5.5v on them, but you have to limit the current of the diodes will burn up. Adding a high value resistor between the higher voltage and input will do this. However, every voltage higher than 5v will give the same analog value as 5v does. Commented Jul 22, 2015 at 15:39
  • 1
    @Gerben More than 5.5V violates the absolute maximum ratings. Lack of Death is not guaranteed. . > 5V when operating violates the operating conditions - walking funny until powered off and on again may happen. Commented Jul 22, 2015 at 19:17
2

For the 12 V battery, let's assume it might get up to 15 to 20 V when charging, so we need a voltage divider to divide that down.

Voltage divider

The zener diode is there to clamp the input to no more than 5.1 V in case of spikes or other damaging things on the input.

The voltage divider will divide down to 25% of the input, ie.

output = R2 / (R1 + R2) = 10 / (30 + 10) = 0.25

So now if you measure 5 V on the analog input you know you have 20 V on the battery. Thus you can scale your calculations appropriately.

(A more common value would be a 33 k resistor, in which case redo the calculation and scale accordingly).


For 240 V I strongly advise against trying something like that with bigger resistors. For one thing, 240 V RMS will have 240 * sqrt (2) = 340 V peak to peak. And that is both negative and positive.

A suitable approach would be to run through a small transformer, which will reduce the voltage and also isolate you from (almost) certain death.

In addition to that you would need to rectify the resulting voltage (say, 12 V) so that you don't put negative voltages into your input pin. And on top of that filter it so smooth out the peaks and troughs.

answered Jul 22, 2015 at 21:46

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.