• First Steps
  • General
  • Projects
Facebook Twitter YouTube
Tutorials for Raspberry Pi Tutorials for Raspberry Pi
  • Hardware & GPIO
  • Sensors & Components
  • Scale
  • Cases
  • Fingerprint
  • Gas Sensor
  • Heartbeat
  • German
Tutorials for Raspberry Pi Tutorials for Raspberry Pi
Home»Hardware & GPIO»Fan control for better Overclocking of the Raspberry Pi

Fan control for better Overclocking of the Raspberry Pi

Facebook Twitter LinkedIn Tumblr Email Reddit
Share
Facebook Twitter LinkedIn Email Tumblr Reddit Telegram WhatsApp

Who has his Raspberry Pi running as a Server, etc., will quickly realize that the little giant can become very hot. To a certain extent, one can surely ignore this, but if the Pi is running day and night, you should pay attention to the temperature (especially in a housing). Since I also had this problem, I took it as a project to keep the case and the CPU cool.

Accessories

I took a 5V fan and a DS18B20 temperature Sensor. The Transistor installed is a BC547. If you do not have a temperature sensor or you do not want to measure it, you can still use the Script with a small adjustment.

Setup

As Resistors, I have taken 4.7k Ohms each. The output pin for the Transistor is pin 23, although any other GPIO pin that does not have an assigned function can be taken.
Important: The temperature Sensor is connected to 3.3V, whereas the Cooler is connected to 5V.

Script

In order to make the work as easy as possible, I have already prefabricated a script that you only need to adapt.

wget https://tutorials-raspberrypi.de/wp-content/uploads/2014/04/cooler_skript.zip

and unpack:

unzip cooler_skript.zip

Well, then we’ll edit the script:

sudo nano cooler_skript.py

Here, lines 19 to 23 are important and possibly adaptable.

Python
19
20
21
22
23
24
IMPULS_PIN = 23
SLEEP_TIME = 30
MAX_CPU_TEMP = 40
MAX_SENSOR_TEMP = 30
SENSOR_ID = ''
 

Now, IMPULS_PIN simply indicates the GPIO pin, which is used to drive the transistor.

SLEEP_TIME indicates all how many seconds the temperature should be checked. I do not recommend a too small number to give the Pi more calculation time for other applications.

MAX_CPU_TEMP and MAX_SENSOR_TEMP indicate the respective temperatures at which the fan should start to rotate. It does not matter what is achieved first; as soon as one has been reached it starts to turn. If the cooler is always turning, set MAX_CPU_TEMP = 0.

Now to the sensor ID: How to get this out, I have already shown here. If you do not have a sensor, just leave it that way. For me it is e.g. the ID 10-000802b4ba0e:

Python
23
SENSOR_ID = '10-000802b4ba0e'

So far so good. Basically, we are already done. With

sudo python cooler_skript.py

the Script can already be started. If you want to have the values displayed on every check, you can delete the # in lines 59 and 60 of the Script.

Automatic starting

If you want to start the Script automatically, you can take a look at this Tutorial. Optimally you move the script to /usr/local/bin/

sudo cp cooler_skript.py /usr/local/bin/cooler_skript.py

Then you just have to adjust the names, as in line 8:

Shell
1
python /usr/local/bin/cooler_skript.py

 

Overclocking

Now that we have made sure that the Pi is always cool enough, we can also overclock:

sudo raspi-config

Under point 7 Overclock you can set the clock rate. For example, I have set Medium or High as needed. You can adjust this depending of the Application (in the case of computationally intensive usage, a higher clock rate makes more sense and brings speed at the same time).

cpu cpu temperature ds18b20 fan fan control overclock overclock overclocking overclocking python temperatursensor
Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
Previous ArticleRaspberry Pi Autostart: Start the Program automatically
Next Article Telegram Messenger on the RaspberryPi

Related Posts

Control all GPIOs with the Raspberry Pi REST API via Python

How to build a ESP8266 Scale (with Weight Sensor HX711)

Using TensorFlow Lite with Google Coral TPU on Raspberry Pi 4

How-To: Bluetooth Connection between ESP32’s and Raspberry Pi’s

1 Comment

  1. vo genesis reviews on 8. January 2020 4:22

    molliegrunwald@gmail.com

    Reply

Leave A Reply Cancel Reply

Build a digital Raspberry Pi Scale (with Weight Sensor HX711)

How to build a ESP8266 Scale (with Weight Sensor HX711)

Use C# and .NET to develop your own GUI apps for the Raspberry Pi

Raspberry Pi Home Automation: Install & Configure OpenHAB

Install Windows 10 IoT on the Raspberry Pi

Review of the 7″ Raspberry Pi Touchscreen Display

Subscribe to Blog
Subscribe to Raspberry Pi Tutorials and don't miss any new Tutorial!
Subscribe

Thank you!

We will contact you soon.

Tutorials for Raspberry Pi
Facebook Twitter YouTube
  • Contact & Disclaimer

Type above and press Enter to search. Press Esc to cancel.