## Protect over voltage on Voltage Divider ciruit

GuppyHJD
Posts: 17
Joined: Sat Jan 20, 2018 3:37 am

### Protect over voltage on Voltage Divider ciruit

Hello,
I am trying to monitor a remote 12v battery. When I do the math for a voltage divider R1 = 1000ohm, and R2= 330 ohm, gives me 3.49 v if the battery is at 14v. If it is at normal 13.1v to 12.8v the output voltage drops to 3.25v to 3.177v. I am wondering, is there a way to protect the Raspberry Pi pins from anything over 3.3v? I don't want to fry the Raspberry Pi.

PhatFil
Posts: 1467
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

### Re: Protect over voltage on Voltage Divider ciruit

You do have some leway below 3.3v the pi will register a high with voltages over +1.8-2v referenced to ground? (look that up or test it..)
http://www.mosaic-industries.com/embedd ... ifications

or you could employ an optically linked indicator, https://shop.pimoroni.com/products/spar ... AeEALw_wcB

or a logic level shifter

dl324
Posts: 122
Joined: Mon May 06, 2019 7:33 pm
Location: Pacific Northwest, USA

### Re: Protect over voltage on Voltage Divider ciruit

You could use a voltage comparator like LM393. Just connect the pull-up resistor to 3.3V. You can operate the comparator from 5V or your battery voltage.

drgeoff
Posts: 10087
Joined: Wed Jan 25, 2012 6:39 pm

### Re: Protect over voltage on Voltage Divider ciruit

Or put a 2.7 volt zener diode across R2.

davidcoton
Posts: 4404
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK

### Re: Protect over voltage on Voltage Divider ciruit

GuppyHJD wrote:
Sat Aug 10, 2019 12:57 am
I am wondering, is there a way to protect the Raspberry Pi pins from anything over 3.3v? I don't want to fry the Raspberry Pi.
The resistor in the voltage divider should be enough protection, up to 4V on the GPIO pin (so over 16V at the battery). Note this is outside the recommended operating conditions but should give adequate protection for an unusual condition. Beyond that you could clamp the GPIO pin via a diode to 3V3, or use a 3V3 zener diode to ground (also gives reverse polarity protection).
Signature retired

GuppyHJD
Posts: 17
Joined: Sat Jan 20, 2018 3:37 am

### Re: Protect over voltage on Voltage Divider ciruit

Thank you for the replies. I have ordered a few Zener diode.

trejan
Posts: 1094
Joined: Tue Jul 02, 2019 2:28 pm

### Re: Protect over voltage on Voltage Divider ciruit

Use bigger value resistors as you'll be dissipating ~10mA across your voltage divider with your current selection. You may need a 10-100nF ceramic cap from the ADC input to ground as well.

Burngate
Posts: 6148
Joined: Thu Sep 29, 2011 4:34 pm
Contact: Website

### Re: Protect over voltage on Voltage Divider ciruit

I'm not convinced about using higher value resistors.

With 1k & 330Ω across 14v, it's only dissipating ~150mW, well within what a standard ¼W through-hole resistor can handle, though a bit much for a standard 0603 Thick Film SMD Resistor ±1% 0.1W.

The OP states
I am trying to monitor a remote 12v battery
To me that means there's a long distance between the battery and the Pi, with all the problems of interference along the way.
As the resistor values go up, so do the problems, so I would be considering reducing the values, not increasing them.

drgeoff
Posts: 10087
Joined: Wed Jan 25, 2012 6:39 pm

### Re: Protect over voltage on Voltage Divider ciruit

trejan wrote:
Sun Aug 11, 2019 2:05 am
Use bigger value resistors as you'll be dissipating ~10mA across your voltage divider with your current selection. You may need a 10-100nF ceramic cap from the ADC input to ground as well.

trejan
Posts: 1094
Joined: Tue Jul 02, 2019 2:28 pm

### Re: Protect over voltage on Voltage Divider ciruit

drgeoff wrote:
Sun Aug 11, 2019 9:57 am
If they want to know the exact voltage then they'd need one. If they're happy with knowing they're just over some preset voltage then no.

trejan
Posts: 1094
Joined: Tue Jul 02, 2019 2:28 pm

### Re: Protect over voltage on Voltage Divider ciruit

Burngate wrote:
Sun Aug 11, 2019 9:27 am
I'm not convinced about using higher value resistors.

With 1k & 330Ω across 14v, it's only dissipating ~150mW, well within what a standard ¼W through-hole resistor can handle, though a bit much for a standard 0603 Thick Film SMD Resistor ±1% 0.1W.
I was more concerned about unnecessary drain on the battery than the resistors themselves. It isn't huge but it may make a difference if they're trying to maximise battery life. I think OP needs to post more details about what they're trying to do.

drgeoff
Posts: 10087
Joined: Wed Jan 25, 2012 6:39 pm

### Re: Protect over voltage on Voltage Divider ciruit

trejan wrote:
Sun Aug 11, 2019 10:19 am
drgeoff wrote:
Sun Aug 11, 2019 9:57 am
If they want to know the exact voltage then they'd need one. If they're happy with knowing they're just over some preset voltage then no.
The threshold voltage on a RPi GPIO is not sufficiently well defined to know with certainty if above or below some preset voltage.

trejan
Posts: 1094
Joined: Tue Jul 02, 2019 2:28 pm

### Re: Protect over voltage on Voltage Divider ciruit

drgeoff wrote:
Sun Aug 11, 2019 10:24 am
The threshold voltage on a RPi GPIO is not sufficiently well defined to know with certainty if above or below some preset voltage.