# PiFace low voltage detector

I'm doing a project with PiFace, but being a software guy my capabilities apparently end when it comes to a circuit to detect low voltage.

Basically, as far as I understand PiFace input port is +5V with 10kohm resistor. Connect it to gnd and it's "on".

My best guess is something like this, with the input port connected to the transistor. Id' just need to have the right values for resistors and the LED should cut the flow in case the voltage drops below say 4.5V... yeah, as I've said, I have no idea what I'm doing :-)

Is there a simple circuit that would actually work?

• I'm a little unclear on exactly what you're trying to do. What do you mean by detecting a low voltage? And where is the LED you mention? Your understanding of the pull-up resistor on the input and needing to connect it to ground is correct - so where do you want to go from there? Oct 6, 2014 at 2:55
• Basically I want to set the input to 1 if voltage drops say below 4.5V... Oct 6, 2014 at 10:06

For a brown-out type of low-voltage detect, the simplest solution would be a purpose-built device like Microchip's MCP100 or something similar. Its a little 3-terminal device which looks like a transistor but is actually a voltage detecting switch IC. You can choose one which triggers at a voltage level which suits you - there are a number of different options available.

However, if you're a bit of a masochist and really want to build something up from discrete components then try something like this:

simulate this circuit – Schematic created using CircuitLab

D1 is a 3.9V zener, so this added to Q2's Vbe of around 0.6V means that for any supply voltage above 4.5V Q2 will be turned on. This in turn holds Q1 off and your PiFace input stays high. If the supply voltage drops below the 4.5V threshold, Q2 turns off which then allows R3 to turn Q1 on which then pulls your PiFace input low.

• Thank you!!I'm trying to understand the whole thing to learn. First puzzle is "why would the circuit across D1 R1 Q2 be turned on at about 4.5V"? So the transistor base->emitter circuit can actually be represented with a diode with voltage drop of about 0.7V, right? To beter understand, I simulated just the D1 -- [R2 || R1 -- 0.7V diode D2]. (-- for serial, || for parallel). In this configuration R2 and [R1--D2] will have the same voltage. I reckon I need R2 for the excess voltage of D1 and R1 for excess voltage of D2. Does R1 and R2 resistance matter? Ctd... Oct 8, 2014 at 9:25
• In my simulation, when source=5V the diode only has 510mV and R1 777mV. Changing R1 to 1 ohm (yes, 1, just to test) brings up the diode voltage to 664mV. Is this because the simulator is using .7V voltage drop @ 1A current? I assume the transistor base voltage drop and zener voltage should be the only parameters controlling the trigger voltage, right? Does that also mean I could put another diode in front of the Q2 base and change D1 to get different values? E.g. D1 2.7V + LED 1.6V + transistor 0.6V=4.9V? Oct 8, 2014 at 9:35
• Ahhh.. and Q1.. it's in parallel to collector-emittor of Q2. And if a resistor (or any element) is in parallel to a wire (R=0 ohm), the total resistance is 0 ohm, hence all the current flows through Q2. When Q2 is closed, the current flows through Q1 base.. right? This is, wow, beautiful Oct 8, 2014 at 12:29
• I think you've pretty much got it. The resistor values are not particularly critical, but I wouldn't suggest you reduce R1 or R3 much lower than 1k. Doing so would unnecessarily stress one or both of the transistors. I got to a valu of 4.5v by assuming that Q2 would begin to turn on at about 0.6v, but 0.7 is probably more likely. Since I have chosen a 3.6v Zener for D1, the 'voltage_to_monitor' will need to be higher than 4.6v (the sum of D1s 3.9 and Q2s 0.7) before any current flows into Q2's base to turn it on. It's likely that you could remove R2 - I put it there mostly out of paranoia :) Oct 9, 2014 at 1:13

I'd suggest you try something like this:

simulate this circuit – Schematic created using CircuitLab

The much simplified explanation of how this should work is:

Your input will normally be held up at 5V by R4, but if you bring it below the point where Q1 starts to turn on (about 4.3V), then current will start to flow through Q1 & R2. This in turn will cause Q2 to turn on, which pulls your PiFace input down to ground.

• First of all thank you! I see I wasn't clear enough - I'm powering the PI and PiFace from a battery. So input and +5V are the same value, hence the first part of the circuit around the PNP wouldn't work. Would this work if I scrapped the first part of the circuit and just hook the battery+ to R2 and tweak the values to close the NPN base if power is under say 4.6V? I don't know how much current need to detect the switch is in "ON" position (and inside the PI input is apparently an equivalent of 10k ohm resistor). Getting the R2 R3 values precisely could be tricky, wouldn't it? Oct 7, 2014 at 12:16
• Aaah now I think I understand what you're looking for - something more like a power-supply brown-out detector! That shouldn't take much more than a zener and a transistor or 2. I'll post a suggestion shortly ... Oct 7, 2014 at 23:44