I'm currently having this project where I put a Raspberry Pi, batteries and a touch screen inside a book that can fit my pocket. This screen is constantly on, and I want to be able to turn it on and off with a transistor.

I'll be controlling the 5 V instead of ground because it is also getting ground over HDMI. The base will have 3.3 V, and the output should be 5 V.

I've tried many things with both NPN and PNP.

I'm running a Python script that outputs 0.02 V as LOW and 3.3 V as HIGH.

I'm ending up with the screen being either on/blinking, grey/grey, grey/off or off/off. It stays totally off with 5 V with PNP transistor.

This is curcuit that has almost worked (grey/off):

PNP - 2N3906

When GPIO is HIGH (3.33 V):

  • Monitor: Grey
  • Base: 4.32 V
  • Collector: 2.21 V
  • Emitter: 5 V

When GPIO is LOW (0.02 V)

  • Monitor: off (no back-light)
  • Base: 4.38 V
  • Collector: 1.6 V
  • Emitter: 5 V

Current state picture taken (HIGH)

I tried with two 2N3906 transistors to make sure it wasn't broken.

I'm kind of confused over this circuit and it seems that my knowledge doesn't match.

What can I do to make this work? What am I missing?

  • \$\begingroup\$ How much DC current does your touchscreen draw from its 5V battery? \$\endgroup\$ – glen_geek Nov 26 '17 at 17:00
  • 4
    \$\begingroup\$ 3.3V is not high enough to turn off your PNP. Will not be high enough to turn off a PMOS either. To make this work you will need to use a P-channel mosfet + an NPN. How much current does the load require? \$\endgroup\$ – mkeith Nov 26 '17 at 17:19
  • 2
    \$\begingroup\$ Please see figure 2 in the document SLVA716. You want to use the rightmost circuit in the figure. SLVA716 is a TI application note about their proprietary load switches. You don't need to use their proprietary load switches. Just copy the circuit in figure 2. P-channel MOSFET selection depends on how much current is required. BSS184 might work for low current. ti.com/lit/an/slva716/slva716.pdf \$\endgroup\$ – mkeith Nov 26 '17 at 17:24
  • \$\begingroup\$ @glen_geek I'm not currently home at the moment, but looking at the eBay listing, it says 400mA max. That one thing I forgot to measure. \$\endgroup\$ – Typewar Nov 26 '17 at 19:54
  • \$\begingroup\$ Oops. Should be BSS84, not 184. Sorry. But it won't work for 400 mA anyway, so look for a logic level PMOS with Rds(on) of 250 mOhm or less at Vgs of 5V. \$\endgroup\$ – mkeith Nov 26 '17 at 20:01

enter image description here

Figure 1. In this example Vss is greater than the 5 V supply of the micro-controller. The protection diodes keep the transistor always on.

Figure 1 shows the internal schematic of a 5 V powered GPIO in "output" mode. A pair of transistor switches pulls the output high or low. (Only one can be turned on at a time.) Note the internal protection diodes.

The protection diodes on most logic chips creates a sneak-path to positive supply. This will keep the PNP transistor permanently turned on and may damage the chip.

In your case your micro is powered from +3.3 V and Vss is +5 V. The result is the same, as you have discovered.

enter image description here

Figure 2. To drive a high-side transistor from a GPIO pin we need a level translator. An NPN transistor does the job nicely.

Note that Q2 inverts the logic so you may need to modify your code to suit.


The images are mine and more on the topic can be found in the article GPIO high-side driver fail.

  • \$\begingroup\$ Your second diagram is exactly how I would do it - given that NPN and PNP transistors are more likely to be "lying around" a typical hobby room. A 2N3904 and 2N3906 pair would probably do the job. \$\endgroup\$ – Floris Nov 26 '17 at 21:51
  • \$\begingroup\$ @Floris, OP says current may be 400mA. If so, the 2N3906 is probably not a good choice, because it can't handle that much current. Also, the VCE(sat) of any BJT may cause problems depending on what the load is. But for an LED powered from 12V, of course, it is no problem. \$\endgroup\$ – mkeith Nov 26 '17 at 22:50
  • 1
    \$\begingroup\$ That is a lot of current - I had missed that detail. I think of LCD displays as low power... shows my age. If you are going to give them backlighting that may no longer be true... \$\endgroup\$ – Floris Nov 26 '17 at 23:31
  • \$\begingroup\$ I guess the Micro is the Raspberry Pi? or is it something else? Just to confirm. I don't recognize the circuit. \$\endgroup\$ – Typewar Nov 27 '17 at 7:13
  • \$\begingroup\$ Yes, the micro represents the Raspberry Pi. What's inside the blue box represents one of the general-purpose input/outputs (GPIO). \$\endgroup\$ – Transistor Nov 27 '17 at 7:31

