Auto Restart Klipper When Ender3 Connected to Pi
Some time ago installed Klipper on my OctoPi which is connected to my Ender3. One issue I’ve had is that I have to manually open Octoprint and restart the Klipper process for Klipper to connect to the printer. Today I decided to fix this issue.
I used the suggestion in this post with some changes originating in this post to create my rule.
I start off by accessing Octopi using ssh. Then I create the file 98-klipper.rules
in the /etc/udev/rules.d/
folder.
ssh octoprint
sudo touch /etc/udev/rules.d/98-klipper.rules
sudo nano /etc/udev/rules.d/98-klipper.rules
I then add the following text into the file
## rule to restart klipper when the printer is connected via usb
SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ACTION=="add", RUN+="/usr/bin/sudo -u pi /bin/sh -c '/bin/echo RESTART > /tmp/printer'"
Finally I re-load the udev rules
sudo udevadm control --reload-rules
If everything works correctly, when I turn on the printer, Klipper will restart automatically.