# Measuring voltage from -12 to +12 VDC

I'm making a -12 to +12V DC regulated power supply, on which I want to measure voltage and current with Arduino (through a voltage divider, of course).

I'm not sure, how to either detect nor measure negative voltage. I could "detect" it via a Schottky diode, but I'd get about 0.3V voltage drop, but that's not what I want, because any voltage between 0.0V and -0.3V wouldn't be measured. I want also to be able to measure positive and negative voltage on the same Arduino analog input pin.

And furthermore, how to measure current, flowing into both ways? (not an AC current, but will change during operation).

I will make additional PCB for this application, so size and number of components isn't important at all.

• What magnitude of current do you need to measure? Microamps? Amps? May 2, 2017 at 15:17
• We're discussing range from 0 to 5A, I'd really like to measure it on at least 2 digits, while measuring amperes, and if the current would be <1A, I'd like to show it in miliAmps. May 2, 2017 at 20:58

## Measuring voltage

Use the following interfacing circuit for measuring voltage:

Resistors R1, R2, R3 (1% tolerance or better recommended) will map the voltage input range (-12 to +12V DC) to an output range that can be read will the Arduino ADC (+0.5 to +4.5V DC, in order to have some slack from the top and bottom end of the ADC range). The actual theoretical input range would be -15 to 15V DC.

The optional (but recommended) Schottky diodes D1 and D2 will protect the Arduino analog IN pin that you connect to Vout from any input under/overvoltage outside the -15 to +15V DC range.

This is the resulting input to output voltage translation curve:

## Measuring current

For measuring current, use a current shunt (i.e., a very low resistance resistor, in the milliohm range) and measure the voltage drop on it via a high input impedance differential amplifier, then sample the output of the amp with the Arduino ADC.

simulate this circuit – Schematic created using CircuitLab

• The Schottky diodes have too much leakage current, the measured voltage will be less accurate. It is better to use 1N4148 diodes with a extra resistor to the Arduino pin (100 ohm to 1k). The diodes are probably not needed at all, since it is allowed to push 1mA into a pin or pull 1mA from a pin. It is therefor safe to apply larger voltages than -15 or 15v.
– Jot
May 2, 2017 at 18:09
• With only those three resistors with those values (20k, 6.65k, 10k) the input may be +/- 40V.
– Jot
May 2, 2017 at 18:15
• I have already selected the values of R1, R2 and R3 so that the leakage of the 1N5819 doesn't distort the measurement. The simulated curve reflects that. The diodes are optional and are there just for protection purposes, it's up to the OP to get rid of them, as I said myself. May 2, 2017 at 18:18
• My leakage numbers are wrong, I found graph in the ST datasheet. The typical leakage according to that graph are can be 1µA to 0.3mA (at 100°C).
– Jot
May 2, 2017 at 18:30
• Connectivity: Vin -> the -12/12V voltage you want to measure; Vs -> 5V from Arduino of from a stable, accurate voltage reference; Vout -> any analog input from Arduino. May 3, 2017 at 13:13