# Help with runout macro

**URL:** <https://klipper.discourse.group/t/help-with-runout-macro/23917>\
**Category:** General Discussion\
**Created:** [June 16, 2025, 10:57pm UTC](https://klipper.discourse.group/t/help-with-runout-macro/23917 "2025-06-16T22:57:32Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![stolowma](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/stolowma/32/10986_2.png) [@stolowma](https://klipper.discourse.group/u/stolowma)\
**Post date:** [June 16, 2025, 10:57pm UTC](https://klipper.discourse.group/t/help-with-runout-macro/23917/1 "2025-06-16T22:57:32Z")

</div>

### Basic Information:

Printer Model: Two Trees SP5  
 MCU / Printerboard: Robin Nano V3  
 Host / SBC BTT Pad 7  
 klippy.log NA

_Fill out above information and_ **_in all cases attach your_ `klippy.log` _file_** (use zip to compress it, if too big). _Pasting your_ `printer.cfg` _is **not** needed_  
_ **Be sure to check our “Knowledge Base” Category first. Most relevant items, e.g. error messages, are covered there** _

### Describe your issue:

I have a BTT filament runout sensor with a switch that is way too sensitive. Even the slightest wobble in the filament triggers it. I looked for a macro with a sort of debounce function but didn’t find any. For the heck of it I asked ChatGPT to write one. It looks impressive but will it work? I was wondering if I could get some of the natural intelligence here to look it over and tell me.  
Thanks!  
[[filament\_switch\_sensor switch\_sens.txt](https://klipper.discourse.group/uploads/short-url/tKb0TrNZ4EUMeHf3UBinu26aqvS.txt) (3.5 KB)

…

---

<div class="post-metadata">

**Author:** ![cloakedcode](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/cloakedcode/32/2752_2.png) [@cloakedcode](https://klipper.discourse.group/u/cloakedcode)\
**Post date:** [June 17, 2025, 3:22am UTC](https://klipper.discourse.group/t/help-with-runout-macro/23917/2 "2025-06-17T03:22:03Z")

</div>

Rather than complicating the setup with lengthy macros, perhaps tuning the config will solve it instead.

I also have a BTT filament sensor (v2 I think, the bulky one) and not had any issues with sensitivity. Are you using the motion sensor in Klipper? That alone should resolve the sensitivity as it’s required to indicate no filament for a length of extrusion before Klipper accepts it as out of filament or jammed.

Here’s my config:

```auto
[filament_motion_sensor filament_sensor]
extruder: extruder
detection_length: 14
pause_on_runout: True
runout_gcode:
    M117 Filament Runout Detected
switch_pin: ^PG11

[delayed_gcode DISABLEFILAMENTSENSOR]
initial_duration: 1
gcode:
    SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=0

```

(The PRINT\_START and PRINT\_END macros enable and disable the sensor so it doesn’t trigger when not actively printing.)

I see you left off the klippy.log but it’s still relevant (it would clear up my questions about the config).

Hope that helps!

---

<div class="post-metadata">

**Author:** ![EddyMI3D](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/eddymi3d/32/1981_2.png) [@EddyMI3D](https://klipper.discourse.group/u/EddyMI3D)\
**Post date:** [June 17, 2025, 5:20am UTC](https://klipper.discourse.group/t/help-with-runout-macro/23917/3 "2025-06-17T05:20:55Z")

</div>

@stolowma  
Sidenote:

When you open a new topic, please start the text at 1, not at 2, else all is written in bold letters.

 ![grafik](https://global.discourse-cdn.com/free1/uploads/klipper/original/3X/d/7/d7d0f04876fa1dd5770cc9f3ff9f279441ede913.png)

---

<div class="post-metadata">

**Author:** ![stolowma](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/stolowma/32/10986_2.png) [@stolowma](https://klipper.discourse.group/u/stolowma)\
**Post date:** [June 17, 2025, 2:15pm UTC](https://klipper.discourse.group/t/help-with-runout-macro/23917/4 "2025-06-17T14:15:06Z")

</div>

Sorry, I didn’t realize that.

---

<div class="post-metadata">

**Author:** ![stolowma](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/stolowma/32/10986_2.png) [@stolowma](https://klipper.discourse.group/u/stolowma)\
**Post date:** [June 17, 2025, 2:49pm UTC](https://klipper.discourse.group/t/help-with-runout-macro/23917/5 "2025-06-17T14:49:21Z")

</div>

The problem is in the runout switch, it triggeres a shut down as soon as it is opened. Even a light touch on the filament near the input triggers it. It doesn’t wait to see if filament is moving or not. I had to remove the sensor because I needed the printer so that’s why no klippy file. I’ll see if I can get it hooked up tonight, compare with your config and get you further info.

---

<div class="post-metadata">

**Author:** ![stolowma](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/stolowma/32/10986_2.png) [@stolowma](https://klipper.discourse.group/u/stolowma)\
**Post date:** [June 19, 2025, 6:52pm UTC](https://klipper.discourse.group/t/help-with-runout-macro/23917/6 "2025-06-19T18:52:02Z")

</div>

@cloakedcode I haven’t tried out your config yet but I had thought about going your route and not using the “runout” switch and just relying on the motion switch. When I think about it why do you need both? I’ll try to give this a shot later today and let you know. Many thanks.

---

<div class="post-metadata">

**Author:** ![stolowma](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/stolowma/32/10986_2.png) [@stolowma](https://klipper.discourse.group/u/stolowma)\
**Post date:** [June 22, 2025, 10:41pm UTC](https://klipper.discourse.group/t/help-with-runout-macro/23917/7 "2025-06-22T22:41:34Z")

</div>

@cloakedcode I’ve finally got a chance to try a print with your config. It starts the print but very soon goes into filament runout. I notice uses switch\_pin, should that be something else like encoder\_pin to keep it from triggering when the encoder changes state? I’ve included the  
[klippy.log](https://klipper.discourse.group/uploads/short-url/uMTbT2iPDaGNeyYKJlgXEv4s3mU.log) (1.9 MB)  
kllippy.log as you requested.

---

<div class="post-metadata">

**Author:** ![cloakedcode](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/cloakedcode/32/2752_2.png) [@cloakedcode](https://klipper.discourse.group/u/cloakedcode)\
**Post date:** [June 23, 2025, 5:32am UTC](https://klipper.discourse.group/t/help-with-runout-macro/23917/8 "2025-06-23T05:32:53Z")

</div>

It has to be “switch\_pin”, that’s the only config option. There’s a “filament\_switch\_sensor” but it also uses “switch\_pin”. But here’s the BTT sample config, pick whichever matches your device:

> **[GitHub - bigtreetech/smart-filament-detection-module](https://github.com/bigtreetech/smart-filament-detection-module)**
>
> Contribute to bigtreetech/smart-filament-detection-module development by creating an account on GitHub.

On top of that, here are some further troubleshooting steps. In particular, double check that the filament after the sensor is entirely constrained or you’ll get false alarms.

> **[Setup a BTT Smart Filament Sensor](https://docs.vorondesign.com/community/howto/samwiseg0/btt_smart_filament_sensor.html)**
>
> Voron Official and Community Documentation

Try those things ^ and lemme know how it goes. I think I also went the lube/shim route to make things extra smooth (it’s been installed for years, hard to remember exactly what I did initially).

---

<div class="post-metadata">

**Author:** ![stolowma](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/stolowma/32/10986_2.png) [@stolowma](https://klipper.discourse.group/u/stolowma)\
**Post date:** [June 23, 2025, 2:23pm UTC](https://klipper.discourse.group/t/help-with-runout-macro/23917/9 "2025-06-23T14:23:41Z")

</div>

Thanks for the info. The mods listed don’t apply because this is their latest new and improved(?) model. It has a completely different mechanism. I’ll start looking at that config and see if I can find what I’m doing wrong.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/klipper/original/1X/64419bf2aac6639e6ef5cef200dcd456b0a01ac3.png) [@system](https://klipper.discourse.group/u/system)\
**Post date:** [August 22, 2025, 2:23pm UTC](https://klipper.discourse.group/t/help-with-runout-macro/23917/10 "2025-08-22T14:23:52Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
