Power Loss Shutdown and Power Loss Recovery
Important Notes
- The Power Loss Shutdown and Power Loss Recovery features conflict with each other and cannot be enabled simultaneously.
- If only the Power Loss Shutdown feature is enabled, the Power Loss Recovery feature will be unavailable.
- The Power Loss Recovery feature requires correct configuration and a maintained Klipper connection to take effect. Once triggered, it will automatically initiate the shutdown process.
Feature Configuration
- Power Loss Shutdown
- Power Loss Recovery
Configuring Power Loss Shutdown
Note
Please follow the steps below to configure the Power Loss Shutdown feature.
-
Access the Device Configuration Page
- Enter the device's IP address in your browser's address bar, e.g.,
http://192.168.1.2/
- Enter the device's IP address in your browser's address bar, e.g.,
-
Show Hidden Files
- Fluidd: Uncheck "Filter hidden files and folders"
- Mainsail: Check "Show hidden files"
Loading...Loading... -
Edit the Configuration File
- Locate and enter the
.flyos-configfolder. - Open the
sys-config.conffile (this file is a soft link toconfig.txton theFlyOS-Confdisk).
Loading... - Locate and enter the
-
Modify Configuration Parameters
- Find the
shutdown_pin_stateandshutdown_pinconfiguration items. - Modify them to the following configuration:
shutdown_pin_state=1
shutdown_pin=xxxxx- Ensure
shutdown_pin=noneis either deleted or commented out (prefixed with#). - Replace
xxxxxwith the actual GPIO number used. Please select the correct GPIO based on your device model.
- Find the
-
Save and Restart
- Save the modified configuration file.
- Close the file and restart the system.
Loading...
Disabling the Power Loss Shutdown Feature
Note
- The Power Loss Shutdown feature must be disabled; otherwise, the Power Loss Recovery feature cannot be used.
- Power Loss Recovery includes an automatic shutdown function after saving progress.
- Ensure no other power supply is connected to the host computer, or normal shutdown may not occur.
-
Access the Device Configuration Page
- Enter the device's IP address in your browser's address bar, e.g.,
http://192.168.1.2/
- Enter the device's IP address in your browser's address bar, e.g.,
-
Show Hidden Files
- Fluidd: Uncheck "Filter hidden files and folders"
- Mainsail: Check "Show hidden files"
Loading...Loading... -
Edit the Configuration File
- Locate and enter the
.flyos-configfolder. - Open the
sys-config.conffile.
- Locate and enter the
Loading...
-
Comment Out Power Loss Shutdown Configuration
- Find the
shutdown_pin_stateandshutdown_pinconfiguration items. - Add a
#at the beginning of each line to comment them out.
- Find the
-
Save and Restart
- Save the modified configuration file.
- Close the file and restart the system.
Loading...
Configuring the Power Loss Recovery Feature
-
Edit the plr.cfg Configuration File
- On the printer configuration page, locate or create the
plr.cfgfile. - Clear the file contents and paste the following configuration.
- Important: Modify the
power_pinparameter according to the actual GPIO number used.
[mcu host]
serial: /tmp/klipper_host_mcu
[power_loss_resume]
power_pin: xxxx
is_shutdown: True # Whether to perform shutdown operation, enabled by default
paused_recover_z: -2.0 # Z-axis movement distance when resuming from a paused state, defaults to no movement
start_gcode:
# G-code executed before resuming print
# All parameters saved before power loss can be accessed via {PLR}
# Use M118 {PLR} to output all available parameters
# M118 {PLR}
M118 Starting recovery: {PLR.print_stats.filename}
M118 Interruption 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 hotend to heat to target temperature
{% endif %}
G91 ; Relative positioning
G1 Z2 F100 ; Lift 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 hotend to reach target temperature
{% endif %}
M83 ; Relative extruder
# G1 E0.5 F400 ; Extrude a small amount
layer_count: 2 # Execute layer_change_gcode after resuming the specified number of layers
layer_change_gcode:
# G-code to execute after resuming {layer_count} layers
M118 Resuming 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:
# G-code executed before shutdown
M118 Low power voltage, shutting down
# M112 ; Emergency stop - On the printer configuration page, locate or create the
-
Include the Configuration File
- Open the
printer.cfgfile and add the following line at the very beginning:
[include plr.cfg]- Click Save and Restart in the top-right corner.
- Open the
Configuring Homing Override
Important Considerations
- If using
[homing_override], do not arbitrarily set homing positions in the configuration. - Incorrect configuration may cause Power Loss Recovery to fail.
Configuration Explanation
[force_move]: Enables the force move function, allowing forced movement to a specified position.[force_move]replaces theset_position_zfunction in[homing_override].- The following configuration ensures correct Z-axis homing during Power Loss Recovery.
[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 %}
Explanation of Z-axis Lift This configuration only executes if the Z-axis is not 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
- Start printing any file.
- During the print, click the Emergency Stop button to simulate a power loss situation.
- Click Firmware Restart and wait for Klipper to reconnect.
- Observe if a pop-up notification appears on the web interface (if it appears, the feature is working).
- You can later perform a real power loss test to verify reliability.
Step 2: Real Power Loss Test
- Test Preparation: Confirm the status of the indicator light near the host computer (LED should blink during normal operation).
- Power Loss Test: Directly disconnect the power while the device is running normally.
- Indicator Light Check: Observe if the indicator light completely turns off within 5 seconds.
- Off: Power Loss Shutdown feature is working correctly.
- Not Off: Automatic shutdown feature did not activate; check configuration.
- Recovery Test: Wait at least 5 seconds, then reconnect the power.
- Function Verification:
- Pop-up appears: Power Loss Recovery feature is working correctly.
- No prompt: Power Loss Recovery feature did not activate; check configuration.
Loading...