# Octoprint & Smart Filament Sensor configuration

**URL:** <https://forum.snapmaker.com/t/octoprint-smart-filament-sensor-configuration/14568>\
**Category:** Snapmaker 2.0 (3-in-1)\
**Created:** [January 18, 2021, 3:42am UTC](https://forum.snapmaker.com/t/octoprint-smart-filament-sensor-configuration/14568 "2021-01-18T03:42:55Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ConsummatePro](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.snapmaker.com/consummatepro/32/7055_2.png) [@ConsummatePro](https://forum.snapmaker.com/u/ConsummatePro)\
**Post date:** [January 18, 2021, 3:42am UTC](https://forum.snapmaker.com/t/octoprint-smart-filament-sensor-configuration/14568/1 "2021-01-18T03:42:55Z")

</div>

I really want to use Octoprint for my Snapmaker A350, for all the reasons Octoprint is awesome.

The 2 features I really want is the filament runout sensor and power loss recovery - I know these aren’t currently available to 3rd party apps like Octoprint.

So, I decided to use the BigTreeTech Smart Filament sensor - it’s about $25 ($30 CAD) and hooked it up to my Pi. This unit is even more advanced in that if the filament isn’t moving, like if the head is jammed, it will also trigger, whereas other filament sensors just detect the presence of filament, whether it’s moving or not. If it triggers, the plugin will pause the print.

Here’s a guide to how I did it:

1. Smart Filament sensor cable: take the 3 pin end of the cable and take out the connectors after seeing which is V, ground and signal - see picture  
 ![Filament sensor pins](https://us1.discourse-cdn.com/flex022/uploads/snapmaker/original/2X/9/9c3087a26d8c01af0fc312670291b814da3049d4.jpeg)
2. Connect the 3 pins to your Pi GPIO pins. I used pin 1 for 3.3V, pin 9 for ground and pin 13 for signal  
 ![Pi connections](https://us1.discourse-cdn.com/flex022/uploads/snapmaker/original/2X/f/f04cfa7483a2d9c8d9ba4351650ec1f9fe1335e6.jpeg)
3. In Octoprint, install the plugin Octoprint Smart Filament Sensor ([Octoprint-Smart-Filament-Sensor](https://plugins.octoprint.org/plugins/smartfilamentsensor/))
4. Configure the plugin: see my screenshot, but **I need advice for the best pause command** for Snapmaker 2.0.  
 ![Screen Shot 2021-01-17 at 7.27.01 PM](https://us1.discourse-cdn.com/flex022/uploads/snapmaker/original/2X/4/4282684aa85595b0b9a38bb0107cd490ea174abf.png)
5. Make sure to press the “Save” button, then reload the plugin, and start the test to see if the filament movement is detected (I didn’t hit save before and it didn’t work til I did).

**But, I’m wondering about these issues: help appreciated!**

1. What is the best Pause command for the Snapmaker 2? They offer M0 (stop), M1 (Sleep), M25 (Pause SD print), M226 (G-code pause), M600 (Filament change), M601 (Pause print)  
 ![Screen Shot 2021-01-17 at 7.34.16 PM](https://us1.discourse-cdn.com/flex022/uploads/snapmaker/original/2X/2/29a27b665784f59aa883b4806ad19d7c83cae28f.jpeg)
2. What Gcode is best for “After print job is paused” “resumed” or “cancelled”? Here’s what I have so far but not sure what I really should have:

**After print job is paused**

> {% if pause\_position.x is not none %}  
> ; relative XYZE  
> G91  
> M83
> 
> ; retract filament of 0.8 mm up, move Z slightly upwards and  
> G1 Z+5 E-0.8 F4500
> 
> ; absolute XYZE  
> M82  
> G90
> 
> ; move to a safe rest position, adjust as necessary  
> G1 X0 Y0  
> {% endif %}

**Before print job is resumed**

> {% if pause\_position.x is not none %}  
> ; relative extruder  
> M83
> 
> ; prime nozzle  
> G1 E-0.8 F4500  
> G1 E0.8 F4500  
> G1 E0.8 F4500
> 
> ; absolute E  
> M82
> 
> ; absolute XYZ  
> G90
> 
> ; reset E  
> G92 E{{ pause\_position.e }}
> 
> ; WARNING!!! - use M83 or M82(extruder absolute mode) according what your slicer generates - S3D uses M82, ? Cura too?  
> ;M83 ; extruder relative mode  
> M82
> 
> ; move back to pause position XYZ  
> G1 X{{ pause\_position.x }} Y{{ pause\_position.y }} Z{{ pause\_position.z }} F4500
> 
> ; reset to feed rate before pause if available  
> {% if pause\_position.f is not none %}G1 F{{ pause\_position.f }}{% endif %}  
> {% endif %}

**After print job is cancelled**

> ; disable motors  
> M84
> 
> ;disable all heaters  
> {% snippet ‘disable\_hotends’ %}  
> {% snippet ‘disable\_bed’ %}  
> ;disable fan  
> M106 S0

1. Anyone have tips on how to do the filament change when it does run out? Should I do it using the Snapmaker’s own Filament change function or the filament change function within Octoprint?

===

I just got this working software wise but haven’t yet tested it with a live print, because I wanted suggestions for the pause and resume commands.

---

<div class="post-metadata">

**Author:** ![MooseJuice](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.snapmaker.com/moosejuice/32/10684_2.png) [@MooseJuice](https://forum.snapmaker.com/u/MooseJuice)\
**Post date:** [January 18, 2021, 3:49am UTC](https://forum.snapmaker.com/t/octoprint-smart-filament-sensor-configuration/14568/2 "2021-01-18T03:49:26Z")

</div>

Pause doesnt currently exist ☹

Snapmaker is under quite a lot of pressure to implement this for various reasons and I think it may be coming soon on the next firmware update, but not 100% sure.

---

<div class="post-metadata">

**Author:** ![Melanchrom](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.snapmaker.com/melanchrom/32/5202_2.png) [@Melanchrom](https://forum.snapmaker.com/u/Melanchrom)\
**Post date:** [January 18, 2021, 10:02am UTC](https://forum.snapmaker.com/t/octoprint-smart-filament-sensor-configuration/14568/3 "2021-01-18T10:02:10Z")

</div>

The pause is implemented in Octoprint. So it doesn’t need to be implemented in the snapmaker.

I would lift the nozzle on aborting the print.

---

<div class="post-metadata">

**Author:** ![ConsummatePro](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.snapmaker.com/consummatepro/32/7055_2.png) [@ConsummatePro](https://forum.snapmaker.com/u/ConsummatePro)\
**Post date:** [January 18, 2021, 5:42pm UTC](https://forum.snapmaker.com/t/octoprint-smart-filament-sensor-configuration/14568/4 "2021-01-18T17:42:34Z")

</div>

I’m confused by how the pause function will work since this plugin since it’s asking which pause command to issue, rather than using the Octoprint pause function - am I misunderstanding?

Also what’s the best practice for filament change in Octoprint on Snapmaker (ie use Octoprint or use the Snapmaker screen?). I’ve read that if you change temps using the screen it can mess up Octoprint’s functioning.

---

<div class="post-metadata">

**Author:** ![woodman42](https://avatars.discourse-cdn.com/v4/letter/w/46a35a/32.png) [@woodman42](https://forum.snapmaker.com/u/woodman42)\
**Post date:** [January 18, 2021, 10:19pm UTC](https://forum.snapmaker.com/t/octoprint-smart-filament-sensor-configuration/14568/5 "2021-01-18T22:19:38Z")

</div>

I’m just curious how you installed the sensor end.

---

<div class="post-metadata">

**Author:** ![ConsummatePro](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.snapmaker.com/consummatepro/32/7055_2.png) [@ConsummatePro](https://forum.snapmaker.com/u/ConsummatePro)\
**Post date:** [January 18, 2021, 10:42pm UTC](https://forum.snapmaker.com/t/octoprint-smart-filament-sensor-configuration/14568/6 "2021-01-18T22:42:02Z")

</div>

I haven’t yet mounted it to the Snapmaker - mine’s in an enclosure with filament feeding through a hole I drilled on the top of the enclosure (my filament feeds from above), directed using PTFE tubing. My plan was to simply splice it inline hanging loose above the enclosure.

---

<div class="post-metadata">

**Author:** ![stefix](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.snapmaker.com/stefix/32/8616_2.png) [@stefix](https://forum.snapmaker.com/u/stefix)\
**Post date:** [January 19, 2021, 2:21am UTC](https://forum.snapmaker.com/t/octoprint-smart-filament-sensor-configuration/14568/7 "2021-01-19T02:21:20Z")

</div>

I have mounted it on my 350, but it works not as intendet. In the plugin the test says all IO filament moving when I move it by hand. During a print looking at the webinterface it shows filament moving: NO.  
Have to test it further.

---

<div class="post-metadata">

**Author:** ![ronzelver](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.snapmaker.com/ronzelver/32/10744_2.png) [@ronzelver](https://forum.snapmaker.com/u/ronzelver)\
**Post date:** [February 10, 2021, 9:57pm UTC](https://forum.snapmaker.com/t/octoprint-smart-filament-sensor-configuration/14568/8 "2021-02-10T21:57:09Z")

</div>

I’m getting the same Smart Filament sensor tomorrow and I want to hook it up to my RPi OctoPrint server. Did you get any further with your testing/troubleshooting?

---

<div class="post-metadata">

**Author:** ![stefix](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.snapmaker.com/stefix/32/8616_2.png) [@stefix](https://forum.snapmaker.com/u/stefix)\
**Post date:** [February 11, 2021, 1:12am UTC](https://forum.snapmaker.com/t/octoprint-smart-filament-sensor-configuration/14568/9 "2021-02-11T01:12:59Z")

</div>

I am not printing with my snapmaker at the moment so I dont need it actually, But so far it all looks fine for me.

---

<div class="post-metadata">

**Author:** ![ConsummatePro](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.snapmaker.com/consummatepro/32/7055_2.png) [@ConsummatePro](https://forum.snapmaker.com/u/ConsummatePro)\
**Post date:** [February 11, 2021, 7:12am UTC](https://forum.snapmaker.com/t/octoprint-smart-filament-sensor-configuration/14568/10 "2021-02-11T07:12:53Z")

</div>

I havent had more time to troubleshoot it - I am not sure what pause or resume gcode we should use for the Snapmaker, so I’m stuck. I can get the config panel to sense movement, but @stefix seems to indicate it doesn’t actually work?

---

<div class="post-metadata">

**Author:** ![Tigercjn](https://avatars.discourse-cdn.com/v4/letter/t/5f8ce5/32.png) [@Tigercjn](https://forum.snapmaker.com/u/Tigercjn)\
**Post date:** [March 9, 2021, 2:20am UTC](https://forum.snapmaker.com/t/octoprint-smart-filament-sensor-configuration/14568/11 "2021-03-09T02:20:48Z")

</div>

Sounds Great, I have been playing with the Octoprint @pause and the Snapmaker 2, you can trigger it from Cura Pause at height plugin, it actually does work but It needs fine-tuning of the Gcode before and after the pause, The plugin has a minor problem that’s in the pipeline to be fixed, the head is 1mm high after the pause, I will try again editing the Gcode. This sensor sounds great, I will try and find it online.

---

<div class="post-metadata">

**Author:** ![ConsummatePro](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.snapmaker.com/consummatepro/32/7055_2.png) [@ConsummatePro](https://forum.snapmaker.com/u/ConsummatePro)\
**Post date:** [March 23, 2021, 6:55am UTC](https://forum.snapmaker.com/t/octoprint-smart-filament-sensor-configuration/14568/12 "2021-03-23T06:55:10Z")

</div>

Great: please post any fixes you have to make this work!

---

<div class="post-metadata">

**Author:** ![Tigercjn](https://avatars.discourse-cdn.com/v4/letter/t/5f8ce5/32.png) [@Tigercjn](https://forum.snapmaker.com/u/Tigercjn)\
**Post date:** [March 24, 2021, 12:42am UTC](https://forum.snapmaker.com/t/octoprint-smart-filament-sensor-configuration/14568/13 "2021-03-24T00:42:17Z")

</div>

I had to fix a couple of minor things in the script “pauseatheight.py” that sits in the post-processing script folder. Here is the link to the modified file. [PauseAtHeight.py - Google Drive](https://drive.google.com/file/d/1fIwMDhTpBhAKCbin1JyY6RdTGBLmKR4I/view?usp=sharing)

---

<div class="post-metadata">

**Author:** ![Tigercjn](https://avatars.discourse-cdn.com/v4/letter/t/5f8ce5/32.png) [@Tigercjn](https://forum.snapmaker.com/u/Tigercjn)\
**Post date:** [March 24, 2021, 12:46am UTC](https://forum.snapmaker.com/t/octoprint-smart-filament-sensor-configuration/14568/14 "2021-03-24T00:46:53Z")

</div>

So the Cura post processing script adds the @pause command at the right spot that you set. Octoprint then sees this command and pauses, you then the filament change, or add a magnet or whatever and then press the resume button on octoprint to proceed.

If you check the Gcode the @pause should be on a new line and have some Gcode inserted before and after it. I fixed the 1mm problem and also the @pause on a new line so all should work now.

---

<div class="post-metadata">

**Author:** ![ConsummatePro](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.snapmaker.com/consummatepro/32/7055_2.png) [@ConsummatePro](https://forum.snapmaker.com/u/ConsummatePro)\
**Post date:** [March 24, 2021, 6:55am UTC](https://forum.snapmaker.com/t/octoprint-smart-filament-sensor-configuration/14568/15 "2021-03-24T06:55:37Z")

</div>

@Tigercjn Can you explain how to integrate this into the sensor configuration? I’m not sure if your files are meant for Octoprint, the plugin or for use in Cura.

I use Simplify3D for my slicer and upload the sliced gcode to Octoprint so I’m unclear how to use your file.

---

<div class="post-metadata">

**Author:** ![Tigercjn](https://avatars.discourse-cdn.com/v4/letter/t/5f8ce5/32.png) [@Tigercjn](https://forum.snapmaker.com/u/Tigercjn)\
**Post date:** [March 24, 2021, 8:52am UTC](https://forum.snapmaker.com/t/octoprint-smart-filament-sensor-configuration/14568/16 "2021-03-24T08:52:42Z")

</div>

OK thinking about it you won’t need my file if you are going to issue the @pause command when the sensor triggers, my sensor has not arrived yet so I am playing with octoprint pause and resume using the Cura plugin postprocessing PauseAtHeight. Ok I see your problem the Snapmaker has no pause function available yet so you would need to try and get this to send a @pause command so Octoprint would pause. I think they would need to modify the plugin as you also need to add some Gcode before and after the pause.

---

<div class="post-metadata">

**Author:** ![Tigercjn](https://avatars.discourse-cdn.com/v4/letter/t/5f8ce5/32.png) [@Tigercjn](https://forum.snapmaker.com/u/Tigercjn)\
**Post date:** [March 24, 2021, 9:11am UTC](https://forum.snapmaker.com/t/octoprint-smart-filament-sensor-configuration/14568/17 "2021-03-24T09:11:28Z")

</div>

It looks like the plug in author is updating this so I think it will work in the future.

---

<div class="post-metadata">

**Author:** ![Mads0100](https://avatars.discourse-cdn.com/v4/letter/m/4af34b/32.png) [@Mads0100](https://forum.snapmaker.com/u/Mads0100)\
**Post date:** [August 25, 2021, 12:03am UTC](https://forum.snapmaker.com/t/octoprint-smart-filament-sensor-configuration/14568/19 "2021-08-25T00:03:24Z")

</div>

Anyone figure out how to make this pause a print? It looks like M25 should work? Hardware wise it’s working just fine… I’m just not sure what the best way to pause is.

I can’t figure out how you do @pause with the plug in listed above…

Chris

---

<div class="post-metadata">

**Author:** ![ronzelver](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.snapmaker.com/ronzelver/32/10744_2.png) [@ronzelver](https://forum.snapmaker.com/u/ronzelver)\
**Post date:** [December 15, 2021, 9:13pm UTC](https://forum.snapmaker.com/t/octoprint-smart-filament-sensor-configuration/14568/20 "2021-12-15T21:13:30Z")

</div>

The new firmware version v4.4.11 implements the M76 command for pausing:  
“Add “M76” G-code for triggering pause request in printing.”

---

<div class="post-metadata">

**Author:** ![Mads0100](https://avatars.discourse-cdn.com/v4/letter/m/4af34b/32.png) [@Mads0100](https://forum.snapmaker.com/u/Mads0100)\
**Post date:** [December 24, 2021, 4:51am UTC](https://forum.snapmaker.com/t/octoprint-smart-filament-sensor-configuration/14568/21 "2021-12-24T04:51:01Z")

</div>

Thanks Ron, I’ll set it back up.

[Next page](https://forum.snapmaker.com/t/octoprint-smart-filament-sensor-configuration/14568.md?page=2)
