Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Raspberry Pi Surveillance Camera: Setup & Guide

· 8 min read · Home Security

In this article
  1. Why Use a Raspberry Pi for Surveillance
  2. Hardware You Will Need
  3. How It Works: Software and Streaming
  4. Step-by-Step Setup with Motion
  5. Common Problems and How to Fix Them
  6. Cost and Power Consumption
  7. Alternatives to a Raspberry Pi Camera
  8. Frequently Asked Questions

Yes, a Raspberry Pi can be built into a fully functional surveillance camera for indoor or outdoor monitoring. You can use it to stream live video, record motion-triggered clips to an SD card or network drive, and view the feed from any browser on your local network. This guide covers the hardware, software, and setup steps, plus common pitfalls and alternatives.

Why Use a Raspberry Pi for Surveillance

A Raspberry Pi is a low-cost, credit-card-sized computer that runs a full Linux operating system. For surveillance, its main advantages are price, flexibility, and low power consumption. A basic Pi Zero 2 W or Pi 4 can run continuously for weeks on a 5V power supply, drawing far less electricity than a typical desktop PC. You also control the software completely, so there are no monthly fees or cloud dependencies if you keep everything on your local network.

The main trade-off is that a Pi is not a dedicated security camera. It requires some initial configuration, and the image quality depends heavily on the camera module you attach. For a simple indoor pet monitor or a weekend project, a Pi is excellent. For a serious, always-on security system with night vision and rugged weatherproofing, a commercial IP camera is often more reliable.

Hardware You Will Need

To build a Raspberry Pi surveillance camera, you need these core components:

  • Raspberry Pi board – A Pi 3, Pi 4, or Pi Zero 2 W are all good choices. The Pi 5 also works but is overkill for basic video.
  • Camera module – The official Raspberry Pi Camera Module 3 (12MP) or the older Camera Module 2 (8MP) are the most common. For low-light, the Camera Module 3 NoIR (no infrared filter) works with an IR illuminator.
  • MicroSD card – At least 16GB, Class 10 or A1 rated for reliable writes. 32GB is a comfortable minimum if you record continuously.
  • Power supply – A 5V/2.5A USB-C or micro-USB supply (depending on the Pi model) that is stable. Avoid cheap phone chargers that can cause undervoltage warnings.
  • Case and mount – A simple plastic case with a camera slot, or a weatherproof enclosure if placing outdoors. A small tripod or zip ties work for mounting.
  • Optional – A passive heatsink for the Pi 4/5, and an Ethernet cable if you want a wired network connection.

If you already have a Pi and a camera module, the total cost is just the SD card and power supply. If buying new, expect to spend roughly $60–$100 for a Pi 4, camera, and accessories.

How It Works: Software and Streaming

