Skip to content

Equipment monitoring using Pi Zero 2 W cameras #11

Open
0 of 1 issue completed
Open

Description

@sgbaird

PXL_20240829_210342178.jpg

Need to order tripod, pi zero case, and tripod nut.

Add documentation page to devices dir (aside: need to expose device pages)

Possible setups:

  • YT live streaming
  • MQTT "point and shoot"
  • other streaming/camera feed/API access (Kafka?)

Possible demo extensions:

  • HeinSight
  • observing linear actuator (picture OK), fan (livestream, zoomed in), MyCobot 280, capper/decapper (picture or video OK), Jubilee system, OT-2, microscopes
  • Custom tool on Jubilee

Related: OpenMV demo.

Activity

  1. sgbaird commented on Sep 5, 2024

    @sgbaird
    CollaboratorAuthor

    Also, setting up the tripod and case.

    PXL_20240905_194633334.jpg

    PXL_20240905_194641558.jpg

    There's a second case type, with no tripod attachment

    PXL_20240905_194737158.jpg

  2. sgbaird commented on Sep 16, 2024

    @sgbaird
    CollaboratorAuthor

    I ordered ball bearing attachments for the prime cables clamp tripods.

    PXL_20240916_163314097.jpg

    The additional four should be set up in a similar manner. There's one extra in the cabinet (might move).

    PXL_20240916_163318146.jpg

    PXL_20240916_163353126.jpg

  3. added this to the Training Lab v1.0 milestone on Sep 20, 2024
  4. sgbaird commented on Sep 20, 2024

    @sgbaird
    CollaboratorAuthor

    For the setup, also important to have a micro USB to female USB-A cable (comes in the pi zero 2 W kits), and a keyboard/mouse combo (however in this case maybe you need two USB ports or a USB splitter)

    For the camera mount, a small Phillips screwdriver works

    IMG_20240920_171722.jpg

    Mount item and instructions:

    https://www.pishop.ca/product/pro-mini-camera-mount-for-raspberry-pi-zero/

    https://thepihut.com/blogs/raspberry-pi-tutorials/pro-mini-camera-mount-assembly-guide

  5. sgbaird commented on Sep 30, 2024

    @sgbaird
    CollaboratorAuthor

    @Jonathan-Woo any updates?

  6. Jonathan-Woo commented on Oct 3, 2024

    @Jonathan-Woo
    Contributor

    IMG_3034
    IMG_3035
    IMG_3037

    IMG_3038.MOV

    I have the hardware setup but I think we need a smaller nut to connect to the tripod or PrimeCables mount. The current one is too thick so the standoffs can't sit flush on the case.

    On the software side of things, I believe we'll building using picamera2. What sort of MWE/system would you like me to build?

  7. sgbaird commented on Oct 3, 2024

    @sgbaird
    CollaboratorAuthor

    Nice! Ok, can you identify a nut (maybe on Amazon) that you think will work OK? For the software, it would be great if you could try to get a YouTube livestream set up with it. I'll send credentials for an "AC hardware stream" account, or you can use a personal account for testing.

    Before that, following a tutorial to get the video feed displaying on the desktop of the Pi Zero 2W would be a good start (and a really short video demo of it from your phone would be nice, too)

    EDIT: and make sure to invert the camera feed with the software (specific to this camera mount)

  8. Jonathan-Woo commented on Oct 4, 2024

    @Jonathan-Woo
    Contributor

    Sounds good, I'll look into that. Regarding the video feed displaying on the desktop of the Pi Zero 2W, I was wondering if there was something specific you wanted differently than the attached video above. Thanks!

  9. sgbaird commented on Oct 4, 2024

    @sgbaird
    CollaboratorAuthor

    Oh, sorry! Somehow I missed that. That looks great. I'm also seeing that the PDF you linked to is very comprehensive. Anything in particular you'd want to note about following that guide? E.g., certain install commands you used. It would be great if you could also include the code you ran to produce the preview.

    Past that, I'd say you're good to move onto setting up a livestream as well some of the other camera modules (the latter of which I imagine will be straightforward).

    Thanks for working on this.

  10. sgbaird commented on Oct 4, 2024

    @sgbaird
    CollaboratorAuthor

    Sent you a stream key and the stream URL attached to https://www.youtube.com/@ac-hardware-streams channel.

  11. sgbaird commented on Oct 4, 2024

    @sgbaird
    CollaboratorAuthor
  12. Jonathan-Woo commented on Oct 4, 2024

    @Jonathan-Woo
    Contributor

    Yeah that looks good, 1/4"

  13. sgbaird commented on Oct 8, 2024

    @sgbaird
    CollaboratorAuthor

    The item arrived from amazon

  14. sgbaird commented on Oct 10, 2024

    @sgbaird
    CollaboratorAuthor

    Accidentally got something that was 1/4" outside dimensions.. planning to order a new part.

  15. 49 remaining items

  16. sgbaird commented on Jul 3, 2025

    @sgbaird
    CollaboratorAuthor

    Trying out a longer cable setup, courtesy of @kelvinchow23

    PXL_20250703_201833944.mp4

    Also trying with it plugged into a standard USB port instead of an outlet

    This is mfu2

    EDIT: says "excellent" connection, so seems like the longer cable and the lower power isn't an issue (?)

  17. changed the title [-]Pi Zero 2 W camera for equipment monitoring[/-] [+]Equipment monitoring using Pi Zero 2 W cameras[/+] on Jul 4, 2025
  18. sgbaird commented on Jul 4, 2025

    @sgbaird
    CollaboratorAuthor

    No data and disconnected from tailscale:

    • 4ehl (SDL2)
    • pd5d (SDL6)

    It would be good to check whether these are plugged in.

    No data, but connected on tailscale:

    • zagr (SDL4)
    ac@rpi-zero2w-stream-cam-zagr:~ $ sudo journalctl -u device.service -f
    Jul 04 16:32:54 rpi-zero2w-stream-cam-zagr python3[692]: [48.0K blob data]
    Jul 04 16:37:02 rpi-zero2w-stream-cam-zagr python3[692]: [48.0K blob data]
    Jul 04 16:41:11 rpi-zero2w-stream-cam-zagr python3[692]: [47.9K blob data]
    Jul 04 16:45:19 rpi-zero2w-stream-cam-zagr python3[692]: [47.9K blob data]
    Jul 04 16:49:27 rpi-zero2w-stream-cam-zagr python3[692]: [48.0K blob data]
    Jul 04 16:53:35 rpi-zero2w-stream-cam-zagr python3[692]: [47.9K blob data]
    Jul 04 16:57:44 rpi-zero2w-stream-cam-zagr python3[692]: [48.0K blob data]
    Jul 04 17:01:52 rpi-zero2w-stream-cam-zagr python3[692]: [48.0K blob data]
    Jul 04 17:06:00 rpi-zero2w-stream-cam-zagr python3[692]: [48.0K blob data]
    Jul 04 17:10:08 rpi-zero2w-stream-cam-zagr python3[692]: [48.0K blob data]
    ac@rpi-zero2w-stream-cam-zagr:~ $ sudo systemctl status device.service
    ● device.service - Start picam device.py script
         Loaded: loaded (/etc/systemd/system/device.service; enabled; preset: enabled)
         Active: active (running) since Fri 2025-07-04 13:00:12 EDT; 4h 13min ago
       Main PID: 592 (python3)
          Tasks: 22 (limit: 173)
            CPU: 57min 22.211s
         CGroup: /system.slice/device.service
                 ├─592 /home/ac/ac-training-lab/src/ac_training_lab/picam/venv/bin/python3 device.py
                 ├─691 libcamera-vid --inline --nopreview -t 0 --mode 1536:864 --width 854 --height 480 --framerate>
                 └─692 ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -thread_queue_size 1024 >
    
    Jul 04 16:32:54 rpi-zero2w-stream-cam-zagr python3[692]: [48.0K blob data]
    Jul 04 16:37:02 rpi-zero2w-stream-cam-zagr python3[692]: [48.0K blob data]
    Jul 04 16:41:11 rpi-zero2w-stream-cam-zagr python3[692]: [47.9K blob data]
    Jul 04 16:45:19 rpi-zero2w-stream-cam-zagr python3[692]: [47.9K blob data]
    Jul 04 16:49:27 rpi-zero2w-stream-cam-zagr python3[692]: [48.0K blob data]
    Jul 04 16:53:35 rpi-zero2w-stream-cam-zagr python3[692]: [47.9K blob data]
    Jul 04 16:57:44 rpi-zero2w-stream-cam-zagr python3[692]: [48.0K blob data]
    Jul 04 17:01:52 rpi-zero2w-stream-cam-zagr python3[692]: [48.0K blob data]
    Jul 04 17:06:00 rpi-zero2w-stream-cam-zagr python3[692]: [48.0K blob data]
    Jul 04 17:10:08 rpi-zero2w-stream-cam-zagr python3[692]: [48.0K blob data]

    Restarting the service manually (note-to-self, make sure to redact stream key):

    ac@rpi-zero2w-stream-cam-zagr:~ $ sudo systemctl stop device.service
    ac@rpi-zero2w-stream-cam-zagr:~ $ sudo systemctl start device.service
    ac@rpi-zero2w-stream-cam-zagr:~ $ sudo journalctl -u device.service -f
    Jul 04 17:16:57 rpi-zero2w-stream-cam-zagr python3[692]: Error writing trailer of <redacted>: Immediate exit requested
    Jul 04 17:16:57 rpi-zero2w-stream-cam-zagr python3[692]: frame=173815 fps= 11 q=-1.0 Lsize= 1429618kB time=03:15:08.98 bitrate=1000.2kbits/s speed=0.762x
    Jul 04 17:16:57 rpi-zero2w-stream-cam-zagr python3[692]: video:1414865kB audio:2987kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.829819%
    Jul 04 17:16:57 rpi-zero2w-stream-cam-zagr python3[692]: Error closing file <redacted>: Immediate exit requested
    Jul 04 17:16:57 rpi-zero2w-stream-cam-zagr python3[692]: [aac @ 0x558e3880a0] Qavg: 65536.000
    Jul 04 17:16:57 rpi-zero2w-stream-cam-zagr python3[692]: Exiting normally, received signal 15.
    Jul 04 17:16:58 rpi-zero2w-stream-cam-zagr systemd[1]: device.service: Deactivated successfully.
    Jul 04 17:16:58 rpi-zero2w-stream-cam-zagr systemd[1]: Stopped device.service - Start picam device.py script.   
    Jul 04 17:16:58 rpi-zero2w-stream-cam-zagr systemd[1]: device.service: Consumed 57min 23.538s CPU time.
    Jul 04 17:17:05 rpi-zero2w-stream-cam-zagr systemd[1]: Started device.service - Start picam device.py script.   
    Jul 04 17:17:28 rpi-zero2w-stream-cam-zagr python3[1021]: ffmpeg version 5.1.6-0+deb12u1+rpt3 Copyright (c) 2000-2024 the FFmpeg developers
    Jul 04 17:17:28 rpi-zero2w-stream-cam-zagr python3[1021]:   built with gcc 12 (Debian 12.2.0-14)
    Jul 04 17:17:28 rpi-zero2w-stream-cam-zagr python3[1021]:   configuration: --prefix=/usr --extra-version=0+deb12u1+rpt3 --toolchain=hardened --incdir=/usr/include/aarch64-linux-gnu --enable-gpl --disable-stripping --disable-mmal --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sand --enable-sdl2 --disable-sndio --enable-libjxl --enable-neon --enable-v4l2-request --enable-libudev --enable-epoxy --libdir=/usr/lib/aarch64-linux-gnu --arch=arm64 --enable-pocketsphinx --enable-librsvg --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-libplacebo --enable-librav1e --enable-shared
    Jul 04 17:17:28 rpi-zero2w-stream-cam-zagr python3[1021]:   libavutil      57. 28.100 / 57. 28.100
    Jul 04 17:17:28 rpi-zero2w-stream-cam-zagr python3[1021]:   libavcodec     59. 37.100 / 59. 37.100
    Jul 04 17:17:28 rpi-zero2w-stream-cam-zagr python3[1021]:   libavformat    59. 27.100 / 59. 27.100
    Jul 04 17:17:28 rpi-zero2w-stream-cam-zagr python3[1021]:   libavdevice    59.  7.100 / 59.  7.100
    Jul 04 17:17:28 rpi-zero2w-stream-cam-zagr python3[1021]:   libavfilter     8. 44.100 /  8. 44.100
    Jul 04 17:17:28 rpi-zero2w-stream-cam-zagr python3[1021]:   libswscale      6.  7.100 /  6.  7.100
    Jul 04 17:17:28 rpi-zero2w-stream-cam-zagr python3[1021]:   libswresample   4.  7.100 /  4.  7.100
    Jul 04 17:17:28 rpi-zero2w-stream-cam-zagr python3[1021]:   libpostproc    56.  6.100 / 56.  6.100
    Jul 04 17:17:28 rpi-zero2w-stream-cam-zagr python3[1021]: Input #0, lavfi, from 'anullsrc=channel_layout=stereo:sample_rate=44100':
    Jul 04 17:17:28 rpi-zero2w-stream-cam-zagr python3[1021]:   Duration: N/A, start: 0.000000, bitrate: 705 kb/s   
    Jul 04 17:17:28 rpi-zero2w-stream-cam-zagr python3[1021]:   Stream #0:0: Audio: pcm_u8, 44100 Hz, stereo, u8, 705 kb/s
    Jul 04 17:17:29 rpi-zero2w-stream-cam-zagr python3[1021]: Input #1, h264, from 'pipe:0':
    Jul 04 17:17:29 rpi-zero2w-stream-cam-zagr python3[1021]:   Duration: N/A, start: 1751663849.055111, bitrate: N/A
    Jul 04 17:17:29 rpi-zero2w-stream-cam-zagr python3[1021]:   Stream #1:0: Video: h264 (High), yuv420p(progressive), 854x480, 15 fps, 15 tbr, 1200k tbn
    Jul 04 17:17:29 rpi-zero2w-stream-cam-zagr python3[1021]: Stream mapping:
    Jul 04 17:17:29 rpi-zero2w-stream-cam-zagr python3[1021]:   Stream #1:0 -> #0:0 (copy)
    Jul 04 17:17:29 rpi-zero2w-stream-cam-zagr python3[1021]:   Stream #0:0 -> #0:1 (pcm_u8 (native) -> aac (native))
    Jul 04 17:17:29 rpi-zero2w-stream-cam-zagr python3[1021]: Output #0, flv, to '<redacted>':
    Jul 04 17:17:29 rpi-zero2w-stream-cam-zagr python3[1021]:   Metadata:
    Jul 04 17:17:29 rpi-zero2w-stream-cam-zagr python3[1021]:     encoder         : Lavf59.27.100
    Jul 04 17:17:29 rpi-zero2w-stream-cam-zagr python3[1021]:   Stream #0:0: Video: h264 (High) ([7][0][0][0] / 0x0007), yuv420p(progressive), 854x480, q=2-31, 15 fps, 15 tbr, 1k tbn
    Jul 04 17:17:29 rpi-zero2w-stream-cam-zagr python3[1021]:   Stream #0:1: Audio: aac (LC) ([10][0][0][0] / 0x000A), 44100 Hz, stereo, fltp, 128 kb/s
    Jul 04 17:17:29 rpi-zero2w-stream-cam-zagr python3[1021]:     Metadata:
    Jul 04 17:17:29 rpi-zero2w-stream-cam-zagr python3[1021]:       encoder         : Lavc59.37.100 aac
    

    Stream is now back up with "excellent". Might be worth tracking onboard temperature or some other indication of what might be going wrong. I'm guessing it probably would have restored the stream with the 8-hr restart.

  19. sgbaird commented on Jul 10, 2025

    @sgbaird
    CollaboratorAuthor

    Ilya is looking into some other mounting options to explore (e.g., suction cup). Self-reminder for adding links and pictures here.

  20. kelvinchow23 commented on Sep 17, 2025

    @kelvinchow23
    Contributor

    @pranshu-ui was running into issues with setting up a new picam for equipment monitoring and I tried to do it as well. We both ran into the same issues. when manually starting the script, it returns a 200 error:

    Image

    is there something with the aws/youtube connection that changed? i can see it created a playlist and is trying to connect, but the stream doesnt start. is this a hint at what may be the issue?

    Image
  21. sgbaird commented on Sep 17, 2025

    @sgbaird
    CollaboratorAuthor

    I think it's the wrong Lambda URL, my bad - this had been changed and I forgot to tell you. I'll DM it to you.

    EDIT: Confirming that was the issue. Could probably benefit from a more useful error message. I also deleted the other "upcoming videos"

  22. sgbaird commented on Sep 25, 2025

    @sgbaird
    CollaboratorAuthor

    I set up a fresh device with @ZeqingBao and we ran into the following error at the end. I saw the broadcast on YT but the stream hadn't started. Will need to debug later

    python3[7075]:   Stream #1:0: Subtitle: text
    
    python3[7075]: Codec AVOption preset (Encoding preset) specified for output file #0 (rtmp://a.rtmp.youtube.com/live2/XXXX-XXXX-XXXX-XXXX-XXXX) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
    
    python3[7075]: Stream mapping:
    python3[7075]:   Stream #0:0 -> #0:0 (pcm_u8 (native) -> aac (native))
    
    python3[7075]: Output #0, flv, to 'rtmp://a.rtmp.youtube.com/live2/XXXX-XXXX-XXXX-XXXX-XXXX':
    python3[7075]:   Metadata:
    python3[7075]:     encoder         : Lavf59.27.100
    python3[7075]:   Stream #0:0: Audio: aac (LC), 44100 Hz, stereo, fltp, 128 kb/s
    python3[7075]:     Metadata:
    python3[7075]:       encoder         : Lavc59.37.100 aac
    
    python3[7075]: [flv @ 0x558d3fd140] Failed to update header with correct duration.
    python3[7075]: [flv @ 0x558d3fd140] Failed to update header with correct filesize.
    python3[7075]: Error writing trailer of rtmp://a.rtmp.youtube.com/live2/XXXX-XXXX-XXXX-XXXX-XXXX: Broken pipe
    python3[7075]: size=      10kB time=00:00:10.54 bitrate=   8.1kbits/s speed=13.6x
    python3[7075]: video:0kB audio:3kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 286.143280%
    python3[7075]: Error closing file rtmp://a.rtmp.youtube.com/live2/XXXX-XXXX-XXXX-XXXX-XXXX: Broken pipe
    python3[7075]: [aac @ 0x558d3fd9c0] Qavg: 65536.000
    python3[7075]: Conversion failed!
    
  23. pranshu-ui commented on Oct 8, 2025

    @pranshu-ui

    Status update: PiCam setup blocked by OS/firmware shift (Bookworm → Trixie)

    TL;DR:
    Our current PiCam setup guide no longer works out-of-the-box. Recent Raspberry Pi OS/firmware changes associated with the Trixie transition (and what the Imager now surfaces by default) have changed key compatibilities. As a result, freshly imaged systems often boot but do not detect the camera module or provide libcamera tools as expected. We need to rebuild the step-by-step setup to account for these changes.

    What changed:
    Raspberry Pi Imager now prominently offers Debian Trixie/testing and Bookworm as “Legacy” images.
    So, it’s easy to end up with:

    • Plain Debian (Trixie or Bookworm) that lacks Raspberry Pi’s kernel/firmware plumbing for camera module
    • Legacy builds whose compatibility differs from our guide.

    As a result, even though the OS shows “Bookworm” (Debian 12), the kernel/firmware stack isn’t the Raspberry Pi one we rely on. That breaks camera detection and libcamera tooling used in our instructions.

    Current Behaviour

    1. Flash a fresh image following the old guide (using what Imager currently suggests).
    2. Boot a Pi Zero 2 W.

    Observe

    1. libcamera-hello missing or unavailable until extra repos are added.
    2. Even with libcamera installed, no cameras listed:
    3. libcamera-hello` --list-cameras # → empty
    4. Kernel shows generic Debian instead of Raspberry Pi’s downstream build:
    5. uname -a # shows no "+rpi" suffix
    6. ls -l /dev/video* # video10/11/12 only; no /dev/video0 (video0 means cam is connected)
    7. dmesg | grep -i unicam # empty (driver never bound)

    Why this blocks us
    Our pipeline assumes:

    • Raspberry Pi OS Lite kernel 64 bit with +rpi patches
    • Raspberry Pi firmware for the CSI (unicam) stack
    • libcamera-apps available in the Raspberry Pi repos
    • predictable behavior of the camera overlay/driver.

    With the Trixie-era shift surfaced by Imager, those assumptions are no longer guaranteed, so the camera never turns on and the guide fails at the first mile.

    Next step (what we will do)

    • We need to rewrite the step-by-step setup to be Legacy-aware and robust to the new Imager catalogue to this version specifically:

      | raspios_lite_arm64-2024-03-15/ | 2024-03-15 16:13 |  
    thru
    https://downloads.raspberrypi.com/raspios_lite_arm64/images/

    • Verify /dev/video0,
    • Run libcamera-hello --list-cameras and capture the detected sensor.
    • libcamera installed but no cameras listed → check ribbon orientation, connector, and dmesg | grep -i unicam.
    • Only /dev/video10/11/12 present → ISP nodes only; sensor not detected.

    Bottom line: This is a breaking change induced by the Bookworm → Trixie era update path and what Raspberry Pi Imager now presents by default. Our current guide assumes compatibilities that no longer hold. We’ll rebuild the setup instructions so new devices follow the correct OS/firmware path and pass automated pre-flight checks before proceeding.[DIR] raspios_lite_arm64-2024-03-15/ 2024-03-15 16:13

  24. sgbaird commented on Oct 8, 2025

    @sgbaird
    CollaboratorAuthor

    Thank you for documenting! In meantime, we'll use bookworm for #340 until we can implement the changes and leave enough time to check that it's stable (the original system now has cameras that have been streaming with high uptime for months). Could you include a quick video recording for how to install the legacy bookworm using the latest version of imager?

  25. pranshu-ui commented on Oct 8, 2025

    @pranshu-ui
    Recording.2025-10-08.163844.mp4

    The version of legacy OS was installed here:
    https://downloads.raspberrypi.com/raspios_lite_arm64/images/

  26. sgbaird commented on Oct 14, 2025

    @sgbaird
    CollaboratorAuthor

    Seems it can also be downloaded via imager

    20251014-1741-37.5379464.mp4
  27. sgbaird commented on Oct 17, 2025

    @sgbaird
    CollaboratorAuthor

    I set up a pi with trixie from scratch. There was a library rename, that I added logic for in device.py (merged to main), so should be OK now. All other installation steps were the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions