 # Voltage Divider with Zener Protection Diode - Automotive Application

Hi All,

I’m looking to measure the voltage on an automotive electrical system using the ADC on an Arduino. I’d expect voltages up to around 18 volts from the alternator during charging (probably a bit less, but I’d prefer to be safe), but high transient voltages are possible.

I understand I can use a voltage divider to reduce the voltage to 5v or less, and that a zener diode can be added per the attached schematic to provide some protection against over voltage conditions.

What I don’t understand is how I go about calculating/determining the impact of the zener diode on the divider, and, therefore, the values needed for R1 and R2. How is this done, or is there some better solution? The calculation is pretty simple. If 18V is the maximum voltage from the alternator, you must be expecting a value of 5V at the ADC input i.e. the max arduino input or a 10 bit ADC value of 1023. So use the equation:

vout= vin*(R2)/(R2+R1). So in your case it'll be. 5V=18V*(R2)/(R2+R1). Now as a safety measure you can add a 5.1V zener diode across R2 resistor to ensure that the voltage across the resistor does not rise above 5.1V. The zener diode will breakdown and prevent any increase in voltage beyond 5.1V.

Thanks for that. So, if I’m at less than the breakdown voltage, the diode presents basically no load on the circuit?

Looking at the data sheet for a 1N4733A from Fairchild, the min Zener voltage is listed as 4.845 volts. Does that mean that I should design my voltage dividier such that the maximum expected input will produce less than 4.8v across R2, ensuring the Zener won’t break down within my measured range?

https://www.fairchildsemi.com/datasheets/1N/1N4733A.pdf

Looking at the data sheet for a 1N4733A from Fairchild, the min Zener voltage is listed as 4.845 volts. Does that mean that I should design my voltage dividier such that the maximum expected input will produce less than 4.8v across R2, ensuring the Zener won’t break down within my measured range?

As long as there is series resistance, there’s nothing wrong with some current through the Zener. 10V across 1K would be 10mA, and 10mA at 5V is 50mW. So, the Zener would be working well within it’s range.

The “breakdown” voltage is where the Zener switches-on and does it’s thing. Below breakdown, it’s essentially not in the circuit. At breakdown, it’s limiting the voltage, which is it’s purpose. If you never hit the breakdown voltage, it may as well not be there.

I’d design the voltage divider for 12V or 14.4V or whatever the “nominal” voltage is, and then use the Zener for anything “unexpected”. If you need to measure 18V, then the voltage divider should be designed for that, and make sure the Zener doesn’t kick-in until you exceed whatever voltage you want to measure accurately.

Alternatively, you can use a regular diode (or a Schottky diode) connected “backwards” to the Arduino’s 5V regulated power supply. [u]This page[/u] shows the Zener method, and another method with two regular diodes to protect against excessive positive voltages, or negative voltages. (I’ve used the regular-diode method.)

In any case, you need at least one resistor to limit the current through the protection diode(s) and you can use either method with a voltage divider (2 resistors).

A zener diode will leak current. Since I would prefer high values for the voltage divider (something like 33k and 10k) a zener diode will it make impossible to read the voltage accurate.
To protect the Arduino, you can use clamping diodes after the voltage divider. Just simple 1N4148 to GND and 5V. An extera resistor of 1k is needed to go to the Arduino pin. If you use an Arduino Uno, then the ATmega328P microcontroller has clampling diodes inside, and it allowed to push up to 1mA into those clamping diodes.

Suppose the 22k and 10k are used without extra clamping diodes and without the 1k to the Arduino pin. Only the two resistors. At what voltage is the limit reached for pushing 1mA into the Arduino pin ?
Current through 10k will be 5V/10k = 0.5mA
Current through the pin is 1mA.
Current through the 33k will be 0.5 + 1 = 1.5mA
Thus the measured voltage can be 5V + 49.5V = 54.5V

What about using the internal voltage reference of 1.1V ?
Then the resistors could perhaps be 150k and 10k, that reduces the current a lot, and the allowed maximum peak voltage for 1mA pushing into the Arduino pin is at a much higher voltage (225V). That is because, when the voltage reference is 1.1V, the maximal voltage at the Arduino pin will still be 5V.

DVDdoug: Alternatively, you can use a regular diode (or a Schottky diode) connected "backwards" to the Arduino's 5V regulated power supply. [u]This page[/u] shows the Zener method, and another method with two regular diodes to protect against excessive positive voltages

Thank you for that. Can someone clarify/confirm that in the circuit using two regular diodes, the voltage divider (or, I guess R2 in my voltage divider) would be in the place of R1 in the linked diagram, and I'd connect D3 to the +5v power supply the Arduino is using.

Does that mean that excess voltage could be shifted to the 5v line (if so, what are the consequences of that), or is some or all of that power converted to heat by the diode?

Given this is in a car, transient voltages well over 100 volts could be encountered.

The diode D3 to the 5V is what I called a clamping diode. The excess voltage (actually the current) is going into the 5V line. The is normally not a problem for short peak currents. You may not use 50mA going into the 5V. So you have to choose the value of resistors of the voltage divider not too low.

The output of that may not be connected to an Arduino pin, because D2 and D3 with be parallel with the internal clamping diodes of the ATmega328P. It would be unknown which diode gets the most current. Therefor an extra resistor of about 1k is needed to the Arduino pin.

The simple 1N4148 can have a peak current up to 1A (if the pulse is very short) and continuous of 200mA. That is of course a lot more than the internal diode of 1mA.

A zener diode is useless if/when the Arduino is off. A 1N4148 diode with a higher forward voltage than the max 0.5volt in the Atmega datasheet also doesn’t help that much. A schottky diode would be ok.
But all of this is not needed, because you already have diode protection inside the chip.
Just choose the resistor divider wisely (<=1mA fault current), add a 100n cap to ground to kill spikes, and forget about useless diode protection.
Using the 1.1volt Aref for voltage measurements kills two birds with one stone.
Way more stable, and an easier overvoltage protection.
Most of it has already been explained by Koepel.
This might get you started.

``````/*
0 - ~17volt voltmeter
works with 3.3volt and 5volt Arduinos
uses the internal 1.1volt reference
10k resistor from A1 to ground, and 150k resistor from A1 to +batt
(1k8:27k or 2k2:33k are also valid 1:15 ratios)
100n capacitor from A1 to ground for stable readings
*/
float Aref = 1.075; // change this to the actual Aref voltage of ---YOUR--- Arduino, or adjust to get accurate voltage reading
unsigned int total; // A/D output
float voltage; // converted to volt

void setup() {
analogReference(INTERNAL); // use the internal ~1.1volt reference  | change (INTERNAL) to (INTERNAL1V1) for a Mega
Serial.begin(9600); // ---set serial monitor to this value---
}

void loop() {
for (int x = 0; x < 16; x++) { // 16 analogue readings and 1/16 voltage divider
}
voltage = total * Aref / 1023; // convert readings to volt
// print to serial monitor
Serial.print("The battery is ");
Serial.print(voltage);
Serial.println(" volt");
total = 0; // reset value
}
``````

Leo…

Wawa: Using the 1.1volt Aref for voltage measurements kills two birds with one stone. Way more stable, and an easier overvoltage protection.

Thanks Leo. So I would select resistors for my voltage divider that deliver up to 1 volt to the Arduino, then use the Arduino's internal 1.1 volt reference per your code?

Is there any reason I couldn't take one reading and multiply it by 16 rather than summing 16 readings in a for loop?

Using the for loop, I'm concerned the output would be inaccurate (possibly substantially) if the voltage changes in the time it takes to get and total the 16 reads of the ADC.

Johnnytheknife: Is there any reason I couldn't take one reading and multiply it by 16 rather than summing 16 readings in a for loop?

