This repository contains a complete home security system solution using ESP32 camera modules with motion detection sensors (PIR and mmWave), a Raspberry Pi server, and a React Native mobile application for monitoring and control.
The system consists of three main components:
- ESP32 Camera Devices - ESP32 modules with cameras and motion sensors
- Raspberry Pi Server - Handles communication and coordination between devices
- Mobile Application - Provides user interface for monitoring, alerts, and configuration
Two types of ESP32 camera devices are supported:
This module uses a Passive Infrared (PIR) sensor to detect motion through heat signatures.
- ESP32 with camera module
- PIR motion sensor
- Connecting wires
-
Connect the PIR sensor to the ESP32 according to this wiring:
PIR Sensor ESP32 VCC 3.3V GND GND OUT GPIO 14 -
Connect the ESP32 to computer via USB
-
Open the
esp32_pir_modulesketch in Arduino IDE -
Install required libraries:
- WiFi
- WebSocketsClient
- ArduinoJson
- NTPClient
- ESP32 Camera libraries
- ESPAsyncWebServer
- AsyncTCP
-
Upload the sketch to ESP32
This module uses a millimeter-wave radar sensor for more precise motion detection that can work through thin walls and in varying lighting conditions.
- ESP32 with camera module
- mmWave radar sensor
- Connecting wires
- Connect the mmWave sensor to the ESP32 according to this wiring:
mmWave Sensor ESP32 VCC 3.3V GND GND RX GPIO 44 TX GPIO 43 - Connect the ESP32 to computer via USB
- Open the
esp32_mmwave_modulesketch in Arduino IDE - Install the same libraries as for the PIR module
- Upload the sketch to ESP32
When powered on for the first time, each ESP32 device will:
- Create a WiFi access point named either "ESP32-PIR-Setup" or "ESP32-mmWave-Setup"
- Connect to this access point using a smartphone or computer
- The device is now ready to be added to your security system through the mobile app
The server runs on a Raspberry Pi and acts as a communications hub for all ESP32 devices and the mobile application.
- Raspberry Pi (3 or 4 recommended) with Raspbian/Raspberry Pi OS
- Python 3.7 or higher
- Stable network connection
-
Transfer the
server.pyfile to your Raspberry Pi -
Install the required Python packages:
pip install websockets python-socketio json numpy asyncio -
Edit the provided
security-server.servicefile to update the paths:- Replace
/path/to/server.pywith the actual path to the server.py file - Replace
/path/to/directorywith the directory containing server.py
- Replace
-
Move the provided
security-server.servicefile to the systemd directory:sudo mv security-server.service /etc/systemd/system/ -
Enable and start the service:
sudo systemctl enable security-server.service sudo systemctl start security-server.service -
Check the status to verify it's running:
sudo systemctl status security-server.service
The mobile app provides the user interface for monitoring camera feeds, receiving alerts, and configuring the system.
- Clone the repository containing the mobile app code
- Install dependencies:
npm install - Start the development server:
npx expo start - Connect with the Expo Go app on your mobile device:
- Install "Expo Go" from the App Store (iOS) or Google Play Store (Android)
- Scan the QR code displayed in your terminal
- The app will open on your device
- On the mobile app, first go to the Settings screen to configure the following parameters
(these will be used by the ESP32 devices to connect to your network and server):- Your home WiFi network SSID and password
- The Raspberry Pi server IP address and port (default is 8081 for the ESP32 devices)
- Power on the ESP32 device - it will create its own WiFi access point
- Connect your phone to the ESP32's WiFi network (either "ESP32-PIR-Setup" or "ESP32-mmWave-Setup")
- On the mobile app, go to the Devices screen
- Tap "Add Device"
- Enter a name for your device and tap "Configure & Add Device"
- The device will restart and connect to your network and the Raspberry Pi server
- Connect your phone to your home network
- On the Home screen of the mobile app add the server IP and port (default is 8080 for the app)
- Tap "Connect" to establish a connection with the server.
- The system is now configured and ready to use.