How to Make a Security Camera with Raspberry Pi

How to Make a Security Camera with Raspberry Pi

A Raspberry Pi can become a useful home camera with only a few parts. You can start with a live view on your home network, then add motion-triggered recording later. Remote viewing is possible with some software and network setups, but it needs extra care.

The simplest build is usually a Pi Zero 2, a camera module, and a microSD card of 32GB or more. An external USB webcam can work too, especially if you already have one.

The best way to build this project is to make a few decisions first. Pick the camera, prepare the software, get local viewing working, and only then think about recording or internet access.

What you need to build a Raspberry Pi security camera

Here’s the basic parts list:

  • A compatible Raspberry Pi
  • A Raspberry Pi Camera module or USB webcam
  • A microSD card, with 32GB or more being a practical starting point
  • A suitable power supply
  • A computer for preparing the microSD card
  • Wi-Fi or wired network access, depending on the Pi model and setup
  • Camera software, such as a supported MotionEyeOS image or another camera application
  • A case or mount, if you want to place the camera safely

A Pi Zero 2 is a common choice for a small, low-cost camera. It can keep the camera body compact and use less power than a larger board. A Raspberry Pi Zero can also be paired with an external webcam for a security-camera project.

The Pi itself needs enough support for the camera and software you choose. Don’t assume that every Pi model, camera module, and software image will work together. Check that the software image supports your board before you write it to the card.

You may also want:

  • A short camera cable, if the standard cable won’t reach the mounting position
  • A small case with an opening for the lens
  • A stable shelf, wall mount, or stand
  • Extra storage if you plan to keep many recordings
  • A wired network connection, where your Pi and hardware support one

A quick choice before you buy

Decide what you want the camera to do:

  1. Basic local camera: View a live feed from another device on the same home network.
  2. Raspberry Pi IP camera server: The Pi serves the camera feed through a web page or camera app on your network.
  3. Remote camera: View the camera while away from home over the internet.

Start with the first option. It is easier to test, and it keeps the camera off the public internet while you are still learning. You can add motion capture and remote access once the local feed works.

Checkpoint: You should know which Pi, camera, and software route you plan to use before assembling anything.

Choose between a Raspberry Pi camera module and an external webcam

This choice affects the shape, cost, and setup of the finished camera.

Raspberry Pi Camera module

Raspberry Pi Camera module

A camera module connects directly to the Pi’s camera connector with a ribbon cable. It is a neat choice for a small camera because the lens and board can sit away from the main Pi board.

A module makes sense if:

  • You want a small, tidy build
  • You’re starting from scratch
  • You want to mount the lens in a simple case
  • Your chosen software supports the module and Pi model

Turn the Pi off before connecting the ribbon cable. The cable must be fitted in the correct direction at both ends. The exact connector and cable can vary between Pi models, so check the board markings and the camera’s instructions rather than forcing it.

External USB webcam

A USB webcam is often easier if you already own one. Plug it into a USB port, or use the correct adapter if your Pi has a smaller USB connector.

A Pi Zero can be connected to an external webcam for a security-camera project. This can be useful when the webcam already has its own stand, microphone, or adjustable lens.

A webcam may need more power than the Pi can comfortably provide, especially if you add other USB devices. If the camera keeps disconnecting, power may be part of the problem.

The webcam also takes up a USB port and may make the finished setup larger. That trade-off is often worth it for a quick test.

Checkpoint: Confirm that your chosen camera is supported by the software image you plan to use. Connect the camera only while the Pi is powered off.

Flash the software and prepare the microSD card

The microSD card holds the operating system and camera software. This is the card the Pi starts from.

A simple route is to use Raspberry Pi Imager, often called Pi Imager. It writes the selected software to the card and prepares it for the Pi.

The general process is:

  1. Insert the microSD card into your computer.
  2. Open Pi Imager.
  3. Select the Raspberry Pi model, if the program asks for it.
  4. Choose a camera software image that supports your board.
  5. Select the microSD card carefully.
  6. Write the image to the card.
  7. Wait for the writing and checking process to finish.
  8. Safely eject the card.

MotionEyeOS is one software option used in Raspberry Pi security-camera projects. It provides camera controls and a browser-based way to manage features such as live viewing and motion capture. Support can vary by Pi model and image, so check compatibility before choosing it.

