Electrical – 2n2222 NPN low side switch not working with 31V

npnswitchestransistors

I'm attempting my first slightly more advanced circuit and failing. I have a led string which I'm powering with a 31V 0.21A power adapter that came with it. Now I'm trying to switch it on and off with a 2n2222 NPN transistor which I'm controlling with a Raspberry Pi 3.3V GPIO. Initially, I had an optocoupler in there also to keep my Raspberry safe but took it away to confirm it isn't the problem.

I have connected the emitter to ground, collector to the LEDs and the GPIO to base via two 220 resistors, achieving 440 ohms.

enter image description here

Now, putting the GPIO to high or low doesn't affect the lights (at least noticeably). Instead, the lights are steadily burning with a faint glow. Removing the GPIO from base pin turns off the lights completely. I'm having a hard time understanding what's going on.

Some questions that might solve this:
I based my resistor calculations on this tutorial assuming 100 hFE. I'm not sure about the hFE value. The 2n2222 datasheet doesn't really tell what it is with 31V and 0.21A. Any help here?

The 31V is quite high (weird choice by the light manufacturer in my opinion) but the transistor can handle up to 40Vce and 1A. Am I misunderstanding something here?

One option is that I somehow got high and low the wrong way. Does the behavior sound like it could be caused by an inversed circuit?

Solution
Thanks to @WillDean I realized I was using two grounds which was messing up a whole lot of things. I didn't realize this is an issue before the obvious was stated.

Best Answer

You need to connect 0V of your RaPi to the emitter connection on your power supply because you cannot drive dc current into the base without a return path for that current.

But, before you do that make sure that the 31 V dc supply can connect to 0V on the RaPi safely i.e. is the 31 V supply isolated from ground?

It may be OK if it isn't but tread carefully because I don't want you to destroy your RaPi.