Skip to main content

Power Loss Shutdown and Power Loss Recovery

Important Notes

1. Function Concepts and Processes

  • Power Loss Shutdown

    • Concept: Upon detecting an abnormal power loss, the system does not save the current printing state and directly executes a safe shutdown.
    • Recovery Process: After power is restored, the device will automatically restart and go into standby mode. The previous print job has been aborted, and you need to manually start a new print.
  • Power Loss Recovery

    • Concept: Upon detecting an abnormal power loss, the system immediately saves the current print progress (e.g., position, layer height) and then shuts down.
    • Recovery Process: After power is restored, user confirmation is typically required before the device can resume and complete the unfinished print from the point of interruption.

2. Core Rules

  • Power Loss Shutdown and Power Loss Recovery are mutually exclusive functions and cannot be enabled simultaneously.
  • If the Power Loss Shutdown function is enabled, the Power Loss Recovery function will automatically become inactive.

3. How to Choose

  • Choose "Power Loss Shutdown": Enable this function if you are more concerned about electrical safety, or if you want the device to automatically start up and go into standby mode after power is restored, without needing to resume an interrupted print.
  • Choose "Power Loss Recovery": Enable this function if you frequently run long-duration print jobs that cannot afford to fail, and you wish to resume printing from the interruption point after a power loss.

Configuration

Disable Power-off Shutdown

Notice
  • Before using power-loss resume functionality, ensure Klipper has started normally and can control the printer.
  • The power-off shutdown function must be disabled, otherwise power-loss resume will not take effect.
  • After disabling power-off shutdown, the device will remain powered on. Ensure there is no independent power supply connected to the upper computer, otherwise the device will still be unable to shut down after a power outage.
  • Enter the device's IP address in the browser's address bar, for example: http://192.168.6.179

  • Enter the configuration page

    • Open the device's IP address in the browser, for example: http://192.168.1.2/
    • In fluidd, as shown on the left in the image below, uncheck -> Filter hidden files and folders.
    • In mainsail, as shown on the right in the image below, check -> Show hidden files.
    Loading...
    Loading...
    • At this point, you can see the .flyos-config folder. Entering this folder will reveal the sys-config.conf file.
    • The sys-config.conf file is a symbolic link to the configuration file config.txt on the removable disk FlyOS-Conf.
    Loading...
    • Open the sys-config.conf file and find the two configurations: shutdown_pin_state and shutdown_pin=
    • Add # before these two configurations
    • Then Save -> Close and restart
    Loading...

plr.cfg Configuration File

  • In the printer configuration page, locate the plr.cfg file.
  • Clear its contents, then paste the configuration below.
  • The configuration file content is as follows:
  • power_pin must use the host GPIO or a pin recommended by the product, and cannot use a pin from the lower-level MCU (MCU/toolboard).
  • If you have the C5 version, use the code below.
[mcu host]
serial: /tmp/klipper_host_mcu

[power_loss_resume]
power_pin: !host:gpiochip0/gpio260
is_shutdown: True # Whether to perform shutdown operation, default is enabled
paused_recover_z: -2.0 # If paused during printing, Z move distance when resuming, default is no movement
start_gcode:
# Gcode to execute before starting resume
# 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 Interrupted 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 ; Raise Z, prepare for X,Y homing
G90 ; Absolute coordinates
G28 X ; Home X
G28 Y ; Home Y
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 small amount
layer_count: 2 # Execute layer_change_gcode after resuming a specified number of layers
layer_change_gcode:
# Gcode to execute after {layer_count} layers have been resumed
M118 Resume printing 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 extrusion speed percentage
shutdown_gcode:
# Gcode to execute before shutdown
M118 Low power voltage, shutting down
# M112 ; Emergency stop
  • After saving the configuration file above

  • Open the printer.cfg file and add the following at the very beginning:


    [include plr.cfg]

  • Click "Save & Restart" in the top right corner.

  • At this point, the Klipper power loss resume function is configured.

About [homing_override]

