Difference between revisions of "PI4-FAN-PWM"

From Waveshare Wiki
Jump to: navigation, search
 
(34 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
<div class="wiki-pages jet-green-color">
 
<div class="wiki-pages jet-green-color">
 
{{infobox item|
 
{{infobox item|
 +
|name=PI4-FAN-PWM
 +
|name2=PI4-FAN-PWM-B
 
|img=[[File:精修风扇1.jpg|400px|{{Amazon_nolink|default={{#ifeq: {{#urlget:amazon|0}}|{{#urlget:Amazon|0}}| default|}}|url=link=https://www.waveshare.com/pi4-fan-pwm.htm}}|PI FAN 3007]]
 
|img=[[File:精修风扇1.jpg|400px|{{Amazon_nolink|default={{#ifeq: {{#urlget:amazon|0}}|{{#urlget:Amazon|0}}| default|}}|url=link=https://www.waveshare.com/pi4-fan-pwm.htm}}|PI FAN 3007]]
 +
|img2=[[File:PI4-FAN-PWM-details-5.jpg|300px|{{Amazon_nolink|default={{#ifeq: {{#urlget:amazon|0}}|{{#urlget:Amazon|0}}| default|}}|url=link=https://www.waveshare.com/pi4-fan-pwm.htm}}]]
 
|caption=Armor lite heatsink with pwm fan for Raspberry Pi 4B
 
|caption=Armor lite heatsink with pwm fan for Raspberry Pi 4B
 
|brand=Waveshare
 
|brand=Waveshare
Line 8: Line 11:
 
|website_en=[https://www.waveshare.com/pi4-fan-pwm.htm Website]
 
|website_en=[https://www.waveshare.com/pi4-fan-pwm.htm Website]
 
}}
 
}}
 +
=Instroduction=
 
==Overview==
 
==Overview==
 
This is a thin and lightweight heat sink, equipped with a 3510 ultra-quiet cooling fan, and the fan supports PWM speed regulation, which is perfectly compatible with Raspberry Pi OS. Other systems need to manually write python or C code to drive the fan speed through PWM.<br>
 
This is a thin and lightweight heat sink, equipped with a 3510 ultra-quiet cooling fan, and the fan supports PWM speed regulation, which is perfectly compatible with Raspberry Pi OS. Other systems need to manually write python or C code to drive the fan speed through PWM.<br>
 
{{Note|NOTE: Supports Raspberry Pi 4B Only, Automatic speed control function only supports Raspberry Pi OS.|warn}}
 
{{Note|NOTE: Supports Raspberry Pi 4B Only, Automatic speed control function only supports Raspberry Pi OS.|warn}}
 
==Features==
 
==Features==
* Lightweight and silent
+
* Lightweight and silent.
* Support PWM control speed regulation
+
* Support PWM control speed regulation.
* Compatible with official system configuration
+
* Compatible with official system configuration.
* Easy to install and fix
+
* Easy to install and fix.
* Good heat dissipation effect
+
* Good heat dissipation effect.
 
==Gallery==
 
==Gallery==
 
* Product Outlook
 
* Product Outlook
Line 26: Line 30:
 
* Specifications
 
* Specifications
 
{|
 
{|
|[[File:精修风扇1.jpg|left|320px]]
+
|[[File:PI4-FAN-PWM-details-13.jpg|none|320px]]
|[[File:Detailszp0110.jpg|none|320px]]
+
|[[File:PI4-FAN-PWM-details-11-3.jpg|320px]]
|[[File:降温.jpg|none|320px]]
+
|[[File:PI4-FAN-PWM-details-11-4.jpg|320px]]
 
|}
 
|}
  
 
==Package Includes==
 
==Package Includes==
[[File:清单图1.jpg|right|250px]]
+
[[File:PI4-FAN-PWM-details-pack.jpg|600px]]
 +
* 1 x FAN Adapter <code style="background:red;color:white">(OPTIONAL)</code>
 
* 1 x Armor lite heatsink with pwm fan for Raspberry Pi 4B
 
* 1 x Armor lite heatsink with pwm fan for Raspberry Pi 4B
 
* 1 x Screw driver
 
* 1 x Screw driver
Line 41: Line 46:
  
 
==How to assemble==
 
==How to assemble==
[[File:Zp0110安装1.jpg|left|800px]]
+
1. Paste the thermal pad to Raspberry Pi 4B as shown:<br />
<br style="clear:both;">
+
[[File:PI4-FAN-PWM-details-11-1.jpg]]<br />
[[File:Zp0110安装2.jpg|left|800px]]
+
2. Fix the heat sink with screws from the back of the Raspberry Pi:<br />
<br style="clear:both;">
+
[[File:PI4-FAN-PWM-details-11-2.jpg]]<br />
{{Note|When used with FAN Adapter, the default PWM pin is D12 pin ,You can switch to TXD or D18 by modifying the 0R resistor|warn}}
+
3. Connect the wires to Pi4B directly.<br />
==How to control fan speed==
+
{{Note|The PWM pin can be connected to TXD(GPIO14)/GPIO12/GPIO18.|warn}}
* Controled by Raspberry Pi OS:
+
[[File:PI4-PWM-FAN-03.jpg|600px]]<br />
{{Note|We assume you have a Raspberry Pi OS installed.|info}}
+
4. Connect the wires to FAN Adapter.<br />
1.Connect the pins of the cooling fan to the Raspberry Pi or FAN Adapter.Make sure you have already connected the Red wire to 5V, Black wire to GND pin, and Blue Wire to PWM (GPIO 12).<br />
+
{{Note|When used with FAN Adapter, the default PWM pin is D12(GPIO12), You can switch to TXD or D18 by modifying the 0R resistor.|warn}}
[[File:FAN-Adapter-V2-PINS.png|thumb|left|400px]]
+
[[File:PI4-FAN-PWM-details-11-4.jpg]]<br />
<br style="clear:both;">
+
{{Raspberry Pi PWM FAN Control Manual}}
2. Turn on Raspberry Pi and login, open a terminal and enable Fan control as following Steps:
 
Typing following command in terminal:<source inline> sudo raspi-config </source><br />
 
3. Navigate to <code style="background:red;color:white">Performance options</code><br />
 
4. Navigate to <code style="background:red;color:white">Fan</code><br />
 
5. Select <code style="background:red;color:white">yes</code><br />
 
6. Input <code>12</code> means using GPIO 12 as PWM output Pin.<br />
 
7. Change threashold trigger temperature to 60 degrees.<br />
 
8. Confirm it.<br />
 
9. Navigate to <code style="background:red;color:white">Finish</code> and reboot Raspberry Pi as it required to take effect.<br />
 
<gallery>
 
File:PI-FAN-CONTROL-01.png
 
File:PI-FAN-CONTROL-02.png
 
File:PI-FAN-CONTROL-03.png
 
File:PI-FAN-CONTROL-04.png
 
File:PI-FAN-CONTROL-05.png
 
File:PI-FAN-CONTROL-06.png
 
File:PI-FAN-CONTROL-07.png
 
</gallery>
 
<br style="clear:both;">
 
{{Note|In this case, the fan will be triggered to rotate only when the CPU temperature of the Raspberry Pi reaches 60 degrees, otherwise the fan will not spin.|error}}
 
 
 
==How to enable it via Programming==
 
* Make sure RPi.GPIO library has been installed.
 
<source>  pip freeze |grep RPi.GPIO </source>
 
If feedback is: <source>RPi.GPIO==0.7.0</source> means library is OK.
 
* Open a terminal and create a file named: pwm-fan.py
 
* Copy and paste following code into the file and save it.
 
<source lang="python">
 
import RPi.GPIO as GPIO
 
import time
 
import subprocess
 
 
 
GPIO.setmode(GPIO.BCM)
 
##Set to false, other processes occupying the pin will be ignored
 
GPIO.setwarnings(False)
 
GPIO.setup(12, GPIO.OUT)
 
pwm = GPIO.PWM(12,100)
 
 
 
print("\nPress Ctrl+C to quit \n")
 
dc = 0
 
pwm.start(dc)
 
 
 
def ReadTemp():
 
        # view CPU temperature
 
        file = open("/sys/class/thermal/thermal_zone0/temp")
 
        cpu = float(file.read()) / 1000
 
        file.close()
 
        print('CPU temperature is: %2.2f' % cpu)
 
        time.sleep(5)
 
  
try:
+
=FAQ=
    while True:
+
=Support=
        temp = subprocess.getoutput("vcgencmd measure_temp|sed 's/[^0-9.]//g'")
+
{{Servicebox1}}
        ReadTemp()
 
        if round(float(temp)) >= 40:
 
            dc = 100
 
            pwm.ChangeDutyCycle(dc)
 
            time.sleep(0.05)
 
        else:
 
            dc = 0
 
            pwm.ChangeDutyCycle(dc)
 
            time.sleep(0.05)
 
except KeyboardInterrupt:
 
    pwm.stop()
 
    GPIO.cleanup()
 
    print("Ctrl + C pressed -- Ending program")
 
</source>
 
* Execute it by typing:
 
<source>python3 pwm-fan.py </source>
 
* The fan will be turned on when the CPU temperature is reached to 65 degrees.
 
 
</div>
 
</div>

Latest revision as of 06:51, 16 April 2024

PI4-FAN-PWM
PI FAN 3007

Armor lite heatsink with pwm fan for Raspberry Pi 4B
PI4-FAN-PWM-B
PI4-FAN-PWM-details-5.jpg
{{{name3}}}

{{{name4}}}

{{{name5}}}

Instroduction

Overview

This is a thin and lightweight heat sink, equipped with a 3510 ultra-quiet cooling fan, and the fan supports PWM speed regulation, which is perfectly compatible with Raspberry Pi OS. Other systems need to manually write python or C code to drive the fan speed through PWM.

NOTE: Supports Raspberry Pi 4B Only, Automatic speed control function only supports Raspberry Pi OS.

Features

  • Lightweight and silent.
  • Support PWM control speed regulation.
  • Compatible with official system configuration.
  • Easy to install and fix.
  • Good heat dissipation effect.

Gallery

  • Product Outlook
精修风扇1.jpg
Zp0110back.jpg
Zp0110精修.jpg
  • Specifications
PI4-FAN-PWM-details-13.jpg
PI4-FAN-PWM-details-11-3.jpg PI4-FAN-PWM-details-11-4.jpg

Package Includes

PI4-FAN-PWM-details-pack.jpg

  • 1 x FAN Adapter (OPTIONAL)
  • 1 x Armor lite heatsink with pwm fan for Raspberry Pi 4B
  • 1 x Screw driver
  • 2 x M2.5x6mm Screws
  • 4 x Thermal Pad
  • 1 x Instructions


How to assemble

1. Paste the thermal pad to Raspberry Pi 4B as shown:
PI4-FAN-PWM-details-11-1.jpg
2. Fix the heat sink with screws from the back of the Raspberry Pi:
PI4-FAN-PWM-details-11-2.jpg
3. Connect the wires to Pi4B directly.

The PWM pin can be connected to TXD(GPIO14)/GPIO12/GPIO18.

PI4-PWM-FAN-03.jpg
4. Connect the wires to FAN Adapter.

When used with FAN Adapter, the default PWM pin is D12(GPIO12), You can switch to TXD or D18 by modifying the 0R resistor.

PI4-FAN-PWM-details-11-4.jpg

How to control fan speed

  • Controlled by Raspberry Pi OS:
We assume you have a Raspberry Pi OS installed.

1. Connect the pins of the cooling fan to the Raspberry Pi or FAN Adapter. Make sure you have already connected the Red wire to 5V, the Black wire to the GND pin, and Blue Wire to PWM (can be connected to TXD(GPIO14)/GPIO 12/GPIO18).
PWM-FAN-PIN-Definition.jpg
2. Turn on Raspberry Pi and log in, open a terminal and enable Fan control as following Steps: Typing following command in terminal:sudo raspi-config
3. Navigate to Performance options
4. Navigate to Fan
5. Select yes
6. Input 12 means using GPIO12 as PWM output Pin.

If you connect to TXD(GPIO14),pls using GPIO14 as PWM output Pin.

7. Change the threshold trigger temperature to 60 degrees.
8. Confirm it.
9. Navigate to Finish and reboot Raspberry Pi as required to take effect.


In this case, the fan will be triggered to rotate only when the CPU temperature of the Raspberry Pi reaches 60 degrees, otherwise the fan will not spin.

How to enable it via Programming

  • Make sure RPi.GPIO library has been installed.
pip freeze |grep RPi.GPIO
If feedback is:
RPi.GPIO==0.7.0
means library is OK.
  • Open a terminal and create a file named: pwm-fan.py
  • Copy and paste following code into the file and save it.

Demo1

import RPi.GPIO as GPIO
import time
import subprocess

GPIO.setmode(GPIO.BCM)
##Set to false, other processes occupying the pin will be ignored
GPIO.setwarnings(False)
GPIO.setup(12, GPIO.OUT)
pwm = GPIO.PWM(12,100)

print("\nPress Ctrl+C to quit \n")
dc = 0
pwm.start(dc)

def ReadTemp():
        # view CPU temperature 
        file = open("/sys/class/thermal/thermal_zone0/temp")
        cpu = float(file.read()) / 1000
        file.close()
        print('CPU temperature is: %2.2f' % cpu)
        time.sleep(5)

try:
    while True:
        temp = subprocess.getoutput("vcgencmd measure_temp|sed 's/[^0-9.]//g'")
        ReadTemp()
        if round(float(temp)) >= 40:
            dc = 100
            pwm.ChangeDutyCycle(dc)
            time.sleep(0.05)
        else:
            dc = 0
            pwm.ChangeDutyCycle(dc)
            time.sleep(0.05)
except KeyboardInterrupt:
    pwm.stop()
    GPIO.cleanup()
    print("Ctrl + C pressed -- Ending program")

Demo2

import RPi.GPIO as GPIO
import time
import subprocess as sp


# initializing GPIO, setting mode to BOARD.
# Default pin of FAN Adapter is physical pin 32, GPIO12; 
Fan = 32  #if you connect to pin txd physical pin 8, GPIO14,then set to :Fan = 8
GPIO.setmode(GPIO.BOARD)
GPIO.setup(Fan, GPIO.OUT)

p = GPIO.PWM(Fan, 50)
p.start(0)

try:
    while True:
        temp = sp.getoutput("vcgencmd measure_temp|egrep -o '[0-9]*\.[0-9]*'")
        # print(temp)
        if float(temp) < 48.0:
            p.ChangeDutyCycle(0)
        elif float(temp) > 48.0 and float(temp) < 60.0:
            p.ChangeDutyCycle(100)
            time.sleep(0.1)
        elif float(temp) > 60.0:
            p.ChangeDutyCycle(100)
            time.sleep(0.1)

except KeyboardInterrupt:
    pass
p.stop()
GPIO.cleanup()

Run Demo code

  • Execute it by typing:
python3 pwm-fan.py
  • The fan will be turned on when the CPU temperature is reached to 65 degrees.
The PWM control pin in the code needs to be changed according to the GPIO pin actually connected.
  • If you connect TXD (GPIO14), the corresponding number in the code needs to be changed to 14;
GPIO.setup(14, GPIO.OUT)
pwm = GPIO.PWM(14,100)

if it is connected to FAN Adapter, the default is to connect D12 (GPIO12), run the code as follows:

GPIO.setup(12, GPIO.OUT)
pwm = GPIO.PWM(12,100)

FAQ

Support



Technical Support

If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 AM GMT+8 (Monday to Friday)