A quick google for "3v to 5v transistor" gives me dozens of circuit diagrams that look like option A below with a NPN transistor and a pull-up resistor. If I build the diagram in iCircult, it works as expected. However, when I wire it up on a breadboard, it doesn't work quite the way it should. Without any power to the base, I get Vout = 4.95v. With power to the base I get Vout = 0v so it is inverting my wave.

A few experiments later, I solve my problem using a PNP transistor and a pull-down resistor (option B). In both cases I am taking Vout from the Collector side of the transistor.

It's a pretty simple circuit, you'd think it would just work. I double and triple checked the connections. I have also posted a photo of the breadboard below. I always seem to have weird problems like this when working with transistors, so now I am sort of on a quest to understand why option A doesn't work like it should for me?

Circuit Diagram Breadboard

  • \$\begingroup\$ What are the output impedance of the previous stage and the input impedance of the next stage? \$\endgroup\$ – Ignacio Vazquez-Abrams May 18 '15 at 3:48
  • 1
    \$\begingroup\$ Did you connect the grounds of both power supplies together? \$\endgroup\$ – Lorenzo Donati supports Monica May 18 '15 at 3:53
  • \$\begingroup\$ @Ignacio the incoming 3v is 2.65mA and the incoming 5v is 4.95mA \$\endgroup\$ – ThatAintWorking May 18 '15 at 3:57
  • \$\begingroup\$ I apologize, I went through so many iterations with the circuit that I forgot the original problem wasn't the 4.97-4.99 cycle -- that only happened in iCircuit. On the breadboard, the NPN circuit the Vout was low when the base had power and high when it didn't so it was inverting my wave. I will update my question accordingly. \$\endgroup\$ – ThatAintWorking May 18 '15 at 4:00
  • 1
    \$\begingroup\$ This circuit is a level shifter AND inverter. When you push current through the base, the collector will go low. So the inversion is expected. If you need level shifting without inversion, then you can use two of them, or just use a CMOS buffer powered from 5V to level shift. \$\endgroup\$ – mkeith May 18 '15 at 4:06

Both circuits invert your input signal. The second one will not work properly.

If you want a non-inverting level shifter you can use this circuit:


simulate this circuit – Schematic created using CircuitLab

When the input is close to 3.3V, the transistor is off and R2 pulls the output up to 5V. When the input is close to ground, the transistor is saturated and the output is equal to the input plus maybe 50mV.

  • \$\begingroup\$ This is a good idea. If it is not fast enough, add a small cap from emitter to collector of Q1. That may help. \$\endgroup\$ – mkeith May 18 '15 at 4:26
  • \$\begingroup\$ Will this protect the input side from receiving anything over 3V? That is very important. \$\endgroup\$ – ThatAintWorking May 18 '15 at 4:30
  • \$\begingroup\$ Yes. This only pulls up to 3.3 (or whatever) Volts. Where it says 3.3V in the circuit above, use the same power supply that you are using for your Raspberry Pi I/O and all will be well. \$\endgroup\$ – mkeith May 18 '15 at 4:34
  • 1
    \$\begingroup\$ @mkeith Maybe 20-30pF across R1 would be better. \$\endgroup\$ – Spehro Pefhany May 18 '15 at 4:37
  • 2
    \$\begingroup\$ @ThatAintWorking, you only had to add the pulldown because you were testing on the breadboard, and "IN" was not connected to anything, right? If so, OK. But when "IN" is connected to your Raspberry Pi, the Raspberry Pi should drive it and no pulldown should be needed. \$\endgroup\$ – mkeith May 18 '15 at 5:02

Based on the updated information in the question, I believe Option A is working as I would expect. It both inverts the signal and level shifts it. I guess the examples you found didn't emphasize the inverting nature of this circuit.

Although I would suggest using 10k in series with the base. You want the collector current to be 10x or 20x the base current.

Option B is risky because it may expose the 3V output (the signal that is trying to control the base) to high voltages. Also, 3V may not be high enough to always turn off the PNP, so you may get incorrect data.

If you need to boost the level and maintain polarity, you could use a CMOS buffer powered from 5V, but driven with the 3V signal. If the signal is not super high-speed this will probably work OK, but may affect the duty cycle of the signal.

You could also use two transistors. The first one level shifts and inverts, and the second one just inverts it back to the desired polarity. Whether this will work depends on what you are using the signal for. This will be a sluggish setup, and may change teh duty cycle just as much as the buffer.

A last easy option is to use a comparator. You can set the inverting input to 1.5v with a voltage divider, and the non-inverting input will be your signal input. Power the comparator from 5V. Don't use an open-collector comparator. Use one that actively drives the output up to VCC.

Good luck to you!

  • \$\begingroup\$ I'm sorry you answered before I got to correct my question. I misspoke about how it was behaving on the breadboard. \$\endgroup\$ – ThatAintWorking May 18 '15 at 4:07
  • \$\begingroup\$ Add a diode to the 3v line doesn't seen to work. My 3v source will be a Raspberry Pi so I do want to protect that source because it is very sensitive to more than 3V. What alternative would you suggest? \$\endgroup\$ – ThatAintWorking May 18 '15 at 4:19
  • 1
    \$\begingroup\$ I updated my answer, but Spehro's answer is very good. I have used a similar circuit to what Spehro suggested, except I used an N-channel FET. I just didn't think of it this time. I suggest you try his circuit first. \$\endgroup\$ – mkeith May 18 '15 at 4:30

If you don't want inverting, you can do the following. I use it for 5v sensors feeding a 3.3v arduino digital input.enter image description here

  • 2
    \$\begingroup\$ No base resistor? \$\endgroup\$ – Enric Blanco Apr 28 '17 at 21:42
  • 1
    \$\begingroup\$ Definitely want a base resistor there, as Enric says. \$\endgroup\$ – Hearth Apr 28 '17 at 22:15
  • \$\begingroup\$ if there was a load, the transistor could consume a lot of current if it failed, but since it's feeding a high impedance input, the base resistor is optional. \$\endgroup\$ – sspence65 May 17 '17 at 14:45

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.