3D-Printer Enclosure Fan Control

3D-Printer Enclosure Fan Control

The Tukkari TLX Enclosure

I have bought the Tukkari TLX version of 3D/printer cabinet for Prusa i3 MK3+. This nice enclosure comes as a kit and it comes with a active carbon- and HEPA filter in the kit to reduce nanoparticles and fumes that can come from the 3D printing process.

To get the sometimes toxic particles out of my room someting needs to be done.

Take a look at Tukkari’s page for the different products that the manufacture and sells>


Tukkari TLX Enclosure for Prusa i3 MK2/MK3 (White color)

Tukkari Printer Enclosure

A 120 mm. fan can be mounted either inside or on the back of your enclosure. As I plan to let the air out of the enclosure and guide it out of my room I install the fan on the back of the enclosure as shown here. The bolts are already included in the kit when buying the enclosure from Tukkari

Installing a fan to the enclosure (optional)

The enclosure comes with a filter that you can be mounted either on the inside or at the outside of the enclosure. As I want to mount a fan on the outside I mounted the filter on the inside.

The fan is an optional thing and are not included with the enclosure kit from Tukkari.

I ordered a 120 mm. noctura low noise 5V version to be able to power it from the Raspberry Pi I use as printer server.

In my case I ordered the Ultra Low Noise NF-F12 5V fan (5V USB cable included).

This noctua fan comes with different cable parts. When adding the USB Type-A to the end the cable length is long enough to be router from the back of the enclosure and into the left (seen from the front of the enclosure) cable entry and the to be mounted into one of the USB connectors on the raspberry Pi that I have added to the printer aluminum profile with a 3D printed box

Note! The image is for the PWM version. In the 5V version the cable part (USB-A) is included

Link to the fan at noctua’s webpage:


Setting up Octoprint to to start and stop the enclosure fan

To be able to control the Fan in the enclosure several things needs to be done

Adding system menu’s to control the USB power on the Raspberry PI

Shell scripts to control power to USB connector on Raspberry Pi

I created two different shell scripts. One to turn on USB power and one to turn off the USB power. In my case I use the Raspberry Pi 3B+. The version has 4 USB-A ports. Unfortunately these are all controlled simultaneously. If you turn off one the three others also will be powered off. In my case I have a Webcam, the fan and a LaMetric display connected to my Raspberry Pi. That is not a problem that they are all turned off when I want to turn of the power for the fan for the enclosure. On the Raspberry Pi 4 you can turn the two blocks of 2 USB connectors on and off independently

To be able to turn of the power for the USB connectors from the command line you first need to install the uhubctl USB Power Contrll package. This can be installed like here:

git clone https://github.com/mvp/uhubctl
cd uhubctl

This should generate uhubctl binary. You can install it in your system as /usr/sbin/uhubctl using:

sudo make install

Then you can call this library

usb_on.sh contains:
sudo /home/pi/uhubctl/uhubctl -l 1-1 -p 2 -a on

usb_off.sh contains:

sudo /home/pi/uhubctl/uhubctl -l 1-1 -p 2 -a off

To be able to call these two scripts from the Octoprint UI I will add two commands to the System menu on the printer interface. This can be done by changing the config.yaml file which can be found in the

/home/pi/.octoprint folder

Edit the config.yaml file and add the following code (place it in just before the temperature: part of the file.

  - action: Uoff
    command: /usr/local/bin/scripts/usb_off.sh
    name: Turn USB Power Off
  - action: Uon
    command: /usr/local/bin/scripts/usb_on.sh
    name: Turn USB Power On

After this and restarting the Octoprint you can then find two new commands in the Octoprint userinterface

User rights to run the shell command from Octoprint

Some more thing needs to be done before being able to control the USB power from Octoprint. You need to change the user rights for this.

Go to a shell and do the two following chmod commands

chmod a+x /usr/local/bin/scripts/usb_off.sh


chmod a+x /usr/local/bin/scipts/usb_on.sh

This will add permission for all users to execute the two .sh files

chmod: change mode (permissions) of a file.
a+x: for all (a) users, add (+) the execute (x) permission

Now trying this out from the system menu results in the following where we get "Success" response from the system:

Make the fan turn on and off automatically when printing

To be able to turn on the printer when starting to 3D print it can be nice if this can be done using G-CODE commands that is commonly being used in computer-aided manufacturing to control automated machine tools like 3D-printer and CNC milling machines.

When in my case the PrusaSlicer tool slices a STL file into a machine script file, it could be nice also to be able to turn the enclosure fan on before starting to print. And to turn it off again after the print has been finalized.

Lets define two G-Code commands. In my case have made GCODE10 which call the usb_on script and a GCODE11 which calls the usb_off script. Look below to see the two definitions

Now we have these we need to be able to inject those GCODE commands during a print of a part. The most of the GCODE comes from the PrusaSlicer output file.

In the menu Printer | GCODE Scripts you are able to add more commands that call be call before, after a job completes and after a job is cancelled and after a job is paused.

In this case we will add the two newly defined GCODE commands in the start and after job completes section of this setup page. Look here where marked with arrows.

Now the enclosure fan turns on when the print job starts. And after the print completes it automatically turns off the enclosure fan turns off.

Adding a Fan Shroud to the backside of the fan

To be able to attach a tube to let the fumes out of the enclosure to open air. A shroud is needed to be attached to the fan on the rear side of the enclusure.

As this is a 120 mm fan I get the measures from a drawing which shows the default hole position for such a fan. I design it in SolidWorks. In version 3 of the file the holes has been changed to 4.2 mm. each and not 4.0 as can be seen on the image below

Here a viewer showing the final STL 3D-file. Below you can download a copy and print it for yourself for free.

Loading file
  • Fullscreen
  • Wireframe
  • Zoom In
  • Zoom Out
  • Rotation
  • Screenshot
  • Help


  • Rotate with the left mouse button.
  • Zoom with the scroll button.
  • Adjust camera position with the right mouse button.
  • Double-click to enter the fullscreen mode.
  • On mobile devices swipe to rotate.
  • On mobile devices pinch two fingers together or apart to adjust zoom.
  • On mobile devices 3 finger horizontal swipe performs panning.
  • On mobile devices 3 finger horizontal swipe performs panning.

Here you are welcome to download the file:

Or you can now also find it on Thingiverse where I have created it to my list of designs:


My other Thingiverse design:


That’s it!

Mission Complete!!

Share this content:

Leave a Reply