Adding Filament Runout Detection to an Anycubic Kossel with Marlin 1.1.8 and BIQU 3D Filament Detection Module

I have several Anycubic Kossel 3D Printers that work great for the price ($180-320 depending on the model).  One issue I’ve run into is when a reel of filament gets low, I can’t reliably print with it for fear of running out mid-print and wasting the plastic.  With some changes to the Marlin firmware (version 1.1.8 as of this writing) and adding a sensor for less than $5, I was able to fix this!  The inspiration came from a Thingiverse model by Nenex that mounts this cheap sensor to the 2020 extrusions that make up most of the Anycubic Kossel’s body.


BIQU 3D Filament Detection Module

Marlin Firmware

Arduino IDE



Print the two parts from Thingiverse to attach the sensor to the 3D printer.  You will also need two M4x12 screws, two M4 t-nuts, and two M3x25 screws.

Install the 2020 extrusion mount with two t-nuts and M4 screws. I only had 10mm screws, not the 12mm called for and had to drill the hole out a little


Chamfering the Brass Guides

Before assembly, I suggest taking the sensor apart and chamfering the brass guides that the filament rides in.  Without this, I was getting significant scraping on the filament and the PLA bits were beginning to build up inside the sensor.

Pry the case open with a knife or sponger


Inside the case is the contact switch, circuit board, and brass guides


With the filament in, it should push the contact switch down


Push the two brass guides out a little with something like this Allen Key


Pull them the rest of the way out being careful not to crush it


With a drill bit or something like this countersink bit, chamfer the inside and outside edges so they don’t catch on the filament and scrape it


It should look something like this when done and allow the filament to slide through it easily


Cable Install

Reassemble the sensor and install it to the 2020 extrusion mount with the M3x25 screws.  Plug the cable into the sensor.  It will only go in one way.

The plate is unnecessary since the sensor has an arrow showing the correct filament direction, but it doesn’t hurt to put it on


The cable only plugs in one way


Installed without power or filament will not light up the green LED inside


Make sure the power is off and then remove the bed and plug the cable into the S0 header pins.  The cable can go both ways and mine works with the red wire plugged into the header farthest from the stepper motor drivers in the S pin.  If you wire it backwards, everything will appear to function until the sensor doesn’t have filament and then the board will shut off.  Reinstall the bed and turn the power back on.

Remove the bed to get access to the Tri-Gorilla main board


Header S0 is what we need to plug into


The red wire should be the sensor wire and goes away from the stepper motor drivers


With power and filament you should see this green light on


Changing Marlin Firmware Settings

You can download my copy of Marlin and adjust the size for your own printer (my z-height is shorter than stock since I replaced the pulleys with shorter linear rails) or go in and change the needed settings in your own copy of Marlin.

This printer is a newer one by Anycubic that comes with the power supply, heated bed, and bed leveling.  Because of that, my settings for the Z-endstop are specific for it.

If you download mine, some settings to adjust in Configuration.h are:

  • Line 89: #define STRING_CONFIG_H_AUTHOR
  • Line 139: #define CUSTOM_MACHINE_NAME
  • Line 538: #define DELTA_HEIGHT (should be closer to 320mm)
  • Line 589: #define Z_MIN_ENDSTOP_INVERTING false (some other sensors use true)
  • Line 593: #define Z_MIN_PROBE_ENDSTOP_INVERTING false (same reason)
  • Line 780: #define Z_PROBE_OFFSET_FROM_EXTRUDER -15.49


If you download your own copy of Marlin from, you can get it setup for your own printer and turn on the filament runout sensor with these changes (use the Find tool in the Arduino software):

In pins_RAMPS.h change line 255 to:

  • #define FIL_RUNOUT_PIN 11

In Configuration.h uncomment:


In Configuration_adv.h also uncomment:

  • #define PARK_HEAD_ON_PAUSE


Flash your new firmware by plugging into your computer with the USB cable Anycubic sends with their printers.  Under the Tools menu in the Arduino IDE change the board to Arduino/Genuino Mega or Mega 2560 and change the Processor to ATmega 2560 (Mega 2560), and click Upload.

If all goes well, your 3D printer will reboot and should give you the option to change filament when the hot end heats up, and if the filament runs out mid-print will prompt you to change it!


WIth the new firmware, you should see a “Change filament” option under “Prepare” when the hotend is on and it should prompt you to change the filament when the sensor is triggered


The guide to change the filament when it runs out is very straightforward and helpful

Leave a Reply