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.

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.

  • 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. – Gerben Jul 22 '15 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. – Russell McMahon Jul 22 '15 at 19:17
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.