Set up a Raspberry Pi as a security camera

Raspberry Pi Security Camera with motionEye: Setup Guide (2026)

A Raspberry Pi security camera with Wi-Fi is quick to build: live view in the browser, motion detection, recordings and a message on your phone when something happens. The software for this is called motionEye. This guide shows how to install motionEye on current Raspberry Pi OS, add a camera module or a USB webcam and set up motion detection. We also explain why the once popular MotionEyeOS is no longer the right choice and when Frigate is the better option.

In short

For a security camera with a web interface, install motionEye on Raspberry Pi OS and stop using MotionEyeOS.

  • You need: a Raspberry Pi from the Zero 2 W upwards and a camera module or a USB webcam.
  • Good to know: motionEye is installed with pip, which means lifting a block in Raspberry Pi OS. A camera module on the ribbon cable also needs the extra step libcamerify.
  • Alternative: If you want to tell people, cars and animals apart and have a Pi 4 or Pi 5, use Frigate.

Which solution fits you?

There are three sensible ways to run a camera on a Raspberry Pi today, plus MotionEyeOS for comparison:

SoftwarePi Zero 2 WPi 4 / Pi 5Actively developedGood for
motionEyeYesYesYesLive view, motion detection, recordings and notifications through a web interface
rpicam-vid streamYesYesYes (part of Raspberry Pi OS)Plain live view without recordings or motion detection
FrigateNot recommendedYesYesAI object detection (people, cars, animals), tight Home Assistant integration
MotionEyeOSNoPi 4 onlyNo, last stable release in June 2020No longer recommended

MotionEyeOS used to be the most convenient option: a ready-made operating system image with motionEye built in. Its last stable release dates from June 2020, though. It knows neither the Camera Module 3 nor current Raspberry Pi models and no longer receives security updates. motionEye itself, the web interface, is still being developed and runs as a normal program on Raspberry Pi OS. That is the route this guide follows.

Our recommendation: motionEye is the right choice for most people. If you only need a live view or are looking for AI object detection with Frigate, jump to the alternatives to motionEye further down.

What you need

  • Raspberry Pi: For a compact camera, the Raspberry Pi Zero 2 W*. An existing Pi 3, Pi 4 or Pi 5 works just as well. We no longer recommend the old Pi Zero W: it has a single core and can’t run 64-bit, and on current 32-bit Raspberry Pi OS you can’t add a camera module to motionEye directly for now.
    Links marked with * are affiliate links, which makes them advertising. If you buy through one, I earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases. Learn more
  • Camera: the Raspberry Pi Camera Module 3* with autofocus. For night shots with an infrared illuminator, the Camera Module 3 NoIR*. Alternatively a USB webcam such as the Logitech C270*, which works without the extra step. Our Raspberry Pi camera comparison shows which module suits which project.
  • Case: The official Pi Zero case* has a lid with a camera opening, and the short camera cable for the Zero is included. The holder in the camera lid is designed for the Camera Module 2, though: according to Raspberry Pi, the Camera Module 3 doesn’t fit because of the size and position of its sensor module. If you want the Zero in the official case, go for the Camera Module 2*.
  • microSD card: A security camera writes constantly. A card built for continuous recording such as the SanDisk High Endurance 32 GB* lasts longer than a standard card.
  • Power supply: The Zero 2 W needs a micro-USB power supply with 5 V and at least 2.5 A, for example the official Raspberry Pi micro-USB power supply*. A Pi 4 or Pi 5 runs on its usual USB-C power supply. For a camera module on the Pi 5 you also need a Pi 5 camera cable* (22 to 15 pin), which is not included with the Camera Module 3.

Assembling the hardware (Pi Zero 2 W)

With the official Zero case you don’t need any tools:

  1. Swap the camera module’s long ribbon cable for the short Zero cable from the case. Gently pull open the clip on the camera module, change the cable and close the clip.
  2. Press the Camera Module 2 into the holder in the lid with the round opening (the Camera Module 3 doesn’t fit there, see above).
  3. Plug the other end of the cable into the Pi Zero’s camera connector: open the clip, insert the cable with the contacts facing the board, close the clip.
  4. Place the Pi in the case base and fit the lid. You’ll flash the microSD card in the next step and insert it afterwards.

