# Will this work and what transistor do I use?

I posted this question in the Meta Stack Exchange but David Tweed said that the idea was flawed so any alternative circuit suggestion would be appreciated.

I have this Ikea lamp. It runs off 5V usb power however it draws 0.6A which according to this is more than the GPIO pins can supply. So I need to use a transistor but I don't know how to find one that will work.

• I don't know if a USB can provide enough current to power a normal lamp. On top of that most lamps run on 120V AC and 5V just won't cut it. Commented Aug 30, 2016 at 19:25
• Does the lamp need the D+ and D- lines or just VCC and Gnd? Commented Aug 30, 2016 at 19:33
• @jbord39 Its a usb lamp Commented Aug 30, 2016 at 19:40
• If the Raspberry delivers 5V active high and the USB Vcc pin can deliver the 0.6A (most USB are rated for 100mA or 500mA), then with a PNP transitor you can do that switch, commanding the base with the Raspberry Commented Aug 30, 2016 at 19:56

You've drawn an NPN transistor as a high-side switch. This won't work since you need to drive the base at least 0.7V higher than the emitter, and your RPi GPIO outputs only push 3.3 volts.

You should move the transistor into the ground path to operate as a low-side switch, and add a current limiting resistor to the base. Even then, you will probably run into trouble depending how much current the lamp needs compared to the h_fe of the transistor, necessitating two BJTs in a Darlington configuration.

I would recommend ditching BJTs altogether and using an N-channel MOSFET as a low-side switch. MOSFETs are voltage controlled devices, so you just need to supply a logic level to the gate to get it to operate as a switch. Add a pulldown (say 10k) from the gate to the ground so the input doesn't float when the RPi is off or Hi-Z. Something like this:

simulate this circuit – Schematic created using CircuitLab

When choosing a MOSFET, pick one which can handle the current without a heatsink (say 1A), and ensure that it can switch using a 3.3V gate drive.

Finally, 600 mA is more current than most standard USB ports can handle. A USB charger can do this, but a standard USB 2.0 port is limited to 500 mA. So, be careful what you plug this into.

• I have found this MOSFET. Will it work? Commented Aug 31, 2016 at 14:05
• That FET should work fine. Commented Aug 31, 2016 at 18:18