The Ender 3 does not come with a filament runout sensor built in, unlike some higher end printers such as the Prusa MK3. Many of the 32bit boards available for use on an Ender 3 have open connectors for filament runout sensors so if you have already swapped your board then you have this as an option. Installing the smart filament sensor on your Ender 3 is not difficult but will require some firmware changes and some printed parts. Let’s dive in!
Why Add a Smart Filament Runout Sensor to the Ender 3?
A filament runout sensor will protect your long prints from failure if your filament snaps or runs out. The printer will stop printing and wait for you to fix the issue and reload filament before continuing the print. The BigTreeTech smart filament sensor is an improvement over the standard sensor in that it not only detects if filament is present in the sensor but also that it is moving as expected, providing added protection from a tangle or a clog.
How to Add a Smart Filament Runout Sensor to the Ender 3?
There are multiple ways to connect this sensor to a printer depending on your hardware and what you want to do with it. If possible I would suggest connecting it directly to the main board which will work with printing off the micro SD card on the printer. I have seen some reviewers state that if you connect the sensor to the mainboard it will not work with Octoprint but it does still work so long as you have made the necessary firmware changes.
You could also just connect the sensor directly to a raspberry pi and control it through an octoprint plugin or if you have a BigTreeTech TFT LCD screen then there is also a port on that. I’m connecting the sensor directly to the main board and then enabling its use through octoprint as that covers all of my use cases for printing. I either print via octoprint or directly off the SD card so this is the most versatile option for me.
I am choosing to mount this sensor to the top of the printer frame up by the filament spool holder because I have a direct drive system and I do not want any more mass on my X gantry. If you are running a bowden system then most of this guide will apply to you. The key difference will be that you are connecting the sensor in between the extruder and the hot end using the bowden tube and your cable routing will be slightly different.
Supplies Needed
- BigTreeTech Smart Filament Sensor
- ~300mm of PTFE Tubing (if mounting for direct drive)
- Three M5 screws (two 45mm and one 16mm)
- Two M5 T-Nuts
- One M5 Nylock Nut
- 3D Printed Parts
Steps to add a Smart Filament Runout Sensor to the Ender 3
1) Print the required parts
Obviously before you start taking apart your printer you want the required parts printed and ready to use. For this modification you will be printing a new backplate for the sensor as BigTreeTech really didn’t give a lot of thought on how to mount this sensor. I designed this part to allow for mounting on the top extrusion of the printer and it is designed for a direct drive modified printer.
In addition if you are mounting your spool holder on the top extrusion you will want the spool holder adapter so that you can rotate it 90 degrees and raise it up 40mm to not bump the sensor. You will likely also want to print at least a few of the extrusion inserts so that you can cleanly run your sensor wire in the channels and not need to worry that the wires will get caught on the X carriage.
2) Replace the backplate of the BTT smart filament sensor with the printed part
Remote the 6 screws from the back of the sensor and set them aside. Remove the back plate and replace it with the printed part. Attach the new backplate with the original screws.
3) Mount the printed parts to the top of the printer
Attach the filament sensor to the center of the top extrusion with an M5x16mm screw and t-nut. Next to the sensor mount the filament spool holder with the two M5x45mm screws, use a t-nut in the front and a nylock nut in the back. Adjust the distance between the two parts if needed to ensure your spools fit above the sensor without catching on anything.
4) Unplug the printer
This seems obvious but I’m stating it anyways. NEVER mess with the electronics of your printer with it plugged in. You could short something and fry the machine, or worse, yourself.
5) Open the electronics case
There are 3 screws on the top of the electronics case, remove all three and lift off the lid. Be careful as you lift to disconnect the case fan wires from the board as well so you don’t damage anything. You can set the lid aside as we’re done with it for now.
6) Run the sensor wire from the sensor down to the electronics case
The included wires for the sensor should be long enough to reach all the way down from the top of the printer to the electronics case along the left vertical extrusion. Try to leave yourself a bit of slack to allow for the sensor to be repositioned and for no strain on the wires. Use the printed inserts to hide the wire and hold it in place in the extrusion.
7) Connect the filament runout sensor to the main board of the Ender 3
For my printer I am using a BigTreeTech SKR mini e3 v1.2 board and connecting to the PT-DET pins (See image). This is not the suggested location for a filament runout sensor but the v1.2 board only has 2 pins for the filament runout location and this sensor needs 3 (you can see the 2 pins next to the red connector from my BL-touch). The pins I am using will work but you’ll need to make some additional firmware changes.
8) Close up the electronics case
This is the reverse of opening it using the 3 screws. The only thing to really note here is to make sure you don’t catch any wires and damage them. There is a convenient cutout in the lid for the Z endstop sensor that we can use for the filament sensor cable as well.
9) Connect the PTFE tube from the filament sensor to the extruder
The smart filament sensor is really designed for bowden systems, not direct drive, and BTT suggests it should be installed directly after the extruder. In a direct drive system this isn’t possible so we have 2 options. You can install it directly on the hotend, adding increased weight, or install it as I have but have a significant gap between the sensor and the extruder.
The way I am showing you to connect this comes with a major downside, as the extruder moves around the bed it will pull filament through the sensor which then may hang for a while before being pulled into the extruder. This excess filament will lead to a false positive on the sensor and triggering runout when there is nothing wrong. You can specify a massive runout length (50mm or greater) which will work to prevent a runout but will not help with a clog, or you can constrain the filament path between the two points guaranteeing there is always a set length of filament regardless of the position of the extruder.
Connecting a length of PTFE tube between the smart sensor and the extruder will provide this constrained and guaranteed length path and prevents false positives. I designed my sensor mount at a 45 degree angle specifically to allow this feature and direct the tube in a safe direction. Connecting the tube to both the sensor and the extruder and locking it in place is all you need to do.
10) Power on the printer
So long as you didn’t wire the pins incorrectly or knock out another connector nothing special should happen here. The printer should power on as normal and print as normal since we haven’t enabled the sensor in the firmware. Let’s go do that.
11) Compile the firmware
The best choice for compiling the Marlin firmware for the 32 bit boards is Microsoft Visual Studio Code. I’ve already covered the basics of this in my mainboard replacement article so if this is your first foray into this, check it out first. You will need a version of marlin that is 2.0.7 or newer if you want the option to use this sensor with octoprint.
For editing of configuration.h we need to uncomment #define FILAMENT_RUNOUT_SENSOR, #define FILAMENT_RUNOUT_DISTANCE_MM 7, #define FILAMENT_MOTION_SENSOR, and #define NOZZLE_PARK_FEATURE. In addition you will need to set the runout distance (default is 7mm) which determines at which point if the sensor doesnt detect movement to trigger a runout. You will also want to consider the nozzle park location and adjust that as you desire.
For editing of configuration_adv.h we need to uncomment #define ADVANCED_PAUSE_FEATURE, #define HOST_ACTION_COMMANDS, #define HOST_PROMPT_SUPPORT, and #define EMERGENCY_PARSER. You may want to adjust the advanced pause feature settings depending on the unload and reload lengths and speeds you want the printer to do. The host support and emergency parser are critical to allow Octoprint support.
As we did not use the suggested pin for our board I also need to edit the pins file and tell it the correct pin to use for filament runout. We are going to find the pins_BTT_SKR_MINI_E3_common pins file (located at Marlin – SRC – PINS – STM32F1) and comment out the line #define FIL_RUNOUT_PIN PC15 // “E0-STOP”. We replace that with #define FIL_RUNOUT_PIN PC12 // “PT-DET”.
Changes are done we now save and compile the firmware and we are ready to flash
12) Flash the firmware
Copy the firmware.bin file to the printer SD card, insert it in the printer, and power it on. If the firmware is flashing the boot should take a few seconds later and then you should see the new firmware version listed on the splash screen. If you send an M503 command through a terminal you should see in the return “M412 S1 D7.0” which shows us that filament runout is turned on (S0 means off) and that the runout detection length is 7mm.
13) Run a test print
OK everything is good, you’ve updated the firmware and configured it to your machine, it is time to print something. Once it is printing you can cut the filament and once it passes all the way through the extruder it should trigger the runout after another 7mm have printed. Due to the length of tube we have between the two points we have an excess of filament there and won’t see any issues.
I tried this a number of ways both printing from the SD card on the main board and from Octoprint. I cut the filament and watched it catch the problem. Unhooking the ptfe tube and pulling excess filament so that it wouldn’t keep running through the sensor. I opened the idler door of my extruder to prevent it from pulling filament through as if it was clogged. In all cases the sensor successfully tripped and brought me to the unload and reload filament options which let me save my print.
Troubleshooting
So I’ve already included this in the above steps but the biggest issue I had was that I didn’t originally have a PTFE tube between my sensor and extruder. If the extruder moved from the farthest point on the bed back to center and continued printing it would have a long length of pulled filament that would trip the sensor. Luckily this was easy to measure and calculate the fail points since it is a triangle and Pythagoras (the bane of many middle schoolers) gave us the means.
I found that for most scenarios 50mm runout would solve the issue but it would lead to a few other issues at the extremes where the runout wouldn’t trigger until it was too late to save the print. In addition 50mm of run length on a clog effectively would mean that the print is ruined and in my opinion neutralizes a lot of the benefits of this sensor. I was thinking about my Pruas MMU2 that I have on a printer at work and the constrained filament path between the MMU and the extruder and decided that would solve my problem.
Results
A job well done
The BigTreeTech smart filament runout sensor is successfully working on my modified Ender 3 printer. It correctly detects when filament fails to run through as expected due to it running out, a hotend clog, or a tangle/break in the filament. While none of these issues are common for me it only takes a single failed 30hr print for it to just ruin your week and the added piece of mind that this sensor is protecting me has made it well worth the cost and effort to get it set up.
I hope if you have chosen to follow this guide or any of my other Ender 3 upgrade guides that you have found them helpful and easy to follow. If you have any suggestions or want to let us know how your upgrade went please let us know in the comments.
Tried to install. Good tutorial. No success for me so far. stock ender board v4.2.2. almost instantly trips every time. Will try to constrain the filament path better with the bowden.
Filament constraint does not seem to be the problem. Continuing troubleshooting.
A first question, you are using the original BTT SFS sensor like in my images or the new rectangular v2? The new one has 2 sensors in it, an encoder wheel and also an endstop switch so the connection to the board and the set up in the firmware will be different.
Assuming you are using the same v1 that I used what is the runout distance you are using? If you haven’t I would double check that the pins on the sensor and the pins on the mainboard correspond and you haven’t accidentally swapped the signal and ground pins for example. Depending on which way you are looking at the sensor the order of pins is (Ground, Signal, Empty, Voltage), I’m not seeing a good image with a quick google search for the 4.2.2. board so not sure of the order on the board side and I don’t have a physical one to cross check for ya.
I had to constrain the filament path specifically because the sensor was so far above the extruder that when the toolhead moved significantly in X and Y it would pull extra material through the sensor and then as it kept printing that material would be taken up by the printer but since it was already through the encoder in the sensor it wouldn’t keep reading that it was flowing and trigger a runout. If you are seeing the sensor almost immediately trip it points to either a physical issue (incorrect wiring, damaged encoder wheel, bad wire or crimp, etc) or a firmware issue where the sensor isn’t configured correctly.
Hope this helps, thanks for reading!