There is a standard way to do this with a P-channel MOS transistor (PMOS).


simulate this circuit – Schematic created using CircuitLab

This is the standard way of doing it. You may or may not need to add C1. If the load has capacitance, then sometimes when you turn on M1, the 5V rail will suddenly dip, and that can cause problems for anything powered from 5V. C1 can help with that just by being a bigger capacitor. Q1 does not have to be an NPN. You could use a logic-level N-channel FET such as a BSS138.

There are lots of choices for M1. A BSS84 might work if the load current is low.

  • \$\begingroup\$ I forgot to measure the load and I'm not currently home atm, but the eBay Listing says it is maximum 400mA. I'll set the answer as correct once I get myself the parts. Thank you! \$\endgroup\$ – Typewar Nov 26 '17 at 19:55

I also got stuck on this until I had a moment of inspiration, instead of controlling the power to the screen with a transistor circuit I now control the video signal as my control board for video shuts down when there is no signal present.

  • 1
    \$\begingroup\$ Welcome to EE.SE. Some detail on how might answer the question better. \$\endgroup\$ – Transistor Nov 27 '17 at 13:13
  • \$\begingroup\$ The signals is over HDMI. The data pins on the USB is for the touch. I don't see any other solution than controlling the positive pin giving power to the display. \$\endgroup\$ – Typewar Nov 27 '17 at 17:38

As others have already noted, the 3.3 V from the digital output is not high enough to turn off a PNP transistor with emitter connected to 5 V. There are some simple ways around this.

Here is something really simple that would work in a pinch:

The two resistors form a voltage divider so that the E-B voltage is held at less than 400 mV when the digital signal is at 3.3 V. When the digital signal is low, the transistor is driven with about 2.3 mA base current, and the digital output has to sink 5.2 mA.

This is rather inefficient in the use of the possibly limited current sink capability of the digital output, and it leaves some current thru the protection diodes when the transistor is off.

Here is a much better approach, but slightly more complicated:

This is similar to what others have suggested, but simpler and uses the digital output source current more optimally.

Q2 acts as a switchable current sink. Figure about 700 mV for the B-E drop of Q2, so 2.6 V across R1, which results in 9.6 mA current thru R1. If the transistors have a gain of 50, then that results in 9.4 mA base current from Q1, which would support up to 470 mA of load current. The current sourced by the digital output is only 190 µA, which any remotely normal digital output can do easily.

  • \$\begingroup\$ I get the same result as the top answer; 2.22 V output on the Collector for Q1. But when I separate them, it get's 5 V on the collector for Q1. When measuring the positive pin on the load without it connected to Q1, it got 0.33 V. I don't know if that is important or not. I'll try out your top circuit with one Transmitter and two resistors. \$\endgroup\$ – Typewar Nov 29 '17 at 19:53
  • \$\begingroup\$ First circuit didn't work either. It had 2.2 V to the load again. I'm not sure what is causing this \$\endgroup\$ – Typewar Nov 29 '17 at 21:15
  • \$\begingroup\$ @Typewar, did you ever measure the current required by the load? \$\endgroup\$ – mkeith Dec 4 '17 at 7:03
  • \$\begingroup\$ In your second example, won't Q1's base float without a pull-up to the 5v source? FWIW, I built the second example and it works as expected, just trying to better understand. \$\endgroup\$ – josephrider Sep 3 '18 at 19:13
  • 1
    \$\begingroup\$ @jos: It takes current out of the base to turn on Q1. With Q2 off, there is no path for such current. Still I would put a 10 kOhm or so resistor between B and E of Q1 in a real commercial design. Perhaps I should have shown that here too, but I was trying to go for perceived simplicity, especially as a alternative to the other answer that doesn't use a pullup either. The danger of no pullup is that capacitively coupled noise can make the transistor appear to leak a bit, and to slow down the on to off transition. Neither of those should be much of a problem in this case. \$\endgroup\$ – Olin Lathrop Sep 3 '18 at 22:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.