How to properly pause Octoprint to change filament manualy
Clicking on Pause in Octoprint stops the 3d print. The printing head remains on the last position. If you want to change a filament you need to move the print head to a better position. In standard settings, you don’t have a chance to resume the print successfully. The print head doesn’t return to the last position automatically.
To be able to resume printing successfully, you have enter some commands which will printer execute immediately after a click on Pause button and before the printer continues printing after a click on Resume button.
Go to the Octoprint settings (wrench icon) -> GCODE Scripts. Into the input field “After print job is paused” enter following code:

{% 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 %}
And into the “Before print job is resumed” input field
{% 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(exruder absolute mode) according what your slicer generates M83 ; extruder relative mode ; 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 %}
Credits: code above is modified code from this Octoprint documetation page. To find the page, go to Octoprint Documentation, then Features -> GCODE scripts ->Examples
Update: September 21st 2018 11:20
This code was successfully tested on
- Prusa MK2S
- Prusa MK3
- Octoprint Version 1.3.9
- Slic3r Prusa Edition 1.4.0 + win64
I am not able to test other 3d printers.
Comments (53)
I believe, thta in “Before print job is resumed” after “reset E” should be M82 instead of M83.
Thank you so much, that mistake completely mess up my extruder. 😉 Thanks to the author nonetheless. 😀
Hello Rick,
I am sorry you have problems with the code I posted. I wouldn’t post something which I didn’t tested. Nevertheless, I did it again. I copied the code from the webpage into the Octoprint.
Then I run a print. Paused the print. Changed the filament. Resumed. And again – pause, changed the filament, resume. Everything worked fine for me.
Current test configuration:
– Prusa MK2S with Firmware 3.1.0
– Octoprint Version 1.3.9
– Raspberry Pi 3
– Slic3r Prusa Edition 1.4.0 + win64
What is your configuration?
Did you move the extruder during the pause manually?
@Kris,
there is a switching from relative to absolute mode and back. It is possible that some switching is obsolete.
Why do you recommend M82 instead of M83?
Hey yirco – I just printed benchy with 2 layers using your pause G-code and it worked perfectly with the latest versions of everything.
– Prusa i3 MK3 Firmware 3.4.0
– Octoprint Version 1.3.9
– Rapsberry Pi B+
– Slic3r Prusa Edition 1.41.0+linux64
Unloading and loading filament was simple using the standard menu on the MK3. After a slight lag when pause is selected (probably due to cached commands) the print head rose up, went to a safe position and awaited manual filament change. It resumed printing right where it left off when the resume button was selected. Thanks for the great G-code!
Hi Murphy,
thanks for sharing the positive experience.
You are right about the lag after pressing/clicking the Pause. The printer has to finish movements which are already cached. Otherwise, it wouldn’t be possible to determine exactly the position where to continue.
best regards
yirco
Thank you Yirco for the code!
Thank you Kris, after changing it to M82 instead of M83 it worked on my FLSUN QQ too!!!!
On my Wanhao D9 300 it does work too with your solution to change to M82 instead of M83. Thanks.
Same for my Anet A8, works like a charm, very helpful
What I actually had to do was change the M83 to M82 on the line directly below the warning to change that as required by the slicer, I am using Cura and it works perfectly. I had to reinstall it just now because I had to reinstall Octoprint on my Pi because it quit working. Thank you very much for making this easy and elegant fix.
Thanks for the code, but reset E still has M83. Please update the snippet.
Worked great on an Ender 3 with stock firmware. Thanks!
I tried it, with M83, on an Anycubic i3 MEGA, Octoprint 1.3.9, Pi 3 B, Cura 3.6 without success. The position movements are excellent. Unfortunately the feed did not restart, even though the position and movement did. Happy to try again, and report back, if you want to suggest an alternative resume script.
Hi nigew
thanks for sharing.
I am still not very sure why it on some printers work and not on others. I do believe that it depends on the slicer. I use Prusa printers and Sli3r Prusa Edition which sets extruder to relative mode on the beginning.
Recently I’ve found this article about relative/absolute extruder mode. Look at the beginning of your GCODE generated by Cura. Is there M83 or M82 on the beginning? Before the printing continues you have to set it back to the mode of your slicer. I will appreciate if you try this and let us know about the result.
best regards
yirco
Hello guys,
thank you all for sharing your experience. I suppose whether to use M83 or M82 in “before the print is resumed” depends on how the GCODE is generated. Each slicer can do it differently.
Please let me know which slicer are you using and which M83/M82 works for you.
If confirmed I will update the code with the comment.
Thanks
yirco
please let me answer this,
Cura uses M82 actually,
I change M83 to M82 and works properly.
you are correct, this depends on the slicer and need to adapt M82 or M83. Default cura is M82 (absolute).
mine is ender 3 and cura for slicer.
hi tj
can you help me out…
i tried the code above and the hotend moves out of the way so i can change filament.
but after resuming the print my hotend plunges into the print and keeps extruding.
M83 drove my extruder at hyperspeed 🙁
I was using slic3r and my printer is using Marlin if that matters (Anycubic Kossel Plus)
Simplify3D, Ender 3, Octopi worked after switching to M82 per above… M83 resulted in over-extrusion. Thanks for the code! Once fixed, I was even able to turn off the printer for a long pause, leaving the Raspberry Pi powered, turn it back on and Octopi had the temp settings already on… after letting the temps ramp back to target, I was able to resume the print.
I had been struggling with how to emulate the really useful resume print feature on the Ender firmware with Octopi. I think this handles most planned pauses, other than a surprise power outage.
Hi! How? When I try this (I turn off the Ender leaving Raspberry on), Octoprint loses the conection and the file in progress dissapear, no options to resume when I turn on the Ender and reconnect.
It only looses connection if the PI cannot power the printer
Make sure you are using a 2.1A power supply for your Pi
copy pasted the code while doing a job, this should work though.
did a pause, and the head didn’t move, changed filament and resumed.
Now that it’s still printing, it’s really slow.. approx 10 times slower.
Using Anet A8, with latest marlin firmware, slice job is using sli3r.
FLSUN cube, Cura, Octoprint 1.3.9 – Modifying to M82 worked like a charm.
Thanks all
M82 is correct for a MP Maker Ultimate. With M83, the extruder doesn’t feed.
The M82 vs M83 debate is not about the printer, its about the slicer.
If your slicer generates absolute extruder moves, then it should be:
; absolute E
M82
; absolute XYZ
G90
Note I do not recommend the M82 after the G92 as some firmware may reset E to 0 when this happens.
If your slicer genreate relative extruder modes then it sould be:
; absolute XYZ
G90
M83 ; extruder relative mode
Once I tracked that down it started working for me.
can you help me out…
i tried the code above and the hotend moves out of the way so i can change filament.
but after resuming the print my hotend plunges into the print and keeps extruding.
hi Richard
what’s your printer and slicer?
I’ve found that setting the park position of the extruded to something like 5,5 instead of 0,0 gives better results on printers with mechanical endstops because of the slight variation on triggering. If it’s relying on the stops to park at 0,0 then there can be some layer shift on resume. Parking with a software stop slightly away from the actual stops have given me perfect restarts on my ender 3 pro
Thank you for this!
thanks. worked fine on my ender 3 using cura. just changed to M82 on the Warning part.
Hello,
works for me on Alfawise U20 and Simplify3D but warning with M82 because with M83 the motor will suddenly race and the filament goes out withe a crazy speed… Be carrefull!
That sounds really great, I need to test this 😀 Thanks a bunch.
I was wondering: what kind of issue could I expect if I use this for a long pause (8 hours to allow quiet time during the night) ?
Am I right assuming, that Octopi might lose connection or reset, and then nothing can be recovered ?
Any advice on that would be great.
Thanks
I used M82 and it works like a charm! Genius! Thanks a lot for this piece of code! I injected the two code snippets during a running print on my Anycubic i3 Mega, with no test upfront, and it worked just perfect. Used it a couple of times more in further prints, I am really glad with this.
Gives me a chance for some kind of basic multi color prints, and when running out of filament, I can now change.
Just one little question. Would it be possible to tweak the code a little bit, so it pauses >>at the next z layer change<< ? That would make it even better and just perfect.
Just asking, just in case. I find it very useful already.
So how do you actually set it to pause at a given height, which would then run the “after pause” script and allow me to change the filament? Or, do I have to pause manually?
Hi Josh,
you have to stop it manually using Octoprint. Not on the printer itself! To pause automatically at a given height, try to find Octoprint plugin or prepare .gcode before print to stop at given height. I know Prusa has a description on their web pages. May be the newest Slicer Prusa Edition supports it too.
br
yirco
Awesome, thanks! This worked great. This saved a 10h print I was running. I was relieved to find out that it was possible to add the scripts in octoprint even though the print was already in progress.
As mentioned in the snippet I checked if my slicer produces GCODE with M83 or M82 and adjusted the value.
?
you just saved 5h print
gotta love that code for color change too thanks
You just saved a four day print for me. Tested on an Anycubic Chiron, Cura 4.3.0, Octoprint 1.3.12. Yes I know the Chiron has a filament sensor, but sadly its not recognized by Octoprint, so this code saved me a lot of frustration and a large reprint. Thank you!
Forgot to mention that with my configuration you do need to change to M82 from M83 after “Reset E” as mentioned above.
Ender 3 Pro with TH3D unified firmware, EZABL, Cura 4.2.1, OctoPrint 1.3.11 running on OctoPi 0.16.0
Changed M83 to M82 after “Reset E” as others have stated for Cura and this code worked perfectly for me. Saved a print that had been running for 15 hours and was going to be about 4 meters short on filament. Thanks!
Which M83 did you change? Just the one after reset 3?
I was wondering the same thing….I am already in to a print. Is is ONLY the M82 after “Reset E” or is it every instance you see in above code snippet. I used the cura slicer running M82 (looked in another Gcode myself) and am running octoprint from the pi on an Ender 3 Pro.
Tested with the M82 code after ‘Reset E’. Great work!
S3d slicer
Ender 5 +
OctoPrint 1.3.12
Thanks for the snippets Works excellent with the M82
Cura
Artillery Sidewinder X1
OctoPrint 1.3.16
I am going to try this with M82 after “Reset E”
Just one question, If I accidentally move the head while changing filament, will it still go to the correct position when resuming?
Or should I add a “G28 X Y” somewhere? if so, where should I add that? before the “move back to pause position XYZ” ?
Ender 3 with SKR mini E3 V1.2
Cura 4.5
Octoprint 1.3.11
Hi Arjan,
No.
If you move the head manually, any printer (or let me know which one is:-) is able to recognize the heads absolute position.
Some printers allow to move the head from a menu of the control computer. This doesn’t help neither, because the Octoprint doesn’t receive this information.
Actually, all printers work internally with relative position. Motors receive number of ticks to move forward or backward. The commands M83 / M82 only say internally how the number of ticks are calculated. For absolute movement the number ticks is calculated from the stored absolute position. Stored absolute position is either calculated summing the relative movements or taken from the G-Code. The motor doesn’t send any information to the control computer if it reached the destination or not. If you move the head manually – control computer still believes that it is on the position last remembered.
New printers come with trinamic drivers – units which directly control the current flowing to the motors. These units are able to give some kind of feedback about the real head (motor) movement. But not the real head position. And it is another story…
hope it helps
Thanks so much for this everyone, including the m82 command. I’ve got a print job running and am realizing that I’m about to run out of filament. Hopefully this saves the job, this community is great.
Thanks for this page.
What is your code for “after print is cancelled”? Once can see a bit of it on the image.
Hi,
the image is only an illustration.
The best is to check out https://docs.octoprint.org/en/master/features/gcode_scripts.html#sec-features-gcode-scripts-bundled
I am using Cura 4.6.0 Octoprint 0.17.0 on an Anet A8 Sainsmart with a Raspberry Pi 3. M82 works for me, it still resumed with M83 but at a much slower rate. Thank you very much for this, it really helped me out.
M82 worked great for me with:
– Cura 4.6.2
– Octoprint 1.4.2
– Ender 5 Plus
Worked completely fine for me, with M82.
Ender 3 v2
Octoprint 1.5.1
Cura 4.8
Newbie here. Wow, I greatly appreciate this post. It’s exactly what I want to do.
Quick question regarding the “WARNING”:
I sliced with Cura. Line 12 of the outputted gcode says “M82 ;absolute extrusion mode”
…So, I need to change M83 to M82 right?
I’m not really sure what M82 on line 12 exactly is. But, this should be the way according to the earlier posts.
Just make a test with a small thing before.