The Spaghetti Detective: Automated 3D Print Failure Detection
A common issue in 3D printing is a loss of bed adhesion resulting in hours of wasted filament extruded into a "spaghetti" pile. This project integrates a local Raspberry Pi camera feed running Klipper firmware with AWS Machine Learning to automatically detect failures and halt the machine.
The Architecture Flow
[ Klipper Pi (Camera) ] → (Push Image) → [ Amazon S3 ]
↑ ↓ (S3 Event Notification)
[ Klipper Moonraker API ] ←——————— [ AWS Lambda ] ←→ [ Rekognition Custom Labels ]
1. Edge Ingestion
A cron job on the Raspberry Pi captures a frame from the printer's webcam every 5 minutes and uses the AWS CLI to execute an s3:PutObject command, uploading the image to an ingestion bucket.
2. Event-Driven AI Inference
The moment the image lands in the bucket, an S3 Event Notification triggers a Lambda function. The function passes the S3 object key to Amazon Rekognition Custom Labels, an ML model trained specifically on images of failed 3D prints ("spaghetti").
3. Automated Remediation
If Rekognition returns a confidence score higher than 85% for a print failure, the Lambda function executes an automated remediation protocol. It sends a secure REST API call back to the local network (via a secure tunnel) to the Klipper Moonraker API, executing the emergency stop command to halt the printer heater and motors.
Training a custom model in Amazon SageMaker from scratch would require significant data science overhead and compute costs. By utilizing Rekognition Custom Labels, I abstracted the heavy lifting of the ML pipeline, allowing me to focus entirely on the integration and automated remediation workflows.