Power Loss Resume Function in Klipper
Overview
- The power loss resume function in Klipper refers to the ability to automatically restore the printing state of Klipper after it has been powered off and then powered on again.
- This function requires the use of a safety shutdown module.
- It is not applicable for machines where the Z-axis will move when the power is cut.
Configuration
Disable Power Off Shutdown
Note
- You need to disable the power-off shutdown, otherwise the power loss resume function cannot be used.
- The power loss resume function includes an automatic shutdown after saving progress.
-
Enter the device's IP address in the browser's address bar, for example:
http://192.168.6.179
-
Access the configuration page
- Open the device IP address in the browser, for example:
http://192.168.1.2/
- In fluidd, uncheck as shown in the left image ->
Filter hidden files and folders
. - In mainsail, check as shown in the right image ->
Show hidden files
.
- At this point, you can see the
.flyos-config
folder. Inside this folder, there will be asys-config.conf
file. - The
sys-config.conf
file is a symbolic link to theconfig.txt
configuration file in the removable diskFlyOS-Conf
.
- Open the
sys-config.conf
file and locate the configurationsshutdown_pin_state
andshutdown_pin=
. - Add a # before these configurations.
- Then save and close, and restart the system.
- Open the device IP address in the browser, for example:
plr.cfg Configuration File
-
In the printer configuration page, find the
plr.cfg
file. -
Empty the content inside, then paste the following configuration into it.
-
The content of the configuration file is as follows:
[mcu host]
serial: /tmp/klipper_host_mcu
[power_loss_resume]
power_pin: !host:gpiochip0/gpio260 # Shutdown pin of the safety shutdown module, connected to PA21 pin on the host machine
is_shutdown: True # Whether to execute shutdown operation, default is enabled
paused_recover_z: -2.0 # Z movement distance during recovery if the machine is paused during shutdown, default is no movement
start_gcode:
# G-code to execute before resuming print
# All parameters saved before power loss can be accessed via {PLR}
# Use M118 {PLR} to output all available parameters
M118 Starting resume: {PLR.print_stats.filename}
M118 Interruption position: X:[{PLR.POS_X}] Y:[{PLR.POS_Y}] Z:[{PLR.POS_Z}] E:[{PLR.POS_E}]
M140 S{PLR.bed.target} ; Set bed temperature
M104 S{PLR.extruder.target-10} ; Set extruder temperature
M109 S{PLR.extruder.target-10} ; Wait for extruder to heat up to set temperature
G91 ; Relative coordinates
G1 Z2 F100 ; Raise Z, prepare for X,Y homing
G90 ; Absolute coordinates
G28 X Y ; Home XY
M140 S{PLR.bed.target} ; Set bed temperature
M104 S{PLR.extruder.target} ; Set extruder temperature
M190 S{PLR.bed.target} ; Wait for bed to heat up to set temperature
M109 S{PLR.extruder.target} ; Wait for extruder to heat up to set temperature
M83 ; Relative extrusion
# G1 E0.5 F400 ; Extrude a bit
layer_count: 2 # Execute layer_change_gcode after resuming specified number of layers
layer_change_gcode:
# G-code to execute after resuming {layer_count} layers
M118 Resume print speed
M106 S{PLR.fan_speed} ; Turn on part cooling fan
M220 S{PLR.move_speed_percent} ; Set requested speed percentage
M221 S{PLR.extrude_speed_percent} ; Set requested extrude speed percentage
shutdown_gcode:
# G-code to execute before shutdown
M118 Low power voltage, shutting down
# M112 ; Emergency stopNote- The
start_gcode
macro in the above configuration file may need modification based on the specific machine's actual situation.
- The
-
After saving the configuration file,
-
Open the
printer.cfg
file and add the following content at the beginning of the file:
[include plr.cfg] -
Click the Save button in the top right corner and restart the system.
-
The power loss resume function in Klipper is now configured.
Testing
- Start printing any file. During the print process, click the
Emergency Stop
button to simulate a power failure. - Click
Firmware Restart
, wait for Klipper to connect normally. - If a pop-up prompt appears on the webpage or KlipperScreen, it indicates that the power loss resume function is working properly.
- You can continue testing with real power failure scenarios later.