Build an AI Print-Failure Watchdog with the Arduino UNO Q (Part 2): Camera Setup and Training Images
Part 1: Idea, Case and Camera Mount
Part 2: Camera Setup and Training Images (this article)
Part 3: Training the Anomaly Model with Edge Impulse
Part 4: Building the Watchdog App with App Lab
Part 5: Optimisation and Finalisation
In part 1 of this series I introduced the idea of the AI print watchdog and assembled the hardware: an Arduino UNO Q* with its Media Carrier* and an IMX219 camera* hang on a printed clip at the 3D printer. Today we bring the rig to life — and that turned out more exciting than planned: the UNO Q simply ignored the camera, and as far as I know the solution hadn’t been documented anywhere. By the end of this part, the setup delivers a live view in the browser and collects training images for the AI fully automatically.
The problem: the camera is invisible
Camera plugged into CAM0 (contacts facing the board, power off!), board booted, connected via SSH — and then the disappointment. libcamera’s camera tool finds: nothing.
arduino@uno-q:~$ cam -l
Available cameras:
arduino@uno-q:~$ ls /dev/media*
ls: cannot access '/dev/media*': No such file or directory
The kernel log is just as empty: no IMX219, no camera subsystem. The cause sits in the device tree — the hardware description Linux receives at boot. The UNO Q’s stock image simply doesn’t enable the Qualcomm chip’s camera subsystem. The good news: Arduino ships the correct description as a ready-made file, it just isn’t used. On newer images (verified on image 558 and newer) there is a switch for this in the App Lab settings — my December image didn’t have it yet, but after reflashing to image 558 I verified the route with App Lab 0.10: click the gear (Settings) at the bottom left, scroll to the “Carriers” section, enable “Enable external carriers connected to your Arduino UNO Q” — the Media Carrier is detected automatically. For Camera0, choose “type1-2lanes” (the IMX219 uses two MIPI data lanes; the 4-lanes option is for other sensors) and click “Apply and reboot”. After the restart the camera is there — you can double-check further down with cam -l.
If you run an older image — or want to know what the switch actually does under the hood — here is the manual route.
The fix: a dedicated boot entry with the camera device tree
⚠️ This section is only needed on older images. On current images, the carrier switch in the App Lab settings shown above does the job (see the screenshot) — you can skip straight to the live view chapter. The manual route stays documented for anyone running an image without the switch, or who wants to understand what happens behind it.
In the board’s EFI directory, right next to the standard device tree, sits a variant with camera support: on older images it is called qrb2210-arduino-imola-camera-rpiv2.dtb (“rpiv2” as in Raspberry Pi camera version 2, exactly our IMX219), from image 558 onward it is qrb2210-arduino-imola-carrier-media-full-2lanes.dtb — check with ls /boot/efi/dtb/qcom/ which one you have. Instead of riskily overwriting the standard file, we create a second boot entry that explicitly loads this device tree. If anything goes wrong, the old entry still boots — that is our safety net.
sudo nano /boot/efi/loader/entries/camera.conf
The content is a copy of the existing entry from the same folder, extended by the devicetree line (take kernel version and UUID from your original entry):
title Camera (imx219)
linux /<machine-id>/<kernel>/linux
initrd /<machine-id>/<kernel>/initrd.img-<kernel>
devicetree /dtb/qcom/qrb2210-arduino-imola-camera-rpiv2.dtb
options root=UUID=<your-uuid> clk_ignore_unused pd_ignore_unused audit=0 deferred_probe_timeout=30
Now the bootloader has to load the new entry by default. That is controlled by the central bootloader configuration, which you also open as root:
sudo nano /boot/efi/loader/loader.conf
The file is only a few lines long. Here is what mine looked like before — the default line points to the standard entry, whose cryptic name is your board’s machine ID (so it will read differently on yours):
#timeout 3
#console-mode keep
default a3cfdcbfa9ad463e89f8a1f9bd9a5dd4-*
Change nothing but the default line, pointing it at the new entry. Best practice: keep the old line as a comment — that way the way back is documented right inside the file:
#timeout 3
#console-mode keep
# old default line, kept as the way back:
#default a3cfdcbfa9ad463e89f8a1f9bd9a5dd4-*
default camera.conf
Save with Ctrl+O and Enter, leave the editor with Ctrl+X, then sudo reboot. A side note for the advanced crowd: the more elegant bootctl set-default does not work on the UNO Q because the EFI variables are read-only under its U-Boot firmware — hence the file-based route. After the reboot comes the moment of relief:
arduino@uno-q:~$ cam -l
Available cameras:
1: 'imx219' (/base/soc@0/cci@5c1b000/i2c-bus@0/sensor@10)
The camera lives! Two quirks of the Qualcomm platform are worth knowing: captures need root privileges (access to the graphics memory heaps is locked down by default), and the full 8-megapixel resolution fails due to the small reserved memory pool — 632×480 works reliably, and our AI doesn’t need more anyway: it will later crunch a mere 96×96 pixels internally.
A live view in the browser for aiming
To aim the camera you want a live view — ideally on your phone while your other hand turns the joint. Standard tools are all it takes: GStreamer grabs frames from the camera and drops them as JPEG into RAM, and a small Python script (standard library only, no Flask required) serves an MJPEG stream from that. Both files are ready to go in the project’s GitHub repository, and the easiest way to get them is directly on the board via SSH — wget pulls them from GitHub into your home directory:
cd ~
wget https://raw.githubusercontent.com/raspberry-tips/uno-q-3d-print-watchdog/main/camera-setup/liveview.py
wget https://raw.githubusercontent.com/raspberry-tips/uno-q-3d-print-watchdog/main/camera-setup/capture.sh
chmod +x capture.sh
liveview.py is the stream server for this chapter; capture.sh comes into play in the image-collection section below. Install the GStreamer tool package first (one-time — it was missing on my image), then start the stream:
sudo apt install gstreamer1.0-tools
sudo systemd-run --unit=liveview --collect python3 /home/arduino/liveview.py
# live view: http://<board-ip>:8080
Three practical details in the script will save you frustration: First, the camera hangs upside down in our mount, so the pipeline rotates the image by 180 degrees (videoflip method=rotate-180). Second, focus: the camera is fixed-focus, and in my case the image was perfectly usable at print-bed distance without touching anything — check first, adjust later. One more note: if you mount the camera much closer to the bed, you will have to refocus (turn the lens ring). Arducam also offers the IMX219 as a dedicated motorized-focus variant with software-controlled focus — the standard and NoIR modules (ours) are fixed focus. If your live view really is blurry, the lens can be carefully rotated on its thread; the zoom levels on the page help you judge. And third, the camera pipeline tends to silently stall after a while — so the script watches itself and automatically restarts the pipeline when fresh frames stop coming. Without that watchdog you will eventually stare at a frozen “live” view and wonder.
Don’t be surprised by the pale, slightly greenish colors, by the way: the NoIR camera has no infrared filter and the software pipeline has no color profile for the sensor. For our anomaly detection this is completely irrelevant — what matters is that the images always look the same.
Positioning the camera — and locking the position down
With the live view on your phone, aiming is done quickly: diagonally from the front and above, the print zone fills the center of the frame, the print head only crosses the upper third. Then tighten the joints — and I mean really tighten them. I speak from experience: one careless touch knocked my camera out of position in the middle of data collection, and since the AI learns the entire scene, the collected dataset would have been worthless. What saved me was a comparison image: current live view blended half-transparent over an old photo, camera re-adjusted until the edges lined up.
That incident turned into a routine I strongly recommend: home the print head and bed once and save a reference photo of that pose. The home position is exactly reproducible at any time — turning “looks about right” into a genuine two-minute comparison against ground truth.
Collecting training images — fully automatic
Now for the actual point of all this: the AI is supposed to learn what a normal print looks like. The capture.sh you already downloaded copies the current camera image into a dataset folder every ten seconds. To make both parts easy to control, we turn live view and collector into proper systemd services — the matching unit files also live in the repository and are installed in a minute:
sudo wget -P /etc/systemd/system https://raw.githubusercontent.com/raspberry-tips/uno-q-3d-print-watchdog/main/camera-setup/liveview.service
sudo wget -P /etc/systemd/system https://raw.githubusercontent.com/raspberry-tips/uno-q-3d-print-watchdog/main/camera-setup/capture.service
sudo systemctl daemon-reload
sudo systemctl enable --now liveview
The live view now starts automatically with the board (stop the systemd-run test run from above first with sudo systemctl stop liveview if it is still going). The collector deliberately stays manual — you start and stop it per print job:
sudo systemctl start capture # when the print starts
sudo systemctl stop capture # when the print is done
Collecting the data taught me three rules that decide the quality of the training material:
- Collect from job start, stop at job end. Heating, leveling and the first layer belong in the training — these are exactly the phases where adhesion failures happen, and the watchdog will be watching them later too. What must stay out: idle time, plate swaps, your hands in the frame.
- Variety beats volume. A thousand near-identical frames of the same print add little — every new print with a different object and filament color is worth more. After four prints I had roughly 1,500 images in the folder, more than enough for a first attempt.
- Light on means light on — always. The scene must stay constant, and black filament on a dark bed in evening light is invisible even to humans. My rule ever since: print running = light running. You will see the impact in the training data in part 3.
Coming up in part 3
Roughly 1,500 normal images are in the bag — and thanks to an involuntary stroke of luck, even genuine failure images: right in the middle of collecting, one print treated me to classic stringing, and the camera dutifully photographed it. In the next part we upload everything to Edge Impulse, train the FOMO-AD anomaly model and use the real spaghetti images to tune the alarm threshold. That is when we find out for the first time whether the experiment holds up. Have fun building along!
Update: Part 3 is now online — continue with training, threshold calibration and a model that caught my own mistake.
Frequently asked questions
No. On current UNO Q images the camera toggle sits right in the App Lab settings. Only older images need the boot-entry route shown here — and that is copy-and-paste of two text files, with the old entry as a safety net.
Easily. The anomaly model works with 96×96 pixels internally — what matters is not resolution but that position, angle and lighting stay constant. The limit comes from the system’s small reserved camera memory and could be raised via a kernel parameter, but this project doesn’t need it.
Yes — my liveview service starts automatically with the board and runs around the clock, and the collector service simply reads the same image. Only later, when the watchdog app itself accesses the camera, the stream must not run in parallel — more on that in part 4.