On a Pi 3 or Pi 4, plug the standard camera cable into the connector labelled CAMERA. The Pi 5 has the same narrow 22-pin connectors as the Zero and needs a matching 22-to-15-pin cable. A USB webcam plugs into any USB port.

White official Pi Zero case with the camera module in the lid
The Pi Zero in the official case: the camera module sits in the lid with the round opening.

Step 1: Install Raspberry Pi OS Lite

Flash the microSD card with Raspberry Pi Imager. Choose your model as the device and, as the operating system, Raspberry Pi OS Lite under Raspberry Pi OS (other). The camera doesn’t need a desktop, and without one more memory is left for motionEye. For the Zero 2 W and all larger models, pick the 64-bit version. Only the old Pi Zero W is limited to 32-bit, and on 32-bit the extra step for camera modules currently doesn’t work (more on this under “Camera module shows no picture”).

In Imager’s customisation step, set the hostname, user and password as well as your Wi-Fi, and enable SSH. The Pi then joins your Wi-Fi on first boot and you can connect via SSH without a monitor.

Step 2: Install motionEye

Connect to the Pi via SSH. Paste the commands in this guide one box at a time and check for error messages after each one. Start by bringing the system up to date and installing Python and pip:

sudo apt update && sudo apt full-upgrade -y
sudo apt install --no-install-recommends python3 python3-pip -y

motionEye is not in the Raspberry Pi OS repositories, it is installed with pip. Since Debian 12, and therefore also in current Raspberry Pi OS, the system blocks installs that bypass the package manager: sudo pip3 install motioneye fails with externally-managed-environment. The motionEye developers therefore recommend lifting this block for pip in their installation guide for the current version 0.44.0. From the upcoming version 0.45, they describe installing it into its own Python virtual environment instead, but for 0.44.0 the steps below apply. motionEye has only a few dependencies without strict versions, so conflicts with apt packages are very unlikely according to the developers. These two lines add a single entry to /etc/pip.conf that lets pip install it. Running them a second time does no harm:

grep -q '\[global\]' /etc/pip.conf 2>/dev/null || printf '%b' '[global]\n' | sudo tee -a /etc/pip.conf >/dev/null
sudo sed -i -e '/^break-system-packages/d' -e '/^\[global\]/a\break-system-packages=true' /etc/pip.conf

Now install and set up motionEye. motioneye_init also installs Motion and ffmpeg, creates the configuration in /etc/motioneye and starts motionEye as a service that comes back after a reboot:

sudo python3 -m pip install motioneye
sudo motioneye_init

If you use a Pi Zero W or another 32-bit system anyway, pip may have to compile some modules itself. If the install stops at Pillow or PycURL, install these packages and run the pip command again:

sudo apt install --no-install-recommends python3-dev gcc libjpeg62-turbo-dev libcurl4-openssl-dev libssl-dev libffi-dev -y

Then check that motionEye is running and look up the Pi’s IP address:

systemctl is-active motioneye
hostname -I

The first command should print active. If it prints anything else, sudo journalctl -u motioneye -n 30 shows the service’s most recent log messages. The second command prints the IP address, usually something like 192.168.1.23 on a home network. You can then reach the web interface in your browser at http://Pi-IP-address:8765 or via the hostname you set in Imager, for example http://raspberrypi.local:8765.

Step 3: Log in and set a password

On first access, log in with the user admin and an empty password. Since version 0.44.0, motionEye then asks for a password straight away: the message Please set a password for your account. appears, and once you confirm it, the settings open. Under General Settings, set three things:

  • Under Admin Username, enter your own Password for the administrator.
  • Below it is the view-only user (Surveillance Username, user by default). It can watch the live view but can’t change anything. If someone should only watch, give this user a Password as well. Without one, this user can’t log in.
  • If you prefer another interface language, pick it under Language.

Click Apply to save. motionEye shows Admin password updated. Please log in again., and you log back in with the new password.

Step 4: Add the camera

A USB webcam works directly, a camera module on the ribbon cable needs an extra step.

USB webcam

A USB webcam can be added in motionEye right away: in the camera selector at the top, choose add camera …, set the camera type to Local V4L2 Camera and pick your webcam from the list. After saving, the camera tile shows the live view.

Camera module on the ribbon cable

First check that Raspberry Pi OS detects the module:

rpicam-hello --list-cameras

Your module should be listed under Available cameras, the Camera Module 3 with the sensor imx708. If the command reports No cameras available, the ribbon cable isn’t seated properly: power off the Pi, open the clips at both ends, push the cable in straight (contacts facing the board) and close the clips.

