printpal-io / Klipper-PrintWatch

PrintWatch for Klipper
GNU General Public License v2.0
6 stars 2 forks source link

Klipper-PrintWatch

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.

Installation

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:

Raspberry Pi

  1. SSH into the Raspberry Pi and navigate to the root directory of the user
    cd /home/pi
  2. Download this repository's release for Raspberry Pi
    git clone https://github.com/printpal-io/Klipper-PrintWatch
  3. Change directories
    cd Klipper-PrintWatch
  4. Install libraries
    pip3 install -r requirements.txt
  5. 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.

  1. Reload the systemctl daemo
    sudo systemctl daemon-reload
  2. Enable the systemctl process for PrintWatch
    sudo systemctl enable /home/pi/Klipper-PrintWatch/printwatch.service
  3. Start the systemctl process for PrintWatch
    sudo systemctl start printwatch.service
  4. 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)

Enabling the AI component on Mainsail UI

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).

  1. Change directories to root:
    $ cd ~
  2. Overwrite the current mainsail folder:
    $ cp -rf Klipper-PrintWatch/mainsail .
  3. Verify that the AI component is on the WebUI by visiting http://<DEVICE IP> and navigating to the Dashboard:

image

How to use the PrintWatch AI plugin on Mainsail UI

Navigate 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:

image

What each item means:

Status : this is the status of the AI monitor, it can be: Monitoring, Idle, or Disabled.

Sensitivity : this is the current sensitivity of the AI set by the user. It can be three values:

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

image

Navigate to the settings

Visit the settings page from the top navigation bar of the Mainsail UI and navigate to the AI sidebar option:

image

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.

Development

Develop a custom integration with the AI backend by using the REST API documentation found on this repository.