Security-Cam Documentation
website·Indexed 31 days ago
https://dev.infinitel8p.com/Security-Cam/A security camera system for the Raspberry Pi Zero 2 W featuring modular trigger sensors, a Flask backend API on port 5005, and an Astro dashboard. Includes guides on hardware installation, MediaMTX setup, sensor calibration, and REST endpoint authentication for managing system functions and logs.
What's inside Security-Cam
- Security-Cam is a security camera system designed for the Raspberry Pi Zero 2 W. It automatically records video when a modular trigger sensor is activated, provided that no tracked devices (via Bluetooth or WiFi) are detected nearby. Recording stops once the sensor resets. The system supports a variety of modular sensors that can be swapped without changing code.
Retrieve deployment and archive information
Access metadata about the current installation and new content counts.
- Deployment Info:
GET /deploy_inforeturns thegit_branchandgit_commitif the project is a git repository. - Archive Count:
GET /archive/new_count?since=<ISO_TIMESTAMP>returns the number of recordings, timelapses, and snapshots created after the specified time. This is used for dashboard notification badges and is updated via SSEarchive_updatedevents.
# Get deployment info curl http://<pi-ip>:5005/deploy_info # Count new recordings since a date curl "http://<pi-ip>:5005/archive/new_count?since=2026-04-01T10:00:00%2B00:00"- Deployment Info:
Access the Security Camera Logs page
The Logs page allows you to inspect, search, and filter system log output in real time for debugging and monitoring. It is accessible via the browser using the Raspberry Pi's IP address.http://<raspberry-pi-ip>:3000/logsEnable night vision using Waveshare RPi Camera (F)
The system supports clear visibility in complete darkness by utilizing the built-in infrared LEDs of the Waveshare RPi Camera (F).Understand the automatic recording trigger flow
The security camera uses a modular trigger system to start recordings automatically based on the following logic:
- Sensor fires: A hardware event is detected (e.g., door opens, motion detected).
- Presence check: The system checks if any tracked Bluetooth or WiFi devices are nearby.
- Decision:
- If nobody is home: Recording starts automatically.
- If someone is home: The trigger is ignored to prevent false alarms.
- Stop: Recording stops after the sensor releases and a configurable hold timeout expires.
Note: Manual recording via the dashboard bypasses the presence check and always starts regardless of sensor state.
Access the Security-Cam Dashboard
The system provides a network-accessible dashboard that allows users to view the live feed, browse the video archive, monitor system health, and manage settings from any device on the local network.Locate your device's Bluetooth MAC address
The Bluetooth MAC address is required to identify a device in scan results and for the security camera's presence detection.
- Android: Navigate to Settings → About phone → Status information → Bluetooth address
- iPhone: Navigate to Settings → General → About → Bluetooth
Prevent disk overflow using Auto-delete
The auto-delete feature prevents the SD card from filling up by removing the oldest recordings when disk usage exceeds a specific threshold. The system checks disk usage before every new recording and every 5 minutes in the background.
To enable:
- Go to Settings > Storage.
- Toggle Auto-delete old recordings to on.
- Set the usage threshold (default is 85%).
- Click Save.
Connect the DS3231 Real Time Clock (RTC) Module
The DS3231 RTC module provides timekeeping for the system. The
NC(Not Connected) pin on the module is not used.Wiring Mapping:
DS3231 Pin Wire Color Raspberry Pi Pin Function 3.3V Red Pin 1 3V3 SDA Orange Pin 3 SDA SCK Yellow Pin 5 SCL GND Green Pin 6 or 9 GND Filter and analyze API logs using logger namespaces
The backend writes tologs/api/security-cam.log. Each log entry includes a timestamp, level, and a dot-separated logger name indicating the subsystem. You can usegrepto filter logs by these namespaces.# All Bluetooth activity grep "bt\." /opt/security-cam/logs/api/security-cam.log # Just pairing issues grep "bt.pair" /opt/security-cam/logs/api/security-cam.log # Only errors and warnings grep -E "WARNING|ERROR" /opt/security-cam/logs/api/security-cam.log # Follow live Bluetooth activity tail -f /opt/security-cam/logs/api/security-cam.log | grep "bt\."Connect and test the KY-025 Magnet Reed Switch
The KY-025 magnetic reed switch is connected to the Raspberry Pi GPIO pins. The
AO(Analog Output) pin on the KY-025 is not used because the Raspberry Pi lacks analog input pins.Wiring Mapping:
KY-025 Pin Wire Color Raspberry Pi Pin Function GND Black Pin 14 GND DO Blue Pin 15 GPIO22 + (VCC) Red Pin 17 3V3 Once connected, the red LED on the KY-025 should light up. Use the provided test script to verify the sensor triggers when a magnet is nearby.
python3 /opt/security-cam/setup/test_reed_switch.pyUpdate and restart security camera software
The dashboard checks for updates every 12 hours. A blue dot on the Settings icon indicates available updates.
- Update & Restart: Applies new commits by running
setup/update.sh, which pulls code, installs dependencies, and rebuilds the frontend. This restarts thesecurity-camservice. - Restart Services: Restarts the Flask API and Astro dashboard without rebooting the Pi (equivalent to
sudo systemctl restart security-cam). - Reboot Device: Performs a full Raspberry Pi reboot (equivalent to
sudo systemctl reboot).
- Update & Restart: Applies new commits by running