How to Upgrade your 3D Printer with a Filament Runout Sensor

In this tutorial, we’ll guide you through the process of using an endstop switch as a filament runout sensor on an Ender 3 and updating the Marlin firmware to support this new feature.

In the ever-evolving world of 3D printing, enthusiasts are constantly seeking ways to enhance the capabilities of their machines. One particularly popular and valuable upgrade is the addition of a filament runout sensor. This small device acts as a vigilant guardian, always on the lookout for the dreaded scenario of filament depletion during a print job. When it senses that your filament spool is running low, the runout sensor springs into action, promptly pausing the print. This intervention allows you to replace the filament spool and seamlessly resume the print job, all without a hitch.

But why is this upgrade important? Imagine starting a lengthy print only to return later to a partially completed, abandoned project due to an unnoticed filament outage. The result is wasted time, material, and, most frustratingly, the disappointment of a failed print. The filament runout sensor prevents such frustrations by providing a fail-safe mechanism that saves you not only precious hours but also costly materials. It allows you to confidently embark on long print jobs, even those that may take hours or days, knowing that your 3D printer will pause and wait for you when necessary.

In this tutorial, we’ll adapt a simple endstop switch and use it as a filament runout sensor. That’s an interesting alternative because it allows you to transform a readily available and affordable component into a valuable tool without the need for specialized sensor kits or expensive upgrades. This DIY approach not only saves you money but also provides a hands-on learning experience in customizing and improving your 3D printer’s capabilities to suit your specific needs.

Parts Required

  • Endstop switch (with the wiring and connectors)
  • Case to adapt the endstop switch. Here we’re using a slightly modified version of this case.
  • 2 short M3 screws (to attach the switch to the case)

Mounting and Connecting

  • Print the case in a color of you choice.
  • Place the endstop switch in the case and attach it with the M3 screws.
  • Plug in the connector of the enstop. Make sure you know which side is the signal (S) pin.
  • Place the sensor in the position you want in your printer and run the filament through it. You may want to add a piece of PTFE tubing on the other side as well.
  • Connect the sensor to your motherboard. The boards usually come with a 3 pin connector for the filament runout sensor, but using this endstop switch we’ll only need to connect the Ground (G) and Signal (S) pins. See below a schematics of the connection for Creality’s v4.2.2 mother board:

Updating Marlin Firmware

Now that the sensor is physically installed, you’ll need to update the printer’s firmware to support this upgrade. In this previous tutorial, we guided you through the process of downloading, compiling, and flashing Marlin Firmware to your printer. To update Marlin to support the filament runout sensor, you’ll just need to follow that tutorial, but making the following changes:

  • In the configuration.h file, uncomment the #define FILAMENT_RUNOUT_SENSOR, and the #define NOZZLE_PARK_FEATURE lines.
  • In the configuration_adv.h file, uncomment the #define ADVANCED_PAUSE_FEATURE

Take into consideration that these are the changes needed for adding the filament runout sensor on an Ender 3 using Creality’s v4.2.2 motherboard. Depending on the model of your printer and the board you’re using, you may need to make slightly different changes.

After making those changes, simply compile and flash Marlin to your printer’s board.


That’s it! With your filament runout sensor successfully installed and Marlin firmware updated, you can now enjoy uninterrupted 3D printing. See below what happens when your filament runs out:

Any doubts? Let us know in the comment section below!


[1] Marlin Firmware documentation

Leave a Reply

Your email address will not be published. Required fields are marked *

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.