Can Octoprint Control The New Raspberry Pi Case Fan On/Off Temperature?

Hi all,

Is there a way to control a pi fan to turn on when my raspberry pi hits a certain temperature instead of being always on?

I understand that this question has been asked a lot, and there are guides out there involving soldering pythons and coding transistors, but the folks over at raspberry pi have released an official case fan (Nov' 2020) that can be temperature controlled by Raspbian, and simply requires setting a few preferences in the performance tab of the GUI. Link to product and how to set it up:

This fan comes with a built in 3rd cable that connects to a GPIO pin where raspbian OS can ask which GPIO pin (default 14), and tell it when to turn on and off at a set temperature (default 80C). Perfect. The wrinkle is that this is controlled through the Raspbian OS GUI, and I don't have a GUI set up for Octopi, much less know whether octopi even has the functionality to control the GPIO pin.

Now I'm a complete noob at this, being my first 3D printer, first Pi, never coded, can't speak parceltongue (python), nor understanding the development history of Octopi or Octoprint; so my questions are extended to the below:

  1. As Raspbian OS has the functionality to temperature control the pi's cooling fan (at least from Nov 2020) does Octopi have this functionality?
  2. If yes to Q1, can it be set without a GUI? and how would I go about doing this?
  3. If no to Q1, is there another way that I can make this thing run? Will I need to install the full Raspbian OS, and then install octoprint over the top of that just to turn a fan on and off? I understand this is also a big undertaking.
  4. If the above works, then I've seen people discuss using SystemCommandEditor in Octoprint for camera on/off (though I've not tried it yet). Is this something that could be used to control the pi fan (on / off / temp controlled) if the sudo commands exist?

I'm running the following:
Octoprint Version 1.5.2
Octopi Version 0.17.0
Raspberry Pi 4 Model B Rev 1.2

any help would be greatly appreciated!

OctoPi should be able to do it, though it depends - the current 0.17 image is from November 2019 and the 0.18rc1 is from August 2020, so you might have to get 0.18 and then upgrade it.

Once you have done that, they say there is now an option in 'raspi-config' to enable the fan on GPIO 14 or you can configure it yourself.

Apparently you can do this yourself without updating (not sure about 0.17, might be too long ago) by adding the following to the config.txt file:


I'm hoping you're able to tell what each of those items represents :wink:

Thanks for the help Charlie!

Steps I've done:
I've taken the SD card out of the Pi, put it into my Windows 10 machine. Opened Config.txt in Notepad++, and there is no line for a fan in it (as I am still on 0.17.0).
I have now added the above line that you have mentioned, and will test it in the Pi at temp=80000 (80C). I will then modify it to be at temp =10000 (10C) and see what happens. If this works I'll be super happy!

If the above doesn't work, then I will update to 0.18 and see if the line is available there.
Out of interest, how do I go about upgrading? I haven't been able to find any instructions for an upgrade, only a full replace.

Thanks again!

To upgrade, you can backup your settings in OctoPrint, and then flash the new image, then restore the backup. Or, you could manually update the packages using sudo apt update and sudo apt upgrade, I think. Not sure if a firmware upgrade would be needed in between. Probably not.

Hi Charlie,

Thanks for the advice above.

In the config.txt for Octopi 0.17.0 there is no line as you have mentioned. I added this line in with a threshold of temp=80000 (80C) and the fan is on when the Pi is first turned on, and then shut itself off after about 5 seconds (temp was reading about 40C)

I then set the threshold of temp=20000 (20C). The fan was on when the Pi first turned on, and then it stayed on during use. So it worked!

I have now set the fan to come on at 60C, though I understand this will usually be at 80C for most people as this is when CPU throttling starts.

This line may already be included in the config.txt in the newer 0.18 release, I haven't checked.

Thanks again!


Excellent! this has actually inspired me to dig out my old Pi fan, I didn't know it was a built in option until I saw your post. Then promptly went googling in the right places about that official fan addon...