Note
  • If [homing_override] is used, do not arbitrarily set the homing position within [homing_override]. Failure to do so may result in print resume failure and no responsibility will be accepted.
  • Configuration instructions for [homing_override] are provided below.
  • Explanation
    • [force_move]: Enables the forced move function, allowing forced movement to a specified position when not homed.
    • [force_move] replaces the set_position_z function in [homing_override]. Failure to configure this way may lead to print resume failure.
    • The [homing_override] configuration below is intended to correctly home the Z-axis during print resume.
[force_move]
enable_force_move: true


[homing_override]
axes: z
gcode:
{% set max_x = printer.configfile.config["stepper_x"]["position_max"]|float %}
{% set max_y = printer.configfile.config["stepper_y"]["position_max"]|float %}
{% if 'z' not in printer.toolhead.homed_axes %}
SET_KINEMATIC_POSITION Z=0
G90
G0 Z5 F600
{% endif %}
{% set home_all = 'X' not in params and 'Y' not in params and 'Z' not in params %}

{% if home_all or 'X' in params %}
G28 X
{% endif %}

{% if home_all or 'Y' in params %}
G28 Y
{% endif %}

{% if home_all or 'Z' in params %}
G0 X{max_x / 2} Y{max_y / 2} F3600
G28 Z
G1 Z10 F2000
{% endif %}

  • About Lift Explanation
    • This configuration only executes when the Z-axis is not homed and does not affect normal usage.
      {% if 'z' not in printer.toolhead.homed_axes %}
      SET_KINEMATIC_POSITION Z=0
      G90
      G0 Z5 F600
      {% endif %}

About Configuration for [gcode_macro _CLIENT_VARIABLE]

  • When your configuration includes the [gcode_macro _CLIENT_VARIABLE] macro and sets the following variables:
  • Reference
[gcode_macro _CLIENT_VARIABLE]
variable_use_custom_pos: True # Enable custom position
variable_custom_park_dz: 5 # Set custom park height offset
  • You must accordingly adjust the paused_recover_z parameter in the [power_loss_resume] module, making it opposite in sign to the offset value above.

Configuration Correspondence

Macro VariablePause/Resume Module ParameterCorrespondence
variable_custom_park_dz: 5paused_recover_z: -5Opposite sign, same value
variable_custom_park_dz: -3paused_recover_z: 3Opposite sign, same value

Example Configuration

[gcode_macro _CLIENT_VARIABLE]
variable_use_custom_pos: True
variable_custom_park_dz: 5

[power_loss_resume]
paused_recover_z: -5

Important: Failure to maintain this correspondence may lead to incorrect Z-axis height calculation during print resume or pause recovery, affecting the print.

Testing

First Step Test: Simulating Power Loss via Emergency Stop

  1. Start printing any file. During the print, click the Emergency Stop button to simulate a power loss scenario.
  2. Click Firmware Restart again and wait for Klipper to reconnect and return to normal.
  3. Check if a popup notification appears on the web interface. If it appears, the print resume function is working correctly.
  4. Subsequently, you can further test with an actual power loss to verify the function's reliability.

Second Step Test: Actual Power Loss Simulation and Function Verification

  1. Test Preparation: After the system starts normally and connects to Klipper, first confirm the status of the indicator light next to the host computer. Usually, an LED will blink when the system is running. This indicator light is the key one to observe in subsequent steps.
  2. While the device is running normally and connected to Klipper, directly disconnect the power to simulate a real power loss scenario.
  3. Immediately check if the indicator light next to the host computer turns off completely within 5 seconds.
    • If it turns off: The power-off shutdown function is normal. Please proceed with the subsequent steps.
    • If it does not turn off: The automatic shutdown function is not working. This is usually due to incorrect related configurations (such as kppm wiring or settings), which need to be carefully checked and troubleshot.
  4. Wait at least 5 seconds, then reconnect the power. Observe if Klipper automatically reconnects and returns to normal operation. (Saving data and shutting down takes 3-5 seconds).
  5. Check the web interface
    • If a popup notification appears: The print resume function has been successfully activated and is operating normally.
    • If there is no notification: The print resume function did not start as expected. Please systematically check the relevant configurations based on the above observations.

Loading...