PrintWatch Plugin that runs on any Klipper based 3D Printer. This backend monitors the webcam stream on any Klipper printer for spaghetti type defects. It can work with any camera that is accessible via an IP address/HTTP endpoint. This Plugin requires Moonraker for making API requests to the Klipper firmware.
If you are an OEM using Klipper for their printers, please contact us for a more custom integration, support, and licensing options.
This Backend component can be installed on any Linux device that is running Klipper. Ensure that the latest version of pip is installed on your device with the following commands:
pip install --upgrade pip
In some cases you will need to specify pip3:
pip3 install --upgrade pip
In some cases, you will need to upgrade using python:
python -m pip install --upgrade pip
Please follow the steps below for your device:
- SSH into the Raspberry Pi and navigate to the root directory of the user
cd /home/pi
- Download this repository's release for Raspberry Pi
git clone https://github.com/printpal-io/Klipper-PrintWatch
- Change directories
cd Klipper-PrintWatch
- Install libraries
pip3 install -r requirements.txt
- Modify the settings file
sudo nano settings.json
Then modify the api_key and camera_ip fields to match your configuration.
You can obtain your API key from your account's settings tab, or upgrade if you haven't upgraded your account yet.
The camera_ip field should be the URL address for retrieveing the static image of your webcam. If using crowsnest (built-in streamer for Klipper), this URL is configured in your crowsnest.conf file. The address is typically http://127.0.0.1/webcam/?action=snapshot. Verify this by entering the URL into your browser and ensuring the static image of the webcam is returned.
If you want to edit the api_key or camera_ip after having started the printwatch.service, you must run the command systemctl restart printwatch for the changes to take effect.
- Reload the systemctl daemo
sudo systemctl daemon-reload
- Enable the systemctl process for PrintWatch
sudo systemctl enable /home/pi/Klipper-PrintWatch/printwatch.service
- Start the systemctl process for PrintWatch
sudo systemctl start printwatch.service
- Validate the printwatch process is running
sudo journalctl -u printwatch
Outputs:
Sep 08 23:35:24 pi systemd[1]: Started PrintWatch AI.
Sep 08 23:35:28 pi python3[2237]: INFO: Started server process [2237]
Sep 08 23:35:28 pi python3[2237]: INFO: Waiting for application startup.
Sep 08 23:35:28 pi python3[2237]: INFO: Application startup complete.
Sep 08 23:35:28 pi python3[2237]: INFO: Uvicorn running on http://0.0.0.0:8989 (Press CTRL+C to quit)
You must overwrite the Mainsail directory with the folder in this repository in order to enable the AI panel (this will change in the future).
- Change directories to root:
$ cd ~
- Overwrite the current mainsail folder:
$ cp -rf Klipper-PrintWatch/mainsail .
- Verify that the AI component is on the WebUI by visiting
http://<DEVICE IP>and navigating to the Dashboard:
Visit the Mainsail UI page at http://<RPi IP address>
Navigate to the dashboard and observe the AI component added to the dashbaord items:
What each item means:
Status : this is the status of the AI monitor, it can be: Monitoring, Idle, or Disabled.
Monitoring: this means that the AI is actively running and analyzing the webcam imagesIdle: this means the AI is turned on but not actively observing anything.Disabled: this means the AI is turned off
Sensitivity : this is the current sensitivity of the AI set by the user. It can be three values:
Fast (3 minutes): it takes ~3 minutes of consistent positive detections for an action to occurMedium (6 minutes): it takes ~6 minutes of consistent positive detections for an action to occurLong (12 minutes): it takes ~12 minutes of consistent positive detections for an action to occur
Notification : if notifications are enabled by the user
Pausing : if pausing the print is enabled by the user
Defect Level : the current moving average of the defect level detected by the AI
- this value is
0-100 - it is a moving average value of the last
16/32/64detections- if
Sensitivity=Fast (3 minutesthe last 16 detections are used for the average - if
Sensitivity=Medium (6 minutesthe last 32 detections are used for the average - if
Sensitivity=Fast (12 minutesthe last 64 detections are used for the average
- if
- Equation for the moving average is:
Visit the settings page from the top navigation bar of the Mainsail UI and navigate to the AI sidebar option:
The user can change the settings on this page and then must click SAVE.
If this is your first time using the plugin, follow our configuration guide for configuring your camera's settings, location, and the lighting.
Develop a custom integration with the AI backend by using the REST API documentation found on this repository.
