Skip to main content

Power Off Shutdown and Power Loss Resume

Important Notes
  • Power Off Shutdown and Power Loss Resume functions conflict with each other and cannot be enabled simultaneously
  • If only the power off shutdown function is enabled, the power loss resume function will be unavailable
  • Klipper connection must be correctly configured and maintained for the power loss resume function to take effect. Once triggered, it will automatically enter the shutdown process

Function Configuration

Disable Power Off Shutdown Function

Notice
  • Power off shutdown must be disabled, otherwise the power loss resume function cannot be used
  • Power loss resume includes an automatic shutdown function after saving progress
  • Ensure no other power is connected to the host, otherwise normal shutdown may not be possible
  1. Access the device configuration page

    • Enter the device IP address in the browser address bar, e.g., http://192.168.1.2/
  2. Display hidden files

    • Fluidd: Uncheck "Filter hidden files and folders"
    • Mainsail: Check "Show hidden files"
    Loading...
    Loading...
  3. Edit configuration files

    • Find and enter the .flyos-config folder
    • Open the sys-config.conf file
Loading...
  1. Comment out power off shutdown configuration

    • Find the shutdown_pin_state and shutdown_pin configuration items
    • Add # in front of these two configurations to comment them out
  2. Save and restart

    • Save the modified configuration file
    • Close the file and restart the system
Loading...

Configure Power Loss Resume Function

  1. Edit the plr.cfg configuration file

    • On the printer configuration page, find or create the plr.cfg file
    • Clear the file content and paste the following configuration:
    • Please modify the power_pin parameter according to the actual GPIO number in use
    [mcu host]
    serial: /tmp/klipper_host_mcu

    [power_loss_resume]
    power_pin: xxxx
    is_shutdown: True # Whether to perform shutdown, enabled by default
    paused_recover_z: -2.0 # Z movement distance when resuming from a paused print; default is no movement
    start_gcode:
    # Gcode to execute before starting resume
    # All saved parameters before power loss can be accessed via {PLR}
    # Use M118 {PLR} to output all available parameters
    # M118 {PLR}
    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}]
    {% if PLR.bed.target > 0 %}
    M140 S{PLR.bed.target} ; Set bed temperature
    {% endif %}
    {% if PLR.extruder.target > 50 %}
    M104 S{PLR.extruder.target - 10} ; Wait for nozzle to heat to set temperature
    {% endif %}
    G91 ; Relative positioning
    G1 Z2 F100 ; Raise Z, prepare for X,Y homing
    G90 ; Absolute positioning
    G28 X Y ; Home X and Y
    {% if PLR.bed.target > 0 %}
    M190 S{PLR.bed.target} ; Wait for bed to reach target temperature
    {% endif %}
    {% if PLR.extruder.target > 0 %}
    M109 S{PLR.extruder.target} ; Wait for nozzle to reach target temperature
    {% endif %}
    M83 ; Relative extrusion
    # G1 E0.5 F400 ; Extrude a little
    layer_count: 2 # Execute layer_change_gcode after this many layers are resumed
    layer_change_gcode:
    # Gcode to execute after {layer_count} layers have been resumed
    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 extrusion speed percentage
    shutdown_gcode:
    # Gcode to execute before shutdown
    M118 Low power voltage, shutting down
    # M112 ; Emergency stop
  2. Include the configuration file

    • Open the printer.cfg file and add the following at the very beginning:
    [include plr.cfg]
    • Click the save button in the top right corner and restart

Configure Homing Override

Important Notes
  • If using [homing_override], do not arbitrarily set homing positions in the configuration
  • Incorrect configuration may cause power loss resume failure

Configuration Explanation

  • [force_move]: Enables the force move function, allowing forced movement to specified positions
  • [force_move] replaces the set_position_z functionality in [homing_override]
  • The following configuration ensures correct Z-axis homing during power loss 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 Z-Axis Lift Explanation This configuration only executes when the Z-axis has not been homed and does not affect normal use:

{% if 'z' not in printer.toolhead.homed_axes %}
SET_KINEMATIC_POSITION Z=0
G90
G0 Z5 F600
{% endif %}

Function Testing

Step 1: Simulated Power Loss Test

  1. Start printing any file
  2. During printing, click the Emergency Stop button to simulate a power loss
  3. Click Firmware Restart, wait for Klipper to reconnect
  4. Observe if a popup appears on the web interface (a popup indicates the function is working normally)
  5. Proceed with a real power loss test to verify function reliability

Step 2: Real Power Loss Test

  1. Test Preparation: Confirm the status of the indicator light next to the host (LED should be flashing during normal operation)
  2. Power Loss Test: Disconnect power directly while the device is running normally
  3. Indicator Light Check: Observe if the indicator light completely turns off within 5 seconds
    • Turns off: Power off shutdown function is working normally
    • Does not turn off: Automatic shutdown function is not effective, check the configuration
  4. Recovery Test: Wait at least 5 seconds before reconnecting power
  5. Function Verification:
    • Popup appears: Power loss resume function is working normally
    • No prompt: Power loss resume function did not start, check the configuration

Loading...