Control 5 V load with transistor 3.3 V - Raspberry Pi
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.



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.

Links:

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