In motionEye, the module does show up in the list of V4L2 cameras but only returns “Unable to open video device”. Motion, the program underneath motionEye, talks to cameras through the old V4L2 interface, while Raspberry Pi OS drives camera modules through libcamera, and motionEye has no direct support for it yet. The maintainer recommends libcamerify as a bridge, placed in front of the motionEye service:

sudo apt install libcamera-v4l2 libcamera-tools -y
sudo sed -i 's|^ExecStart=|ExecStart=/usr/bin/libcamerify |' /etc/systemd/system/motioneye.service
sudo systemctl daemon-reload
sudo systemctl restart motioneye

If you already added the module and it only shows the error, remove that entry first: select the camera in the camera selector at the top and click remove camera. Then add the module again like a USB camera via add camera … and Local V4L2 Camera. If the list shows several entries, pick the first one. If the tile shows no live view, remove the camera again and try the next entry. As soon as the live view appears, the camera is set up.

Step 5: Motion detection, recordings and notifications

Without motion detection, motionEye only shows the live view. You switch on the actual surveillance in the camera settings: open the settings with the button on the far left. Below General Settings you’ll find the sections for the camera selected at the top.

  1. Enable the Motion Detection section. The Frame Change Threshold sets how much of the image, in percent, has to change before motionEye reports motion. Lower values catch smaller movements but also trigger more often on changing light or shadows.
  2. A Mask excludes parts of the image from detection, such as a tree in the wind or the street in the background. Enable the mask, set Mask Type to Editable, click Edit Mask and mark the areas in the live view that motionEye should ignore. Save Mask applies it.
  3. Under Movies and Still Images you decide whether motionEye saves videos or photos on motion. With Preserve Movies and Preserve Pictures, motionEye deletes old recordings automatically so the microSD card doesn’t fill up.
  4. Under Motion Notifications you set up a message for each motion event: by email (you’ll need your mail provider’s SMTP details), as a Telegram message on your phone or through a webhook, for example to Home Assistant. Test Email checks the settings straight away. For Telegram, create your own bot in the Telegram app via the @BotFather contact and enter its HTTP API token and your Chat ID.

Click Apply after every change, otherwise motionEye discards the settings. To test, walk through the picture once: shortly afterwards a recording should be saved and the notification should arrive. If nothing happens, lower the threshold a little.

What you’re allowed to record

The rules for private surveillance cameras differ from country to country. In the EU, data protection law applies as soon as a camera records even part of a public space such as a pavement or street. In Germany, a private camera may generally only cover your own property, so pavements, streets and neighbouring properties are off limits there, even if only a strip of them is in view. If the camera covers areas that visitors, delivery drivers or housemates enter, you usually have to tell them, for example with a sign. Point the camera so that only your own space is in view and exclude edge areas with a mask. This is not legal advice, so check the rules where you live.

Accessing the camera remotely

Out of the box, motionEye is only reachable on your home network. There are three ways to access it remotely:

  • Easiest: Tailscale, covered in Secure your Raspberry Pi. You don’t have to change anything on your router, and it also works on connections without a public IPv4 address of their own.
  • Full control: your own WireGuard VPN server.
  • Classic: port forwarding. It exposes the camera directly to the internet. motionEye has no HTTPS of its own, so put a reverse proxy with HTTPS and a strong password in front of it.

We recommend Tailscale or WireGuard because no port is left open on your router.

Updating motionEye

New motionEye versions are installed with pip as well. If you’re still on a version older than 0.44.0, update now: version 0.44.0 fixes five security vulnerabilities. The interface shows the running version under motionEye Version in General Settings. Via SSH, you can check it like this:

python3 -m pip show motioneye

The Version line should read 0.44.0 or later. For the update, the developers recommend stopping the service briefly:

sudo systemctl stop motioneye
sudo python3 -m pip install --upgrade motioneye
sudo systemctl start motioneye

Your existing password keeps working after the update. If you never set one, motionEye now asks for it at login, as in Step 3. If you add cameras from another motionEye server (Remote motionEye Camera), both servers need 0.44.0. On the first login, motionEye then asks for the other server’s key, which you’ll find there in General Settings under Client Secret.

Everything else stays up to date as usual with sudo apt update && sudo apt full-upgrade.

