Electronic – Will this work and what transistor do I use

currentlampraspberry pitransistorsusb

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.Diagram of what I want to do

Best Answer

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:

schematic

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.