A lightweight web-based camera viewer for Raspberry Pi. This implementation uses a bash script to capture images from the Raspberry Pi camera module and serves them via a simple HTTP server.
Perfect for home monitoring: If you live in a multi-room or multi-floor house/apartment and want to keep an eye on pets, children, or elderly family members in different rooms, this project offers a simple solution. Just place a Raspberry Pi with a camera module in any room you want to monitor, run this software, and you can check in from any device on your home network. It's an affordable, privacy-focused alternative to commercial monitoring cameras - ideal for watching sleeping babies, pets while you're in another room, or checking if your 3D printer has finished its job.
- Prerequisites
- Installation
- Usage
- Configuration
- Files
- How it Works
- Troubleshooting
- Automatic Startup with Crontab
- License
- Raspberry Pi (any model) with Raspberry Pi OS installed
- Raspberry Pi Camera Module connected and enabled
- Python 3 installed (comes pre-installed with Raspberry Pi OS)
- ImageMagick for image rotation (
convertcommand)
-
Clone this repository or download the files to your Raspberry Pi
-
Install required dependencies:
sudo apt-get update sudo apt-get install -y imagemagick
-
Make the scripts executable:
chmod +x capture.sh server.sh start_camera_server.sh
The easiest way to start everything is to use the provided startup script:
./start_camera_server.shThis will:
- Start the camera capture process
- Start the web server
- Display the URL where you can view the camera feed
Once the server is running, you can access the camera feed by opening a web browser and navigating to:
http://[YOUR_PI_IP_ADDRESS]:8080
The page will automatically refresh with a new image every few seconds.
To stop both the camera capture and web server, press Ctrl+C in the terminal where you started the
start_camera_server.sh script.
You can modify the following settings in the capture.sh file:
QUALITY: JPEG image quality (1-100, higher is better quality but larger file size)WIDTH: Image width in pixelsHEIGHT: Image height in pixelsROTATION: Image rotation in degrees (set to 0 to disable rotation)
capture.sh: Script that captures images from the cameraserver.sh: Script that starts a simple HTTP serverstart_camera_server.sh: Script that starts both the camera capture and web serverindex.html: Web page that displays the camera feedweb_assets/styles.css: Stylesheet for the web pageweb_assets/camera.js: JavaScript code for updating the camera feed
The Raspberry Pi Camera Server uses a simple but effective architecture:
- A camera capture script continuously takes pictures using the Raspberry Pi camera module
- A web server makes these images available over your local network
- A web page automatically refreshes to show the latest image
The system is designed to be lightweight and reliable, using minimal resources while providing near real-time monitoring.
For a detailed explanation of the system architecture with diagrams, see the ARCHITECTURE.md document.
-
Make sure the camera is properly connected
-
Ensure the camera is enabled in
raspi-config:sudo raspi-config
Navigate to "Interface Options" > "Camera" and enable it
-
Check the camera logs:
cat camera.log
- Make sure port 8080 is not already in use
- Check the server logs:
cat server.log
You can configure the camera server to start automatically when your Raspberry Pi boots up by using crontab:
-
Open the crontab editor:
crontab -e
-
Add the following line to run the camera server at boot:
@reboot cd /path/to/RpiCamera/simple && ./start_camera_server.sh >> /home/pi/camera_startup.log 2>&1Replace
/path/to/RpiCamera/simplewith the actual path to the directory containing the scripts.Note: Even though the script will detect its own directory, explicitly changing to the directory in the crontab entry is recommended for clarity and as a best practice.
-
Save and exit the editor (in nano, press Ctrl+O, then Enter, then Ctrl+X)
-
Reboot your Raspberry Pi to test the automatic startup:
sudo reboot
-
After the Pi reboots, you can check if the camera server is running:
ps aux | grep capture.shYou should see the capture.sh process in the list.
-
You can also check the startup log for any errors:
cat /home/pi/camera_startup.log
If you want to disable the automatic startup:
-
Open the crontab editor:
crontab -e
-
Find and remove or comment out (by adding a # at the beginning) the line that starts with
@reboot -
Save and exit the editor
If the camera server doesn't start automatically:
-
Check the startup log:
cat /home/pi/camera_startup.log
-
Make sure all scripts have execute permissions:
chmod +x capture.sh server.sh start_camera_server.sh
-
Try running the start script manually to see if there are any errors:
cd /path/to/RpiCamera/simple ./start_camera_server.sh -
Check if the camera module is enabled:
vcgencmd get_camera
You should see
supported=1 detected=1 -
If you're still having issues, you can try adding a delay before starting the server:
@reboot sleep 30 && cd /path/to/RpiCamera/simple && ./start_camera_server.sh >> /home/pi/camera_startup.log 2>&1
This project is open source and available under the MIT License.