Detecting reverse battery voltage measurement on A0

All,

I'm measuring a battery voltage via a voltage divider feeding analog pin A0 on a NANO. The unit is powered by it's own source. All works fine provided the 12 volt battery is connected correctly. However if the user connects the battery in reverse, i'll have +12 volts at GND, and 0 at A0.

I'd like to 1) have reverse polarity protection and 2) ability to turn on a red LED to indicate reverse connection.

I'm stuck, anyone know?

Most people use a diode for reverse voltage protection. That will require recalibrating the voltage divider.
Easy enough to add a "reversed battery" LED, with its own reverse voltage protection and current limit resistor.

reverse_batt.png

jremington, thanks for the quick response. I was thinking some diodes would do but didn't know to use them in this configuration with the LED. Any specific diodes? Schottkeys, or fast recovery work OK? I'm not really worrying about power loss.

Again, really appreciate your help!

Try googling "Full Wave Bridge Rectifier" .
You need to put one between your circuit and the power supply.
These are designed to take an Alternating input (+ - , - +) and output it as + -.
Then use D3 , D2 & R3 from the prev circuit and fit it before the rectifier.
This will warn you of reverse polarity and rectify the reversed voltage to the correct polarity.

Daz.
Ps. Dont forget to allow for voltage drop of two diodes between battery and Arduino.

No, don't use a diode or rectifier in series with the voltage divider.
That will add non-linearity and temp dependency to your divider.

If the resistors of the divider (R2) are high enough, then you don't need protection.
The internal pin protection can absorb small reverse currents.
If you HAVE to use a diode, then connect a schottky diode between pin and ground, cathode to pin.
Use a low leakage one, because it still will introduce some temp dependency.

What you should do is calculate the divider for 1volt@12volt in.
Then R2 can be much larger, for lower fault currents.
R1:R2 can be 10k:120k (-30uA fault current if -12volt).
That ratio will also give you 5x more protection for positive voltages.

You now must use the internal 1.1volt Aref in setup().
analogReference(INTERNAL);

That itself has several other benefits.
Leo..

Any specific diodes?

Any diodes. 1N4148 is fine. Use 1K for the LED current limit resistor.

Using a diode in series with the divider will introduce an additional ~0.6 V drop in the voltage divider, plus a small, but (for the purpose of monitoring a 12V battery) negligible temperature and voltage dependence.

Why use diodes if you don't have to.
A 10k:120k divider and 1.1volt Aref works fine, is potentially more stable than default Aref, and should protect to more than 100volt AC with minimal fault current.
Leo..

jremington:
Most people use a diode for reverse voltage protection. That will require recalibrating the voltage divider.
Easy enough to add a "reversed battery" LED, with its own reverse voltage protection and current limit resistor.

reverse_batt.png

I haven't tried it yet...... but wondering if a spin-off of the above might work.... such as replace D1 with a normally-closed relay .... and replace D2 and the LED D3 with a 1 ohm resistor. Then use a pnp bjt to monitor current in that 1 ohm resistor. And depending on what R3 is set to, could make the pnp transistor turn on and drive some other transistor (eg. a power transistor) - having the purpose of open-circuiting that normally-closed relay. And that relay can get its power from the 'reversed' battery source. Basically, if reverse polarity battery is connected, then the relay disconnects the battery from the arduino side of things.

On the other hand, somebody that doesn't connect the battery properly (with the correct polarity) shouldn't be allowed to connect the battery - especially if clear symbols and signs etc are provided with the equipment. But also, if somebody doesn't connect the battery with correct polarity and damages something, then they'll likely keep this in mind next time. But if the same thing happens next time..... then they can fix it themselves.

You could always try a N channel Mosfet with the LED circuit above to give visual, Basically if you connect it the wrong way round the unit will turn on as it keeps the GND disconnected, You could do the same and use a P channel Fet in the high side, I found it in a design was thinking having a look it into for one of my projects as you should get very low voltage drop if any ?

Capture.PNG

Many opinions here...

It depends how accurate the battery voltage has to be measured and for which voltages the input has to be protected. The accuracy depens also on the temperate. If it is always at room temperature, and not powered with only a USB cable, then the internal voltage reference can be used and the calculations can be tuned to achieve a good accuracy.

If ±200mV is okay, then diodes can probably be used. I think that the internal voltage reference has to be used.

If there is a very good 5.00V power supply, then the default 5V can be used as reference.

It is also possible to measure a full range from -15V to +15V, with a three-resistor voltage divider. With some luck and tuning that might also be ±200mV accurate. Since the 0V level is shifted, the circuit does not automatically default to 0V with nothing connected and as a result the outcome of the calculation can be a small voltage when nothing is connected.

If ±50mV accuracy is needed, then the internal voltage reference can be used, or an extra external reference.
Then with no diodes in the voltage divider as Wawa wrote. But I would not use Schottky diodes, but normal 1N4148 clamping diodes to GND and VCC with an extra 1k resistor to the analog input (to protect the internal clamping diodes).
To measure reverse polarity a second circuit to a second analog input could be used.

Don't forget to use the average of a number of samples. That helps a lot.

KrisKasprzak:
All,

I'm measuring a battery voltage via a voltage divider feeding analog pin A0 on a NANO. The unit is powered by it's own source. All works fine provided the 12 volt battery is connected correctly. However if the user connects the battery in reverse, i'll have +12 volts at GND, and 0 at A0.

I'd like to 1) have reverse polarity protection and 2) ability to turn on a red LED to indicate reverse connection.

I'm stuck, anyone know?

Please note the answer given about the full wave rectifier was based on.

"The unit is powered by it's own source. All works fine provided the 12 volt battery is connected correctly. However if the user connects the battery in reverse, i'll have +12 volts at GND, and 0 at A0. "

Which i took to kean the supply to the whole Arduino would be reversed! Not just A0.
I dont think it will like that, could be wrong.
And please note i mentioned fitting the voltage divider before the bridge so no voltage loss from the bridge, you would of course have to factor in any loss to VCC idpf any but to go from 12v through the bridge to the Arduino ext input should actually help by dropping the volts from 12 to around 10.8 reducing the load on the onboard regulator.

Daz

Steveiboy:
Capture.PNG

Nice one stevei ....... I assume the battery is connected between the '+V IN' terminal and gnd. If the battery is reverse polarity, then will that polarised capacitor C12 be ok too?

Yeah the top line is v+ bottom 0v, I’ve not tested it yet but this was taken out of the IMAX b6 charger clone and I have got one of these and connected the input battery wrong way round a few times an it’s all good, yes the C12 will be ok because if it’s connected the wrong way round the GND circuit will not be connected the other side of the Fet