Building a Low-Code 3D Print Failure Watcher: Zero-Shot Gemma 3, n8n, & Home Assistant

Building a Low-Code 3D Print Failure Watcher: Zero-Shot Gemma 3, n8n, & Home Assistant

Unbranded enclosed Core-XY 3D printer with subtle AI vision bounding box scanning a geometric print

Automated AI 3D print failure watcher scanning a Core-XY 3D printer build plate

If you do any amount of 3D printing on a Bambu P1S, you know the drill: modern Core-XY machines run fast, and when a failure happens, it doesn’t waste time. Spaghetti, knocked-over supports, and blobbed hotends can turn half a spool of filament into an expensive bird’s nest before you even check your phone.  And the spaghetti mess isn’t usually detected until it does something drastic, such as knocking loose the extruder drawer.

I decided to tackle this problem with a clean slate. My primary goal? Go low-code first. Instead of hacking together yet another docker application that expose background services,  I wanted to see if I could build a modular, state-driven print monitor orchestrating tools I already run: Home Assistant, n8n, and local (LAN) inference via Ollama.

The Experiment: Pure Zero-Shot Vision

Here is the catch with this first attempt: we aren’t giving the vision LLM any hand-holding or pre-classified examples. No fine-tuning, no pre-trained custom weights. We are passing raw camera snapshots straight into a zero-shot multi-modal model (Gemma 3 4B) with a simple instruction: “Decide if this print failed, and reply with JSON.”

If this experiment works, great! If it struggles, we’ll use the collected dataset to fine-tune our own purpose-built model.

The Architecture at a Glance

Rather than letting a script poll constantly in a vacuum, the system is strictly state-driven:

Architecture diagram: Home Assistant to n8n Orchestrator to go2rtc Camera to Ollama Gemma 3 to Pushover Alert, branching to Local Storage
End-to-end flow: Home Assistant triggers the job lifecycle, n8n runs the 5-minute snapshot & grading loop, and every frame is archived locally.
  • Trigger
    Home Assistant monitors the Bambu MQTT integration. When print status switches to running or prepare, it calls an n8n webhook. When the print stops or finishes, it hits the stop webhook.
  • Orchestrator
    n8n manages the active state, 5-minute schedule ticks, and error handling. It remains completely idle when the printer is off.
  • Vision Feed
    go2rtc exposes a single-frame snapshot endpoint (/api/frame.jpeg?src=p1s) so we don’t hold an RTSP video stream open.
  • Grading
    Gemma 3 (4B-IT-QAT) running locally in Ollama inspects each captured frame and returns a structured JSON verdict.
  • Alerts
    Pushover delivers high-priority notifications straight to my phone after two consecutive failure verdicts.

How the Flow Works Step-by-Step

1. Clean Slates on Every Run

One of my hard requirements was that I didn’t want months of old photos cluttering disk space or mixing between jobs. When Home Assistant sends the /print-start hook, n8n executes an SSH command against the local storage pool on my server:

BASE="/srv/.../Printer_Logs"
rm -rf "$BASE/good" "$BASE/bad"
mkdir -p "$BASE/good" "$BASE/bad"

This resets the workspace so every single print job starts with clean, isolated good/ and bad/ folders.

2. Snapshot Grabbing Every 5 Minutes

While the print is active, a 5-minute interval timer grabs a single 720p JPEG frame (~62 KB) from go2rtc and stamps it with a UTC filename like 2026-11-15T21-40-15-945z.jpg. Crucially, because the Bambu P1S camera only allows ~2 simultaneous clients and occasionally drops frames when the official Bambu app connects, we added non-blocking error handling: if a frame is dropped, it logs a CAMERA_TIMEOUT line without false-alerting or crashing the workflow.

What the Watcher Sees (Captured Every 5 Minutes)

Because the P1S camera sits low at the front-left corner of the chamber, the model has to work with a tight angle, a dark textured PEI plate, and a fast-moving toolhead. Here are actual frames captured by the pipeline and sorted into good/ and bad/:

✓ good/ — Mid-Print Infill Capture

