I'm trying to use a RP2040-zero to control a 12V PC fan that also has a PWM and tach connection. I'm using a transistor to turn off the fan completely as a 0% duty cycle on PWM doesn't turn the fan off, it only spins it down to a really slow speed.

When I use the GPIO pin to turn on the transistor, everything seems to be working. The fan spins as expected, I'm able to control the speed with PWM, and I can read the signals from the tach to get the rpm. When I drive the GPIO pin that is connected to the transistor base low, the fan spins down and stops. But the problem is that the fan is making a clicking sound starting right before it stops and then the whole time when it is stopped.

I measured the voltage between the collector and +12V when the GPIO pin is high and I see right around 12V as expected. But when the GPIO pin is low, the voltage drops to 8V, it doesn't drop to zero. I also tried tying the base directly to ground just to rule out any GPIO issues and also see 8V.

The interesting part is that if I disconnect the PWM connection to the fan, everything starts working properly. I see the collector at 12V and 0V when the GPIO pin is high and low. So somehow the PWM connection is interfering with being able to turn off the transistor.

I tried looking for another question here that had the same problem as me but couldn't find one. I'm assuming this is probably something stupid that I'm missing due to a lack of experience. Here is the schematic for the circuit:


  • 2
    \$\begingroup\$ The 12V Power supply's ground is not common to the logical one in your schematics. Is that a mistake ? \$\endgroup\$
    – Mathieu G.
    Commented May 23 at 6:34
  • 2
    \$\begingroup\$ The LM2596 is not an isolated converter so the grounds should be harmonized if the built circuit reflects its schematic. \$\endgroup\$
    – vir
    Commented May 23 at 7:19
  • \$\begingroup\$ @MathieuG. The ground is common across the whole circuit. This is the way Fritzing did the connections. \$\endgroup\$
    – mpaw
    Commented May 24 at 4:33

1 Answer 1


Switching the fan on the low side is a mistake here; when the transistor is off there will be a current path through the fan and the tach/PWM pins. You could use the NPN transistor to pull down the base of a PNP between the 12V supply and the fan. Also, the 68R is rather low as a base resistor; the GPIO pins will only be good for a few mA so they will limit the current, which explains why you’re seeing 8V rather than zero. If you’re adding a second transistor then consider about 10k there and maybe 1k to limit base current for the PNP to around 10mA which will be ok for a fan current of a few hundred mA. Use less than 1k if you need to to get the PNP to switch on fully.

  • 1
    \$\begingroup\$ Thank you @Frog, using the NPN transistor to switch the PNP transistor between the 12V and the fan solved my problem and everything is working perfectly now. \$\endgroup\$
    – mpaw
    Commented May 24 at 4:37

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.