Using the for loop, I'm concerned the output would be inaccurate (possibly substantially) if the voltage changes in the time it takes to get and total the 16 reads of the ADC.

Pre-reading, multiple readings, and averaging increases accuracy. Two decimal places (1700-count with a 1024-count A/D) is only possible with that. I guess 17 readings take ~2msec. If that's a problem, replace it with a running average. https://www.arduino.cc/en/Tutorial/Smoothing Leo..

Wawa: Pre-reading, multiple readings, and averaging increases accuracy. Two decimal places (1700-count with a 1024-count A/D) is only possible with that. I guess 17 readings take ~2msec. If that's a problem, replace it with a running average. https://www.arduino.cc/en/Tutorial/Smoothing Leo..

Thanks.

I'd planned on using a rolling average to help keep the display output stable anyway. I'm not sure why I thought that the read time would be significant. I cannot imagine substantial variation over 2msec causing issues in my application.

Using the average will remove the noise (from the Arduino ADC, the resistors, and other things). That is often enough, certainly to measure the voltage of a battery. The average of a few samples makes the value more accurate, even with only 3 or 5 samples. When you want the smooth the measured voltage, then you have to use the running average and read the voltage at a certain interval. For example taking a sample every 20ms, and a running average of 20 samples. You can combine both, or else the noise will influence the running average ;)

@Johnnytheknife automotive systems can spike as high as 120V DC: http://www.newark.com/pdfs/techarticles/tyco/Auto_Network_AN.pdf

I recommend a PTC protected TVS diode with a voltage dividor into an buffer op amp then into the arduino.

Terryjmyers:
I recommend a PTC protected TVS diode with a voltage dividor into an buffer op amp then into the arduino.

I don’t.
TVS diodes (super zeners) leak a lot, and could compress the upper range of the voltage you want to measure.
The voltage range (~13.8volt) you’re really interrested in.
TVS diodes have their place in protecting power rails, not analogue inputs.
A simple 150k:10k divider (and using 1.1volt Aref to measure) protects to ~88volt without even using the internal pin protection diodes (pin <=5.5volt). The internal clamping diodes protect far beyond that.
A 100n cap from analogue input to ground kills the (ignition) spikes.
Leo…

Hi, I like the code and scheme for the voltmeter. Just two questions: 1. What values of resistor must I use if I want measure until ~25v ? 6900 and 150000 are ok? 2. What can I include in to protect from inverse currents? I want it to measure solar panel, so If it is dark, the currents will be inverse ... diode from +Batt to 150K resistor would be fine? What kind of diode and what value?

Thanks so much!!

What is the maximum voltage and current the panel can produce? Battery voltage? Are you using a charge controller? Can you post a drawing?

The panel is solar panel to charge a 12v battery.
The maximum voltage … around 17~21v (It depends from sun). It´s 160 watts. The maximum current around 8~12 Amp (I think 8 amp really, because never is the best condition to get 11 amp). If the solar panel is in a open circuit the maximum is 22~24v . But the solar panel is a 12v solar panel, for 12v installations, It is NOT a 24v solar panel.

I am using a charger controller to charge 12v AGM battery.

I want measure the battery voltage (but I have already the circuit you post before). And I want measure the solar panel voltage, always, during charge state and during not charge state … but I want the measure of the panel before de charger controller, because after the charge voltage It can low the voltage to adjust to the battery voltage and needs.

The connection is

----------- +SOLAR PANEL ----------- +PANEL CHARGER CONTROLLER

----------- -SOLAR PANEL ------------ -PANEL CHARGER CONTROLLER

------------ +BATTERY ---------------- +BATTERY CHARGER CONTROLLER

------------ -BATTERY ---------------- -BATTERY CHARGER CONTROLLER

So, the battery controller has 2 connections, positive and negative from the solar panel and positive and negative to the battery.