Octoprint & Smart Filament Sensor configuration

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
  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
  3. In Octoprint, install the plugin Octoprint Smart Filament Sensor (Octoprint-Smart-Filament-Sensor)
  4. Configure the plugin: see my screenshot, but I need advice for the best pause command for Snapmaker 2.0.
  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)
  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.

5 Likes

Pause doesnt currently exist :frowning:

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.

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.

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.

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

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.

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.

1 Like

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?

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.

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?

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.

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

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

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.

@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.

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.

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

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

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

1 Like

Thanks Ron, I’ll set it back up.