BTT Smart Filament Sensor on Custom Marlin FW

Apologies if i am posting in the wrong forum for this.

I am currently running 8x Ender 3's on Marlin 2.0.bugfix with runout detection enabled for the BTT Smart Filament Sensor. The runout detection runs perfectly when printing from an SD Card but not when I am running a job from Repetier Server (Pro). I understand that the runout detection only works when marlin is aware of a job running which, i understand is not the case when Repetier is sending the instructions directly to the printer bypassing Marlin. 

My question is this, is it possible to set up some 'listening' code to detect when the filament runout detection is triggered and then respond to that action mimicking the pause-->park nozzle-->retract filament process?

Looking at 'G-Codes' under printer settings, it seems like 'Response to Event' is exactly what I'm looking for, but I am very new to this and any guidance or pointing me to some documentation would be greatly appreciated.

Thanks for your time


  • The problem is in deed that many firmwares do not send any message when runout is triggered. And without any message the server can not react. Matlin has many options and I can not say how to make it send something in which case. You should check by manually triggering the sensor if you get any message. On messages known we call the filament dialog. But you were correct you can use Response to event to send 


    and it would show the filament change dialog when the expression is found in printer output.

    I know marlin has compile options to send messages to host as well. Just this is often disabled or configured to be handled firmware intern and intern is not when printing externally as you already figured out also we set the marlin print timer on start.
  • Thanks for the response. I've been looking at the compiling software and there's a note that says the following:

     * Filament Runout Sensors
     * Mechanical or opto endstops are used to check for the presence of filament.
     * IMPORTANT: Runout will only trigger if Marlin is aware that a print job is running.
     * Marlin knows a print job is running when:
     *  1. Running a print job from media started with M24.
     *  2. The Print Job Timer has been started with M75.
     *  3. The heaters were turned on and PRINTJOB_TIMER_AUTOSTART is enabled.

    I've looked, and the PRINTJOB_TIMER_AUTOSTART is enabled. But that hasn't solved it. 

    I'll have a bit of a hunt around to see if I can figure out how to get marlin to send messages to host.


  • We also send on print start
    M530 S1 L{i:numLayer}
    M531 {s:filename}
    M532 X0 L0
    so also the M75 condition is met. 
    Please keep me informed when you find a solution and especially if there is a unknown message.

    Known tests for marlin responses we know are catched with this from Marlin.xml in firmwares folder:

    <response type="outOfFilament">^echo:Insert filament and send M108</response>
    <response type="outOfFilamentPause" string="true">//\s*action:out_of_filament\b\s*(T\d+)?</response>
    <response type="outOfFilamentPause" string="true">//\s*action:pause filament_runout\b\s*(T\d+)?</response>
  • Thanks for the assist. I'll give that a try. 

    Just to confirm the usage, did you include that in the slicer software precursory code or is that placed in the "Run Before Job" event dependency?

  • We have an independent set of gcode that we send on start and end of a job. So that is what we send in case marlin firmware is selected. It is send before the custom server start gcode which gets followed by the print gcode.
  • Hi again, thank you for the assistance so far.

    I have an update, but it's not all good news, maybe you could help me figure this out because I'm clearly doing something wrong...

    I can get the filament sensor to trigger through jobs sent from Repetier Server using the M75 code but it seems to be triggering at the very start of the print. Below is a list of things i've tried so far.

    -Confirmed the HIGH/LOW state of the sensor with M119, when filament is present, the response is "open"
    -inserted "M75" into the 'run before job' event dependency (triggers at the start of the print"
    -inserted "M75" into the slicers (Cura) precursory G-code at the beginning (before setting E0 and Bed temperatures)
    -inserted "M75" in to the slicers precursory G-Code at the end (after G28).

    All three attempts have resulted in the sensor triggering at the start of the print when filament is present.

    I would love to hear your thoughts on this.


  • Sure open is what it should send when filament is inserted? To me it sounds like M75 enables the test and when the signal is for out of filament it directly triggers the signal.

    As simple test remove filament or bypass sensor and see if it does not stop any more. Then during print insert filament and if it stops the signal is just the wrong way around and needs to be inverted.
Sign In or Register to comment.