Transistor/Switch help needed

Hey all,

I am using a raspberry pi and I need to use the 5V for an input to a circuit however I would like to be able to control this 5V through the GPIO pins. As far as I’m aware, the GPIO pins can only output 3.3V. I was thinking about how I could use the GPIO output to control a switch to allow 5V to pass through my circuit.

My first idea was to use a PNP transistor with the GPIO connected to the base with the 5V connected to the emitter and the circuit attached to the collector however this did not work and I got around 2.5V on the collector when base was powered.

I then tried to use an NPN transistor with the GPIO connected to the base and 5V connected to the collector. I then added a pull down resistor on the collector, I’m not 100% sure why but that didn’t work either.

Is there a really simple way to do this where I can control the 5V input through a GPIO pin that I have completely overlooked?

Thanks for your help and your time.


Hi Andrew
You just about got every wrong connection possible with that little effort.

Use the NPN Transistor or an N Channel Mosfet as a low side switch.

Connect the GPIO toTransistor Base or Mosfet Gate via a 1k resistor. Connect Transistor Emitter or Mosfet Source to ground. Connect your load positive to 5V positive. Connect negative side of the load to Transistor Collector or Mosfet Drain. Connect 10k resistor from Transistor Base or Mosfet Gate to Ground.

If the load is inductive (like a Solenoid,Relay etc) put a Schottky diode across it. Connect Cathode to 5V supply/load positive, connect Anode to load negative/Transistor Collector/Mosfer Drain. If you don’t you will destroy your Transistor/Mosfet.

Core have a little Freetronics board SKU:CE04538 which has the 1k and 10k mounted on it, only 3 connections. It is supposed to work with 3.3V logic.
Cheers Bob
I am assuming a complete load you need to power, I just noticed you refer to a “5V input”. What exactly do you mean and what are you trying to do.


See if this helps Andrew


Thanks for your help Bob. I’m sorry I messed up!

Is there any way I can do this at the input to the circuit instead of doing it at ground? I’m just not able to connect it to ground because I have another circuit connected to the it. Thank you


Hi Andrew
I apparently misunderstood. I thought you wanted to power up a device with 5V using the 3.3V switching output of another controlling device.
It seems you want to convert th3 3.3V to 5V for an input to a device.
It can be done with discrete components but the simplest would be a Logic Level Converter. Core stock these devices and I think some have detailed information. Search “logic level converter” on the Core web site and see if anything there suits your purpose.
You are still the only one that knows EXACTLY what you want.
Cheers Bob


Thanks again Bob.

perfectly explained. A mosfet could work better than any other type of transistors

Hello Andrew,
This might interest you. I have been using this circuit on numerous projects with success.
I use mainly salvaged components from discarded TV’s, amplifiers and various power supplies.
The circuit is fully explained by Lewis Loflin via his web site, and also his youtube channel.
There’s lots of great electronics tutorials on his channel.

The circuit offers good protection via the opto isolator and it works with both 5v and 3.3v.

Good luck,

1 Like