Skip to main content

Power Loss Resume Function of Klipper

Overview

  • The power loss resume function of Klipper refers to the ability to automatically restore the printing status of Klipper after it is powered off and then powered on again.
  • This function needs to be used in conjunction with the Safe Shutdown Module.
  • It is not applicable for models where the Z-axis will move when the power is cut.

Configuration

plr.cfg Configuration File

  • In the printer configuration page, click "New Configuration File" to create a plr.cfg file.

  • The content of the configuration file is as follows:

    [power_loss_resume]
    # power_pin: PA0 # The shutdown pin of the safe shutdown module connected to PA0 pin of the lower computer
    power_pin: host:gpiochip1/gpio21 # The shutdown pin of the safe shutdown module connected to PA21 pin of the upper computer
    is_shutdown: True # Whether to execute the shutdown operation, enabled by default
    paused_recover_z: -2.0 # If the machine is paused during shutdown, the Z movement distance when resuming print, no movement by default
    start_gcode:
    # G-code to be executed before resuming print
    # All parameters saved before power failure can be accessed via {PLR}
    # Available parameters can be output using M118 {PLR}
    M118 Start Resuming Print: {PLR.print_stats.filename}
    M118 Interrupt 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 reach set temperature
    G91 ; Relative coordinates
    G1 Z2 F100 ; Lift 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 reach set temperature
    M109 S{PLR.extruder.target} ; Wait for extruder to reach set temperature
    M83 ; Relative extrusion
    # G1 E0.5 F400 ; Extrude a bit
    layer_count: 2 # Resume printing specified number of layers and execute layer_change_gcode
    layer_change_gcode:
    # G-code to be executed after resuming {layer_count} layers
    M118 Resume Printing Speed
    M106 S{PLR.fan_speed} ; Turn on the 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 be executed before shutdown
    M118 Low Voltage, Shutdown
    # M112 ; Emergency stop

    Note
    • The start_gcode macro in the above configuration file may need to be modified according to the actual machine situation.
  • After saving the above 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 on the top right and restart.

  • The power loss resume function of Klipper has been configured.

Testing

  • Print any file, and click the "Emergency Stop" button during the print process to simulate a power failure.
  • Click "Firmware Restart" again, wait for Klipper to connect normally.
  • If a pop-up prompt appears on the web page or KlipperScreen, it indicates that the power loss resume function is working properly.
  • You can continue to test the real power failure situation later.