0

I dont if this is the correct place to ask this. Please give me feedback any kind will do.

How can I control fan speed using PWM on Raspberry Pico ?

Lets say if I have 5V fan, and a Raspberry Pico. Any other component I should buy ? Please also tell schematic if it is possible because I'm still new in this type of electronic stuff. Also how to utilize MicroPython to achieve that?

4
  • 1
    What have you searched for before asking?
    – joan
    Aug 22, 2022 at 6:41
  • What are the fan specs? You have to make sure than none of the GPIO touch 5v.
    – NomadMaker
    Aug 23, 2022 at 0:21
  • @NomadMaker for the specs i dont really know. Maybe I'll use 5V Noctua fan
    – Trisk Khan
    Aug 25, 2022 at 5:35
  • Sorry. What i know right now is some says "dont power the fan using the pico, instead use external power, only use the pico as the pwm control". But I dont mind to power the fan from Pico as long as I know the pros and cons about that. I try to make the electrical engineering as simple as possible but i dont know how to achieve that @joan
    – Trisk Khan
    Aug 25, 2022 at 6:20

2 Answers 2

1

First of all, the RPi Pico's GPIO pins output 3.3V, not 5V. You can, however, get a steady 5V from the VBUS output from the board, assuming you're powering it from a 5V source.

I myself learnt how to use the PWM stuff from here: https://microcontrollerslab.com/raspberry-pi-pico-pwm-micropython-tutorial/

Here's a code snippet from the website, which would make PWM work on Pin13 at a PWM frequency of 1000Hz. So, just connect a resistor from Pin13 to the +ve of the LED and a jumper wire from -ve on the LED to neutral.

from machine import Pin, PWM
from time import sleep

led = PWM(Pin(13))
led.freq(1000)


while True:
    for duty in range(0,65535):
        led.duty_u16(duty)
        sleep(0.0001)

Hope this helps :)

2
  • Hey, sorry for the late response. So if I connect 5V fan to VBUS, does th pico itself needs 5V power ? Also did I need any resistor for the fan ? And Neutral is GND right ?
    – Trisk Khan
    Aug 25, 2022 at 5:37
  • @TriskKhan no problem. The voltage "output" from VBUS is the same as the voltage "input" to the pico. So, if you give 3V to the Pico, the max you can get from VBUS is 3V. So, to drive a 5V fan from VBUS, yep, you need to supply the Pico with 5V. I have not run fans off my Pico and instead on my Pi3 with the 5V pin. There, I have not used any resistors. But don't take my word for it because I've only ever run 12V PC fans from the 5V line, so I'm not very reliable here. And yes, neutral is ground.
    – xelab04
    Aug 25, 2022 at 13:36
0

Here's a walk through with schematics using the L9110 motor driver with the Pico and micropython, also using a Power Jack Adapter from a 12 V power supply:

https://github.com/jouellnyc/pico_pwm_12v_fans

Just swap out for a 5V and and lower the power to 5V.

There are many many blogs showcasing the L298N motor driver, if interested.

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.