Bambu P1S camera snapshot showing a clean mid-print multicolor infill grid on the textured build plate

Healthy mid-print frame: crisp infill grid and clean adhesion on the dark PEI plate.
✓ good/2026-11-15T21-40-15-945z.jpg

Bambu P1S camera snapshot showing solid completed top layers on the build plate

Timestamped 5-minute capture later in the same job as solid top layers finish cleanly.

✗ bad/ — Clear Filament Spaghetti

Bambu P1S camera snapshot showing tangled clear filament spaghetti across the build plate

Classic spaghetti failure: loose strands dragged across the plate under the nozzle.
✗ bad/ — Detached & Fallen Part

Bambu P1S camera snapshot showing a knocked-over orange 3D printed cylinder with loose strands

Knocked-over orange cylinder with stray filament loops—and motion blur from the moving toolhead.

3. The Zero-Shot Gemma 3 Grade

Each captured image is converted to Base64 and sent via HTTP to Ollama (gemma3:4b-it-qat, temperature 0) with a strict JSON prompt:

“You are monitoring a 3D printer camera. Decide whether the print has FAILED. Failure means: loose or stringy filament (spaghetti), tangled blobs, or detached parts. NOT failures: normal parts, toolhead occlusions, or the dark build plate. Reply with JSON only: {“failure”: true|false, “reason”: “…”}”

4. Sorting Images & Reading watcher.log

Once the JSON response is parsed, n8n writes the JPEG into good/ (if OK) or bad/ (if FAIL) and appends a tab-separated line to watcher.log with the timestamp, verdict, consecutive failure count, and the model’s exact reasoning.

Here is an actual slice from watcher.log during a real print run, showing the 5-minute scan cadence, the consecutive failure counter ticking up and resetting, and the job lifecycle hooks:

/srv/…/Printer_Logs/watcher.log
2026-11-17T23-25-16-708z  OK    consec:0  The image shows a build plate with multiple white, rectangular 3D-printed objects... neat rows, solid state.
2026-11-17T23-30-15-625z  OK    consec:0  The image shows a build plate with several small, rectangular white and gray plastic blocks...
2026-11-17T23-35-16-724z  FAIL  consec:1  [The print appears to be partially complete but has significant warping and separation.] ...
2026-11-17T23-40-15-926z  FAIL  consec:2  [The print appears to be partially complete, but with significant warping and loose pieces.] ...
2026-11-17T23-45-16-252z  OK    consec:0  The image shows a build plate with several white, rectangular pieces...
2026-11-17T19-03-03-0500  JOB_END    Monitoring stopped
2026-11-29T11-20-39-0500  JOB_START  Wiped folders and activated monitoring

Preventing Notification Fatigue: The 2-Check Rule

Notice those consec:1 and consec:2 entries in the log above! A low-angle camera with a moving toolhead is tricky: shadows, infill grids, or separate objects on the plate can occasionally trick a zero-shot 4B model into crying wolf. To prevent bogus alerts, n8n tracks consecutiveFailures and only fires Pushover when two consecutive checks (10 minutes apart) fail. Any passing check resets the counter straight back to zero.

5. Shutting Down Cleanly

When Home Assistant detects that the printer state has left running (finished, stopped, or cancelled), it fires the /print-end webhook. n8n flips its static active flag to false, appends JOB_END to watcher.log, and goes back to sleep.

What’s Next? (Model Training Plan B)

This is v1—a low-code prototype built to test the limits of general-purpose local vision models without writing specialized microservices.

Because every 5-minute snapshot is systematically cataloged into good/ and bad/ folders alongside the model’s reasoning in watcher.log, the system is already building its own labeled dataset.

As the real logs above show, zero-shot Gemma 3 4B can spot obvious spaghetti, but still throws occasional false positives on normal multi-part plates. Next up: feeding reference “good” frames into few-shot prompts, and if needed, training a lightweight custom classifier directly on the archive this watcher collects.

Have you tried local vision LLMs for 3D print monitoring? Let me know how your experience compares in the comments!

Add a comment

*Please complete all fields correctly

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Blogs

No Image
No Image