What's wrong with this single-transistor level-shifter?
The simple explanation is, no matter what you do, the voltage between base and emitter in a conducting bipolar transistor is always around 1V. So, if your base is at 3.3V, the emitter is around 2.3V. All the rest of the voltage (times current) is turned into heat in the transistor, so be careful.

If you want high-side switching, for example to power something controlled by your I/O, you have to use a PNP transistor. In a PNP, the current directions are reversed so we can now connect the emitter to +5V and the collector to the output.







simulate this circuit &ndash; Schematic created using CircuitLab

As soon the GPIO is 3.3V, the NPN opens. Its collector current is the (negative!) base current for the PNP, which makes that one open, too. The output is at roughly 3V. Not much of an improvement, but if you used an input voltage of 12V, the output would be at 10V, while it was still at 2.3V with your circuit.

A better solution with less voltage drop involves a P-Channel enhancement MOSFET.







simulate this circuit

The typical voltage drop over a small signal MOSFET is as low as 0.5V, for power MOSFETs much lower. (Unlike the bipolar transistor, which is a current-controllable current source, a MOSFET is basically a voltage-controllable resistor, so it's current-dependent.)