Troubleshooting

Forgot the password

Connect via SSH and open the file in which motionEye stores the credentials:

sudo nano /etc/motioneye/motion.conf

Find the line that starts with # @admin_password (in nano, press Ctrl+W, type admin_password and press Enter) and delete the value after # @admin_password on that line. Press Ctrl+O and Enter to save, then Ctrl+X to exit nano. After restarting motionEye, log in as admin with an empty password. motionEye then asks for a new password right away, just like on first login:

sudo systemctl restart motioneye

Interface not reachable

If the interface can’t be reached after the Pi restarts, it has usually received a new IP address. Reserve a fixed address for it in your router or use the hostname with .local, which works without a fixed IP.

Camera module shows no picture

If a camera module’s tile stays black even with libcamerify, update the system first so that libcamera and libcamerify are up to date:

sudo apt update && sudo apt full-upgrade -y
sudo systemctl restart motioneye

Then check that libcamerify sits in front of motionEye: in the output of systemctl cat motioneye, the line has to start with ExecStart=/usr/bin/libcamerify.

On a 32-bit system, neither helps: with current Raspberry Pi OS, libcamerify only works on the 64-bit version for now. The bug is known but not fixed yet (discussion on the motionEye tracker). On a Pi Zero 2 W, Pi 3, Pi 4 or Pi 5, reflash the card with the 64-bit image. On the old Pi Zero W, which is limited to 32-bit, the only camera you can currently add to motionEye directly is a USB webcam, connected through a micro-USB OTG adapter.

Alternatives to motionEye

Live view without extra software

If you only want to check the picture now and then, you don’t need a web interface. For a camera module, Raspberry Pi OS includes everything for a livestream with rpicam-vid:

rpicam-vid -t 0 -n --codec libav --libav-format mpegts -o 'tcp://0.0.0.0:8888?listen=1'

If motionEye is using the same camera module, stop it first with sudo systemctl stop motioneye, otherwise the camera is busy. The command wraps the camera image as H.264 video in an MPEG-2 transport stream and serves it over TCP. You need the quotes around the address because of the question mark. Open the stream in VLC via Media → Open Network Stream with the address tcp://Pi-IP-address:8888. A browser cannot play this stream, and there are no recordings or motion detection this way.

Frigate: AI object detection

motionEye detects changes in the image but can’t tell whether a cat, a car or a person walked through it. Frigate can: it recognises objects with AI, works closely with Home Assistant and runs as a Docker container. We recommend at least a Pi 4, ideally a Pi 5 with an AI accelerator. With only 512 MB of RAM, the Zero 2 W isn’t a machine we’d recommend for Frigate. Our guide Raspberry Pi AI Kit with Frigate shows how to set it up on the Pi 5.

Frequently asked questions about motionEye

Does motionEye run on the Raspberry Pi 5?

Yes. motionEye runs on every Raspberry Pi with current Raspberry Pi OS, from the Zero 2 W to the Pi 5. A USB webcam works directly, a camera module on the ribbon cable needs the extra step libcamerify.

Why doesn’t motionEye find my camera module?

Raspberry Pi OS drives camera modules through libcamera, while motionEye expects a V4L2 camera, so it reports “Unable to open video device”. With libcamerify in front of the motionEye service, you can add the camera module like a USB camera.

Can I still use MotionEyeOS?

We advise against it. The last stable MotionEyeOS release dates from June 2020, it supports neither the Camera Module 3 nor current models and receives no security updates. motionEye on Raspberry Pi OS offers the same interface and is still being developed.

motionEye or Frigate – which is better?

motionEye is enough for live view, motion detection and recordings and already runs on the Pi Zero 2 W. Frigate additionally uses AI to detect whether people, cars or animals are in view, but we recommend a Pi 4 or Pi 5 for it, ideally with an AI accelerator.

Does the camera work at night?

Not with the standard Camera Module 3. For night shots you need the Camera Module 3 NoIR without an infrared filter and an infrared illuminator that lights the scene.

Conclusion

With motionEye on Raspberry Pi OS, a Pi Zero 2 W and a camera module become a full Wi-Fi security camera with a web interface, recordings and notifications. Installing via pip and the extra step for camera modules take a few more commands than the old ready-made MotionEyeOS, but in return you get a system with current security updates. If you need more than motion detection, move to Frigate on a Pi 4 or Pi 5.

Similar Posts