---- name="Pi Camera in 2025 (+ MotionEye)" year="2025" ---- I recently thought it could be fun to set up a mini "security camera" system in my apartment (I don't plan to actually rely on this, it's more of a fun webcam pointed outside). In any case, I happened to have a Raspberry Pi 4 (4 GiB) and a Pi Camera V2.1 lying around from some old projects, so I figured I could use those pretty easily. It sounds like, at some point prior to 2024, Raspbian switched to using libcamera instead of V4L2. Unfortunately, a bunch of guides online still reference the legacy API, so I figured I'd write a guide for people in 2025 using the libcamera API. I was clued into this change by [this forum post](https://forums.raspberrypi.com/viewtopic.php?t=362707), so thanks to the writer of that post. ### MicroSD card imaging A couple years ago the Raspberry Pi foundation released [Raspberry Pi Imager](https://www.raspberrypi.com/documentation/computers/getting-started.html#raspberry-pi-imager), which helps you set up a microSD card with Raspbian installed on it quite easily compared to before (when you needed to manually edit the `ssh` and `wpa_supplicant.conf` files to configure things properly). I installed Raspbian Lite (64-bit edition) with this tool and booted up my Pi. ### Checking connectivity You do **not** need to enable anything in `raspi-config`. `vcgencmd get_camera` is also **not** going to tell you the right thing. Instead, run `libcamera-hello --list`. With my Raspberry Pi Camera V2.1 module connected, I see this output: ``` $ libcamera-hello --list Available cameras ----------------- 0 : imx219 [3280x2464 10-bit] (/base/soc/i2c0mux/i2c@1/imx219@10) Modes: 'SBGGR10_CSI2P' : 640x480 [30.00 fps - (65535, 65535)/65535x65535 crop] 1640x1232 [30.00 fps - (65535, 65535)/65535x65535 crop] 1920x1080 [30.00 fps - (65535, 65535)/65535x65535 crop] 3280x2464 [30.00 fps - (65535, 65535)/65535x65535 crop] 'SBGGR8' : 640x480 [30.00 fps - (65535, 65535)/65535x65535 crop] 1640x1232 [30.00 fps - (65535, 65535)/65535x65535 crop] 1920x1080 [30.00 fps - (65535, 65535)/65535x65535 crop] 3280x2464 [30.00 fps - (65535, 65535)/65535x65535 crop] ``` Another thing you can try running is `libcamera-jpeg -o image.jpg` to save a jpeg of the view from the camera. ### Installing MotionEye I mostly followed [this guide](https://pimylifeup.com/raspberry-pi-security-camera/), but had to deviate slightly in order to get things working with libcamera. If you're booted into a fresh Raspbian Lite install, here are the commands I ended up running: ``` # update packages since links often break on fresh installs sudo apt update # prerequisite packages sudo apt install libcamera-tools libcamera-v4l2 python3 python3-dev python3-pip libcurl4-openssl-dev gcc libssl-dev # ideally i'd install the other non-motioneye packages via apt install python3-<>, but I was too lazy to do so. sudo python3 -m pip install --pre motioneye --break-system-packages # sets up the systemd units, etc. sudo motioneye_init # run libcamerify (from libcamera-tools), which is an adapter to present the old v4l2 API to meyectl sudo sed -i 's/ExecStart=/ExecStart=\/usr\/bin\/libcamerify /' /etc/systemd/system/motioneye.service # motioneye_init starts the motioneye daemon by default, we need to restart it to pick up the change. sudo systemctl daemon-reload sudo service motioneye restart ``` Once you navigate to port 8765 of your Pi, you should see the MotionEye interface. Default login credentials are `admin` and no password. You might see multiple options for your camera (in my case, I had many options named `/base/soc/i2c0mux/i2c@1/imx219@10`). I picked the first one and this ended up being (the virtualized) `/dev/video0`, which was correct. That's it! If you're following along at home, good luck, and hope this helped.