Loading...
 
more
Fan Control 20200719 083039 1000w

Raspberry Pi
cooling fan control project

Fan Control 20200719 082618 1000w

 

For a project that needs a cooling fan e.g. an enclosed Raspberry Pi4 can require cooling - a small custom printed circuit board (PCB) has been designed with a circuit using an NPN transistor (S8050) and a 110Ω resistor that can switch the fan on/off by the setting of a GPIO pin HIGH/LOW.

Using this PCB, populated with its few simple components, a cooling requirement can be controlled by a short Python program that:

  • periodically checks the CPU temperature (using the 'vcgencmd measure_temp' command), and
  • switches the fan on at a threshold high temperature and switches it off again at a lower threshold temperature.

The two sides of the 'bare' PCB are shown in the image above left and the 3 images below show the various stages of a test build.

Fan Control 20200719 082855 800w Fan Control 20200719 082700 1000w Fan Control 20200719 082508 800w

 

 

Fan Control RPi4_fan_case_20210709_162042148_900w.jpg

A typical use is shown in the image on the right where a Raspberry Pi4 is mounted in a custom3D printed enclosure (shown here without its enclosing lid) and an additional custom 3D printed bracket is used to mount the PCB control board -  see here for more details.

Some simple test/development Python code (downloadable from here) has been developed that can be run continuously that:

  • on start-up reads a pair of high/low threshold temperatures and an operational wait interval in seconds from a text file
  • periodically checks the CPU temperature after each wait interval
  • switches the fan on/off depending upon the measured CPU temperature and the high/low threshold values, and
  • keeps track of the accumulative fan on/off periods of time which is then periodically written out to a log file (where the log file only keeps a maximum number of records to stop it getting bigger and bigger)

With the use of this arrangement for the PCB/fan with a Raspberry Pi4 in its fully enclosed 3D printed housing, it was found that:

  • for high/low thresholds of 45/40oC and the Raspberry Pi 4 in more or less an idle state (but obviously running the fan control code!), the fan was on for about 13% of the time in an ambient environment of c.20oC
  • but for high/low thresholds of 55/50oC and the Pi still more or less idle, the fan was always off, i.e. passive/natural convection within the enclosure was enough to keep the CPU below 55oC which is a very acceptable operational level, when the Pi is just in a idle state
  • however for another scenario, where the Raspberry Pi 4 is continuously running an Apache webserver with an associated MariaDB database, high/low thresholds of 58/48oC made the fan run for less than 10% of the time in an ambient environment of c.22oC

 

The images below further illustrate a Raspberry Pi 4 in the 3D printed fan-cooled case:

RPi4 Fan Case 20210709 161628124 900w RPi4 fan case 20210709 161924920 900w RPi4 Fan Case 20210709 162010148 900w RPi4 Fan Case 20210709 162030680 500w RPi4 Fan Case 20210709 162515276 900w

 

The 3D print designs for the case and the PCB mounting bracket can be downloaded from the Prusa web site here.

 

 

All the currently available maker project information: