1

I'm trying to get a USB fan to work with raspberry Pi 3, by using transistor as the switch. The base of transistor is connected to GPIO 4. And I want to control the fan by switching GPIO 4 on / off. I'm using PN2222A Transistor (NPN)

This setup works with LED light (images below) and I'm able to turn the LED light on / off, but I can't figure out how to make the fan work?

The fan works if I connect it directly to 5v rail & ground. In addition, the GPIO 4 on/off works with Led light.

Led setup

Fan Setup

1 Answer 1

2

I don't know why you want a fan, let alone one controlled by the Pi.

You have a 33kΩ in series with the base. This will give ~0.1mA base current. Assuming a gain of 100, this would give a collector current of 10mA, woefully inadequate for most fans.

Use a more realistic value 330Ω would be more suitable.

You are also in danger of damaging the transistor, by operating it in linear mode, although at 10mA this is unlikely.

With ANY inductive load you should also be using a diode to protect the transistor from back-emf.

2
  • Thanks for the help Milliways, 330Ω made it move slightly. So I had to go a bit lower. and thanks for the tips about linear mode & diode, I have to look into these. I'm using usb fan because I had one laying around and I wanted to learn how to operate with usb devices through GPIOs.
    – RobRalph
    Commented Feb 5, 2017 at 11:16
  • When using a transistor as a switch you need to provide enough base current to saturate it (which can be confirmed by measuring the collector voltage, which should be ~0.7V). A MOSFET is probably better as a high current switch. I use BS170 with my Pi, as they have a suitable VGS for 3.3V logic, and can switch 500mA.
    – Milliways
    Commented Feb 5, 2017 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.