Every print ends with an error and the nozzle stopped on the print

Since installing MainsailOS on my RPi3b and setting up Klipper, the printing head doesnt reset to home at the end of the print. I get an error for the status on the dashboard of the web interface, and the print head is stopped at the very last position of the gcode instructions, so I get a melted spot from the nozzle remaining in contact with the print, unless Im right there to hit home as the print finishes. I’ve been absorbing most of what Ive been figuring out, and the pointers I’ve got from the community, but I still haven’t figured out how to fix this issue, or even where I would find the relevant settings menu or config file or whatever it is I need to do to fix the issue. If anyone could help me out, it’d be greatly appreciated, thanks!

Can you please share the klippy.log?

How do I do that, it says that file type isn’t allowed.

You can zip it then it should work.

Worked cool

klippy (1).log.zip (376 KB)

Do you see anything that looks out of place?

There are actually 2 errors in the log:

Write g-code response
Traceback (most recent call last):
  File "/home/pi/klipper/klippy/gcode.py", line 446, in _respond_raw
    os.write(self.fd, (msg+"\n").encode())
OSError: [Errno 11] Resource temporarily unavailable
Stats 326798.8: gcodein=0 mcu: mcu_awake=0.000 mcu_task_avg=0.000000 mcu_task_stddev=0.000000 bytes_write=1041 bytes_read=3839 bytes_retransmit=9 bytes_invalid=0 send_seq=114 receive_seq=114 retransmit_seq=2 srtt=0.004 rttvar=0.001 rto=0.025 ready_bytes=0 stalled_bytes=0 freq=72000837 heater_bed: target=0 temp=0.0 pwm=0.000 Pi: temp=50.5  sysload=0.84 cputime=1231.952 memavail=616316 print_time=0.001 buffer_time=0.000 print_stall=0 extruder: target=0 temp=0.0 pwm=0.000

and this:

Stats 1208.8: gcodein=0 mcu: mcu_awake=0.001 mcu_task_avg=0.000009 mcu_task_stddev=0.000007 bytes_write=33906 bytes_read=150920 bytes_retransmit=9 bytes_invalid=0 send_seq=2690 receive_seq=2690 retransmit_seq=2 srtt=0.004 rttvar=0.000 rto=0.025 ready_bytes=0 stalled_bytes=0 freq=72000782 heater_bed: target=0 temp=24.1 pwm=0.000 Pi: temp=54.8  sysload=0.90 cputime=39.077 memavail=607536 print_time=15848.682 buffer_time=0.000 print_stall=3 extruder: target=0 temp=62.9 pwm=0.000
webhooks client 1971778024: Disconnected
webhooks: Error sending server data,  closing socket
Stats 1209.8: gcodein=0 mcu: mcu_awake=0.001 mcu_task_avg=0.000009 mcu_task_stddev=0.000007 bytes_write=33912 bytes_read=151054 bytes_retransmit=9 bytes_invalid=0 send_seq=2691 receive_seq=2691 retransmit_seq=2 srtt=0.004 rttvar=0.000 rto=0.025 ready_bytes=0 stalled_bytes=0 freq=72000784 heater_bed: target=0 temp=24.0 pwm=0.000 Pi: temp=53.7  sysload=0.90 cputime=39.100 memavail=636440 print_time=15848.682 buffer_time=0.000 print_stall=3 extruder: target=0 temp=62.7 pwm=0.000

Is it one of those?

I don’t even know how I would determine what the error is that happens at the end of every print. How would I go about figuring out what the cause of the error is? I’ll post a screenshot at the end of the print I’m doing to show you the error message I’m encountering. That’ll be in about an hour or so

That looks, as if the steppers are turned off (M18 or M84) and there is another attempt to move the axis again after that.

What do I need to change so that the nozzle will return to home at the end of the print?

What slicer do you use and how does the endcode in the slicer looks like?

I use Cura 4.13.1
How do I check the endcode or upload a copy of what you are asking me for?

Goto Preferences -> Configure Cura -> Printers -> select your printer -> Machine settings.

Cool, okay it says:
M104 S0 ; turn off extruder
M140 S0 ; turn off bed
M84 ; disable motors
M107
G91 ;relative positioning
G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure
G1 Z+0.5 E-5 ;X-20 Y-20 F{speed_travel} ;move Z up a bit and retract filament even more
G28 X0 ;Y0 ;move X/Y to min endstops, so the head is out of the way
G1 Y180 F2000
M84 ;steppers off
G90
M300 P300 S4000

i wasent able to just copy and paste the endcode, but im pretty sure ive copied it 100% accurately

You may use it like this:

M104 S0 ; turn off extruder
M140 S0 ; turn off bed
; delete: M84 ; disable motors
M107
G91 ;relative positioning
G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure
; is the ; before the X-20 in the next line ok?
G1 Z+0.5 E-5 ;X-20 Y-20 F{speed_travel} ;move Z up a bit and retract filament even more
G28 X0 ;Y0 ;move X/Y to min endstops, so the head is out of the way
G1 Y180 F2000
; move to the very end: M84 ;steppers off
G90
M300 P300 S4000
M84 ;steppers off

Exactly how it looks in the message above is exactly how it looks in Cura. If there is things you think I should delete, could you indicate that by putting some of these: { } around them please?

I already commented those line out and put another at the end.

Okay I just don’t understand the question about the ; before the X-20. I just copied all that code the way it was written in Cura, so I don’t know if that semicolon is okay. I wouldn’t know if there is or if there isn’t a problem with it. I’m really new to 3d printing, although I am a quick learner and it doesn’t take long for me to pick things up.

It was just for better understanging of that line, but it makes sanse to comment the x/Y movement out.

The issue is, that in the original script in line 3 (M84 ; disable motors) the motors have been turned off. In that case Klipper assumes the axes can be have moved manually and so the positions are not correct any more.
In line 7 (G1 Z+0.5 E-5) the z-axes should be moved up, but Klipper does not know where it actually is. so the error is produced.