-1

Can someone help me? I'm trying to control a fan using PWM and I cannot work out how to do it. This worked for a short amount of time and then stopped working.

According to the docs, GPIO pin 18 supports PWM.

To control it from the shell without root permissions, you need to install the wiringPi library. Take a look at the gpio docs or the man page for more information:

man gpio In short: First set the mode of pin 18 to PWM:

gpio -g mode 18 pwm Then you can set the pin to a PWM value between 0 and 1023:

gpio -g pwm 18 512 However, as Krzysztof already noted, you probably don't need PWM if you just want to send a short pulse. You could use a regular pin and simply turn it on and off every 2 seconds.

gpio -g mode 17 out gpio -g write 17 1 gpio -g write 17 0 You could also control it from a program, e.g. a Python script. You should find information about this in the docs.

All this is untested, but should work. If you have more problems, feel free to comment or look at the or the manpage.

  • What sort of fan have you got? Can you actually really control the fan speed with PWM? I believe that sort of fan has four wires, ground, power, tacho output, PWM input. The PWM input is a pretty specialised signal. – joan Sep 15 '15 at 20:14
3

Your fan probably has a voltage drop that is too high for the Pi's GPIO to power it. The GPIO pins only output 3.3v 50ma MAX.

2

You probably have a fan thats power requirements are too high to be met by the pi, as I have never seen a fan that could run on the pi's 3.3 volt 50 milliamps(keep in mind that the pi's gpio pins are 3.3 volt as they are driven by a Broadcom micro controller that uses 3.3 volt logic). Furthermore you may cause irreversible damage to the pin or the pi if you attempt to draw a lot of power, which would explain why it worked temporarily as you may have just fried the pins etch on the pcb or the micro controller. either way you should never try to draw over 50ma from the pi which puts driving a fan off it directly out of the equation.

1

The output of the GPIO is probably too low. You should use an optocoupler and some external power source to drive the PWM on the fan.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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