# Recovering print after power shutdown

**URL:** <https://klipper.discourse.group/t/recovering-print-after-power-shutdown/3422>\
**Category:** General Discussion\
**Created:** [July 11, 2022, 2:35pm UTC](https://klipper.discourse.group/t/recovering-print-after-power-shutdown/3422 "2022-07-11T14:35:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![awitc](https://avatars.discourse-cdn.com/v4/letter/a/c77e96/32.png) [@awitc](https://klipper.discourse.group/u/awitc)\
**Post date:** [July 11, 2022, 2:35pm UTC](https://klipper.discourse.group/t/recovering-print-after-power-shutdown/3422/1 "2022-07-11T14:35:32Z")

</div>

Hello,

I am in dire need of a solution for the print recovery problem.

I have been browsing every available source of information regarding this and similar topics, like:

> [@Resume Print after power loss](https://klipper.discourse.group/t/resume-print-after-power-loss/2682):
>
> After a power loss when the printer comes online how can the print be resumed? Is there any way of implementing this? Marlin 2.x has such a functionality if I recall. Thx

> <https://github.com/Klipper3d/klipper/issues/1645>
>
> Hi, I am working on an implementation of power-off recovery and wanted to everyo…ne to be aware of it/review my implementation design.
> 
> This implementation would depend on a power panic board, much like the Original Prusa i3 Mk3. It would add a new config option for specifying the power panic pin. 
> 
> Additionally, this assumes the power supply would provide around a second of operation after wall power is lost. Alternatively, the Raspberry Pi and MCU could be powered off of a 5v battery or some form of capacitor setup to substitute.
> 
> Here is how it would work:
> \- power panic signal is received from the power panic board
> \- the MCU would decelerate the printer to a stop and record the remaining steps in the current move
> \- the MCU would send an emergency signal to the Raspberry Pi containing the current x, y, and z axis position, and move queue
> \- the Raspberry Pi would save this move queue, z axis info, set temperatures of the bed + extruders, and the filename of the current print to a file named resume.klipper or something
> \- the Raspberry Pi then executes a shutdown command to safely turn off
> \- upon boot Klipper checks to see if a resume file is present. If so, it heats the bed and extruder(s) up to the specified temperatures
> \- Klipper sets the current z axis position to the one recorded in the resume file and then homes the x and y axis of the printer
> \- Next Klipper loads the file using the Virtual SDCard feature. It looks for the first G1 command containing the current Z axis position as recorded in the resume file. 
> \- Klipper calculates the move queue as usual, but does not send it. Instead it goes through the file looking for a move queue that matches the one sent over by the MCU previously. 
> \- Klipper then moves the extruder to the recorded x and y position from the resume file
> \- Klipper then sends over the move queue from the resume file and continues normally to the next set of moves
> \- Klipper then deletes the resume file and continues on with the print as normal.
> 
> If you have any concerns or advice regarding this implementation please let me know. I have looked through the code a lot and read the documentation and will be fully implementing this and sending a pull request soon.
> 
> Thanks!
> Cole
> 
> \[klippy.log\](https://github.com/KevinOConnor/klipper/files/3189699/klippy.log)

However, it seems that this is a very niche application and there is no working example, as there are many issues with the implementation.

I have the BTT UPS module, which allows for the printer to be able to operate for several seconds after a power loss and can provide a signal, when the power is out. Additionally, for my particular application, I do not use a heated bed (which would eliminate adhesion issues, as there would be no need to reheat it). Hence I figure that it would be possible to make a save of the current print state whenever the power\_out pin is active and toggle a resume print window when the printer is able to run again.

My main issue is the lack of proper understanding of inner workings of Klipper. I would greatly appreciate any feedback on how to implement any of the steps required to reach my goal.

What I have in mind:

Power is gone → Trigger UPS pin → Save position → Raise nozzle, shut-down printer  
Power is back → Resume? → Reheat nozzle → Read last coordinates → Continue the print

I am familiar to python, but I am in no way close to understanding all of the Klipper code. If I could obtain any suggestions on how to proceed, I would be very thankful; i.e. which Klipper files are crucial for this functionality, where to add the file creation, etc.

---

<div class="post-metadata">

**Author:** ![EddyMI3D](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/eddymi3d/32/1981_2.png) [@EddyMI3D](https://klipper.discourse.group/u/EddyMI3D)\
**Post date:** [September 10, 2024, 1:39pm UTC](https://klipper.discourse.group/t/recovering-print-after-power-shutdown/3422/2 "2024-09-10T13:39:03Z")

</div>