The most common software stack for a Pi surveillance camera is Raspberry Pi OS (the official Linux distribution) with a program called Motion or MotionEyeOS. Here is the basic flow:

  1. The camera module captures raw video frames, typically at 1080p or 720p resolution.
  2. The software (Motion, for example) encodes those frames into a video stream using the Pi's hardware encoder, which keeps CPU usage low.
  3. The stream is served over HTTP on a local port (e.g., http://pi-ip:8081). You can open this in a web browser to watch live.
  4. Motion detection compares consecutive frames; when a difference exceeds a threshold, it saves a short video clip or a still image to a specified folder.
  5. You can optionally upload clips to a network share (NAS) or cloud service via scripts.

MotionEyeOS is a dedicated operating system that turns a Pi into a ready-made camera with a web-based interface. It is easier for beginners because you do not need to type commands. However, it is based on an older version of Raspberry Pi OS, so support for the newest Pi models (like Pi 5) may be limited. For maximum control, install Raspberry Pi OS and configure Motion manually.

Step-by-Step Setup with Motion

Here is a typical setup using Raspberry Pi OS and Motion. This assumes you have flashed the OS to your SD card and booted the Pi with a monitor or via SSH.

  1. Update the system: Run sudo apt update && sudo apt upgrade to get the latest packages.
  2. Enable the camera interface: In Raspberry Pi OS (Bookworm or later), run sudo raspi-config, go to Interface Options, and enable the camera. Reboot if prompted.
  3. Install Motion: Run sudo apt install motion. This installs the Motion daemon.
  4. Configure Motion: Edit the configuration file with sudo nano /etc/motion/motion.conf. Key settings to change:
    • daemon on – run in the background.
    • width 1280 and height 720 – resolution (lower for faster processing).
    • framerate 15 – frames per second.
    • stream_port 8081 – the port for live viewing.
    • stream_localhost off – allow access from other devices on your network.
    • target_dir /home/pi/motion – where clips are saved.
  5. Start Motion: Run sudo systemctl start motion and enable it to start at boot with sudo systemctl enable motion.
  6. Access the stream: Open a browser on another device and go to http://<pi-ip-address>:8081. You should see the live video.

If you want remote access from outside your home, you would need to set up port forwarding on your router or use a VPN. Doing this exposes your camera to the internet, so it is critical to change the default password and use a secure connection (HTTPS). For most home users, keeping the camera on the local network is safer.

Common Problems and How to Fix Them

Several issues are common when setting up a Pi camera:

  • No video or black screen: The camera ribbon cable may be loose or incorrectly inserted. Check that the metal contacts face the correct direction (toward the HDMI port on most Pi models). Also ensure the camera is enabled in raspi-config.
  • Undervoltage warning (lightning bolt icon): The power supply is not providing enough current. Use an official Pi power supply or a high-quality 5V/3A adapter.
  • Motion is slow or laggy: Reduce the resolution or framerate. Also, the Pi 4 is much faster than the Pi Zero for motion detection.
  • Motion detection false positives: Adjust the threshold and noise_level settings in motion.conf. A higher threshold requires a larger change in the image to trigger a recording.
  • SD card corruption after power loss: Use a high-quality card and consider setting up a read-only filesystem or storing recordings on a USB drive or network share.

Cost and Power Consumption

The cost of a Pi surveillance camera varies by model and accessories. A rough breakdown for a Pi 4 (2GB) setup:

  • Raspberry Pi 4 board: $35–$45
  • Camera Module 3: $25–$30
  • 32GB microSD card: $8–$12
  • Power supply and case: $15–$20

Total: about $85–$110. A Pi Zero 2 W setup can be as low as $50 total. In terms of power, a Pi 4 under load draws about 5–7 watts; a Pi Zero 2 W draws about 1–2 watts. Running a Pi 4 24/7 for a year costs roughly $5–$10 in electricity, depending on your electricity rate.

Alternatives to a Raspberry Pi Camera

If you are not set on a Pi, here are common alternatives:

  • Commercial IP cameras – Brands like Wyze, Reolink, or Amcrest offer plug-and-play cameras with night vision, cloud storage, and mobile apps. They are often cheaper than a Pi setup and require no technical knowledge.
  • Old smartphone – An old Android phone can be turned into a camera using apps like IP Webcam. It is free if you already have the phone, and the camera quality is often better than a Pi module.
  • USB webcam on a PC – If you have a spare laptop, you can use software like OBS or iSpy to record. This is not as low-power as a Pi but requires no extra hardware.
  • ESP32-CAM – A tiny microcontroller with a camera for under $10. It can stream video but lacks the processing power for advanced motion detection or long recordings.

The best choice depends on your budget, technical comfort, and whether you want a project or a reliable security tool.

Frequently Asked Questions

Can a Raspberry Pi record 24/7?

Yes, a Pi can record continuously to an SD card or USB drive. However, continuous writing will wear out the SD card over time (months to a year). For 24/7 recording, use a high-endurance microSD card or store video on an external SSD or network drive.

Does a Raspberry Pi camera need the internet?

No, it works entirely on your local network. You can view the stream from any device connected to the same router. Internet is only needed if you want remote access from outside your home or to upload clips to a cloud service.

Can I use a Raspberry Pi as a night vision camera?

Yes, but you need the NoIR (No Infrared) version of the camera module, which lacks the infrared filter. You also need an IR illuminator (a ring of IR LEDs) to light the scene in darkness. The Pi's own IR LED on some modules is not powerful enough for more than a few feet.

How long does a Raspberry Pi camera last?

With proper cooling and a stable power supply, a Pi can run for years. The main wear item is the SD card, which may need replacing after a year or two of heavy writes. The camera module itself has no moving parts and typically lasts many years.

Is a Raspberry Pi camera secure?

It can be, but only if you take precautions. By default, Motion has no authentication. You must set a password in the config file, avoid exposing the stream to the internet without a VPN, and keep the OS updated. On a local network behind a firewall, the risk is low.

Can I view the camera on my phone?

Yes. Any phone with a web browser can open the stream URL (e.g., http://pi-ip:8081). For a more app-like experience, you can use a VNC viewer to see the Pi's desktop, or set up a simple web page that embeds the stream.