Some other camera software options may use a regular Raspberry Pi operating system with a camera application installed on top. The exact menus will differ. The main idea stays the same: the card needs software that can read your camera, connect to your network, show a live feed, and record when needed.

Do not remove the card while Pi Imager is writing. A damaged image can look like a camera fault later.

You may be able to set network details during imaging, depending on the software and Pi Imager version. If you do, enter the Wi-Fi name and password carefully. If the software does not offer this step, you can configure the network after the Pi starts.

Checkpoint: The card should finish writing without an error. Keep the software name and version in mind, since the next setup screens depend on it.

Connect the Raspberry Pi camera to your network

Insert the prepared microSD card into the Pi. Connect the camera, then connect power.

Give the Pi time to start. The first boot can take longer than later boots, particularly when the software is preparing its files.

Your goal is to place the Pi and the device you’ll use as a viewer on the same home network. That might be:

  • Your home Wi-Fi
  • A wired network
  • A router with both devices connected to the same local network

The exact connection depends on the Pi model and hardware. A small Pi with wireless network support may connect over Wi-Fi. Another setup may need an adapter or wired connection.

Once the camera software starts, find the Pi’s local network address. Some software shows it on a setup screen. You may also find it in your router’s connected-device list. The address is used by another device on the same network to reach the camera.

Enter that local address into a browser on a phone, tablet, or computer connected to the same network. If the software uses a named local address instead, follow its own setup instructions.

You should see a login page, setup page, or camera dashboard. Change any default password before you leave the camera running.

Keep the first test local

At this point, don’t try to view the camera from a mobile connection away from home. First check that it works inside the house.

Look for:

  • A live image
  • A camera name or device status
  • Settings for video size or quality
  • A place to set recording or motion options
  • A clear sign that the camera is connected

Checkpoint: You should be able to open the camera from a browser or viewer device on your home network. If you can’t, solve that now before adding other features.

Configure the camera and live viewer

Open the camera software’s settings and choose a sensible starting video setup.

You may see options for:

  • Video size
  • Frame rate
  • Image brightness
  • Contrast
  • Orientation or rotation
  • The name shown for the camera
  • Stream settings
  • Storage location

Start with a moderate setting rather than choosing the highest available quality. A larger video feed uses more network capacity and creates larger recordings. The right setting depends on your Pi, camera, network, and chosen software.

Some Raspberry Pi surveillance projects record HD video when movement is detected. Other builds can support higher resolutions, and one described setup reaches 4K while costing under $50. That doesn’t mean every Pi can record 4K smoothly. Treat the advertised resolution as a property of a particular parts-and-software combination, not a promise for every build.

Place the camera where you can test the picture. Aim it at a doorway, cot, hallway, or another area you need to check. Avoid pointing it at a bright window, since strong backlight can make people appear dark.

If the image is upside down, use the software’s rotation option if one is available. If the image is blank, check the camera connection and compatibility before changing lots of settings.

A Raspberry Pi security camera viewer may simply be a browser page on a phone or computer. That’s enough for a local camera. You don’t need a separate display connected to the Pi.

Checkpoint: Watch the live feed for a few minutes. Make sure it stays connected and that the view covers the area you actually want to monitor.

Add motion detection and video recording

Motion capture tells the camera to start saving video when the picture changes. This is useful when you don’t want to store hours of footage showing an empty room.

Camera software may call this feature motion detection, motion capture, or motion-triggered recording. The names vary, but the basic setup is similar.

You’ll usually need to choose:

  • Whether motion detection is on
  • Where recordings will be saved
  • How sensitive the camera should be
  • How long a clip should run
  • Whether the camera should record before or after movement, if that option exists
  • When motion detection should be active

Start with a short test. Walk through the camera’s view and check that a recording appears. Then stand still for a while and see whether the camera keeps recording unnecessarily.

A camera aimed at a busy road, moving curtains, or a television may create many false alerts. You can often reduce this by changing the camera angle, lowering sensitivity, or limiting the area where motion is checked.

Storage matters here. Video files use much more space than still images, and higher-quality video creates larger files. A 32GB card can be enough for a basic build, but the useful recording time depends on the video settings and how often motion occurs.

Don’t treat motion recording as proof that every event will be captured. A camera can miss movement if it loses power, disconnects from the network, fills its storage, or fails to detect a particular change in the scene.

