Turn Your Raspberry Pi into a Live Surveillance Camera with Motion
This step‑by‑step guide explains how to connect a USB webcam to a Raspberry Pi, verify the device, install and configure the Motion daemon, and stream live video to a web browser, providing a simple DIY surveillance solution.
This guide shows how to build a simple surveillance system using a Raspberry Pi and a USB webcam, allowing you to view live video from a browser on any computer.
1. Detect the Camera
The Raspberry Pi supports many USB webcams. After plugging the camera into a USB port, verify detection using one of two methods:
Method 1: Check for /dev/video0:
pi@raspberrypi:~ $ ls /dev/video*
/dev/video0Method 2: List USB devices and look for the camera entry:
pi@raspberrypi:~ $ lsusb
Bus 001 Device 004: ID 0458:7060 KYE Systems Corp. (Mouse Systems) Genius iSlim 2000AF V2 # detected USB camera
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub2. Install the Motion Package
On the official Raspbian system, install Motion with:
sudo apt-get install motionIf installation fails, first update the package lists and upgrade existing packages:
sudo apt-get update
sudo apt-get upgrade3. Enable the Motion Daemon
Edit /etc/default/motion (install vim or use nano) and change the start_motion_daemon setting from no to yes:
# set to 'yes' to enable the motion daemon
start_motion_daemon=yes4. Configure Motion
Open the main configuration file /etc/motion/motion.conf and adjust the following key options:
# Start in daemon (background) mode (default: off)
daemon on
# Restrict stream connections to localhost only (default: on)
stream_localhost off
# Image width (pixels) – default 352, set to 800
width 800
# Image height (pixels) – default 288, set to 600
height 600Save the file and exit the editor.
5. Start the Service
Start Motion as a system service and then launch it:
sudo service motion start
sudo motionThe console will display messages such as loading the configuration file and confirming that Motion 4.0 has started.
6. View the Video Stream
Open a web browser and navigate to http://<em>RaspberryPi_IP</em>:8081. The live video feed works reliably in Google Chrome; other browsers may require additional configuration.
The Raspberry Pi’s IP address can be found in the router’s admin interface or by using an IP scanner.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