Checkpoint: Trigger the camera yourself. Confirm that the clip is saved, can be played back, and is stored where you expect.

Set up remote viewing safely

Remote viewing means opening the camera while you’re away from home. This is different from local viewing. A camera that works inside your house does not automatically become safe or available over the internet.

Before enabling remote access, stop at this security check:

> Do not expose the camera’s login page directly to the public internet until you understand how the chosen software and router settings protect it. Change default passwords, keep the software updated where updates are available, and avoid sharing the camera address or login.

A camera may show private areas of your home. It may also contain recordings of children, carers, visitors, or family members. Convenience is not a good reason to leave an unsecured feed open.

Remote access depends on the Pi model, camera software, router, and network provider. Some setups use a secure connection back to the home network. Others use a service or app supported by the software. The exact steps are different, so use the method documented for your chosen software.

Before you turn remote viewing on:

  • Change every default username or password.
  • Use a long password that you don’t reuse elsewhere.
  • Check whether the software has separate viewer and administrator accounts.
  • Keep the camera on a trusted home network.
  • Update the Pi and camera software when supported updates are available.
  • Review where recordings are saved and who can open them.
  • Test remote access with a device using mobile data, not your home Wi-Fi.

Avoid random port-forwarding instructions copied from an unrelated camera project. A setting that works for one software package may leave another exposed.

If you only need to check the camera while at home, keep it local. A local Raspberry Pi IP camera server is often enough for a nursery, hallway, workshop, or pet area. There’s no need to add internet access just because the option exists.

This DIY setup also shouldn’t replace a professionally installed security system where you need monitored alarms, certified equipment, or reliable coverage during a serious security risk.

Checkpoint: Remote viewing should remain off until the account, update, and network settings are secured. If you’re unsure, use the local viewer instead.

Troubleshoot common setup problems

The Pi starts, but the camera image is blank

Power off the Pi and reseat the camera cable. Check that the cable is facing the right way and is fully inserted.

For a USB webcam, check the adapter and USB connection. If possible, test the webcam on another computer. Also confirm that the software image supports that type of camera.

The Pi doesn’t appear on the network

Check the Wi-Fi name and password. Make sure the Pi is connecting to the same home network as your phone or computer.

If you can access the router’s device list, look for a new device. A wired connection can help you separate a Wi-Fi problem from a camera problem, when your Pi supports it.

The live feed keeps stopping

The Pi may be struggling with the selected video settings, the network may be weak, or the power supply may be unstable. Lower the video quality for testing and remove unnecessary USB devices.

A webcam connected to a small Pi can also create extra power demand.

Motion recording creates too many clips

Move the camera away from windows, televisions, fans, and busy walkways. Then adjust motion sensitivity or the monitored area if your software provides those controls.

Recordings fill the card

Recordings fill the card

Use shorter clips or lower video quality if those settings are available. Review old recordings and set a sensible storage policy. Keep in mind that a card filled with video may stop new recordings from being saved.

Ways to use the finished Raspberry Pi security camera system

Once the local camera is stable, you can use it in several simple ways:

  • Check a sleeping child from another room
  • Watch a hallway or entrance while you’re at home
  • Monitor a pet area
  • Keep an eye on a workshop or storage space
  • Record movement in a room when you’re away
  • Use more than one camera if the software supports multiple feeds

For a parent or carer, a local camera may be the most sensible first version. It gives you a live view without creating an internet-access problem. Motion capture can then reduce the need to watch the feed constantly.

You can use a Pi Zero 2, camera module, and 32GB-or-larger card for a compact starting point. Choose an external webcam if you already have one or want a simpler USB connection. Pick software that clearly supports your board and camera, then build in stages:

  1. Get the camera image working.
  2. View it on the home network.
  3. Add motion-triggered recording.
  4. Test saved clips.
  5. Decide if remote access is truly needed.
  6. Secure the system before enabling it.

Compare the parts you already have with the simplest compatible setup for your home. A small local camera may do everything you need, and it gives you a safer place to start.

DH

Written by Dennis Haymon

Dennis Haymon is a security professional and manager at Safe & Sound Security LLC. With experience in security guard and patrol services, he shares practical information about protecting homes, businesses, and properties. Through Safe & Sound Security LLC, Dennis and the team provide security-focused guidance designed to help individuals and businesses better understand their security needs and available protection options.