Software Prerequisites & Setup
Relevant source files
The following files were used as context for generating this wiki page:
This document outlines the necessary software, dependencies, and configuration steps required to build, deploy, and run the HomeSecurity firmware on an ESP32 microcontroller. The setup process involves configuring the development environment, installing project-specific libraries, and setting user-specific credentials for WiFi and Firebase services.
The project is developed using the PlatformIO IDE within Visual Studio Code, which simplifies dependency management and the build/upload process. Correct configuration is crucial for enabling communication with the cloud backend and ensuring the system operates as intended.
Sources: HomeSecurity/README.md:167-171, 179-182
Prerequisites
Before proceeding with the installation, ensure your development machine has the following software installed.
| Software | Purpose |
|---|---|
| Visual Studio Code | The primary code editor. |
| PlatformIO IDE Extension | Manages the toolchain, libraries, and build/upload process for the ESP32. |
Sources: HomeSecurity/README.md:168-169
Installation and Build Process
The following diagram illustrates the steps to get the firmware running on the ESP32 board.
This flowchart shows the setup sequence from cloning the project to monitoring its operation.
Sources: HomeSecurity/README.md:173-191
Step-by-Step Guide
- Clone the Repository:
git clone https://github.com/IonutMilitaru/HomeSecurity.git cd HomeSecurity - Open in VS Code:
code . - Install Dependencies: PlatformIO will automatically detect the
platformio.inifile and prompt to install the required libraries. The primary dependency is the Firebase client library.Firebase Arduino Client Library for ESP8266 and ESP32 v4.4.17
- Configure Credentials: Follow the steps in the Configuration section below to set up WiFi and Firebase details.
- Build and Upload: Use the PlatformIO interface in VS Code (the arrow button in the status bar) or the CLI to compile and flash the firmware to the ESP32.
pio run --target upload - Monitor Output: View system logs and status messages via the serial monitor.
pio device monitor --baud 115200
Sources: HomeSecurity/README.md:173-191
Configuration
To function correctly, the firmware requires user-specific credentials for the local WiFi network and the Firebase project used for push notifications.
WiFi Configuration
Network credentials must be hardcoded into the firmware.
- File:
HomeSecurity/src/wifi_manager.cpp - Action: Modify the
WIFI_SSIDandWIFI_PASSWORDvariables with your network details.
// HomeSecurity/src/wifi_manager.cpp:5-6
char* WIFI_SSID = "YourNetworkName";
char* WIFI_PASSWORD = "YourPassword";
The system includes a WiFiCheckTask that attempts to reconnect automatically if the connection is lost, using these credentials.
Sources: HomeSecurity/src/wifi_manager.cpp:5-6, 29-36, HomeSecurity/README.md:195-198
Firebase Configuration
The firmware sends notifications by making an HTTP POST request to a Google Cloud Function. The URL of this function and the target device's FCM token must be configured.
- File:
HomeSecurity/src/motion_logic.cpp - Action:
- Update the
FirebaseNotifierconstructor with the URL of your deployedsendNotificationcloud function. - Update the
fcmTokenvariable with the token of the Android device that should receive the alerts.
- Update the
// HomeSecurity/src/motion_logic.cpp:4, 7
FirebaseNotifier notifier("https://your-firebase-function-url.cloudfunctions.net/sendNotification");
const char* fcmToken = "your-device-fcm-token";
The FirebaseNotifier class encapsulates the logic for sending the notification payload to the specified cloud function URL.
Sources: HomeSecurity/src/motion_logic.cpp:4, 7, HomeSecurity/src/firebase_notifier.cpp:6-27, HomeSecurity/README.md:200-205
Timing Parameters
Several key operational timings can be adjusted by modifying #define constants or variables in the source code.
| Parameter | Location | Default Value | Description |
|---|---|---|---|
WIFI_CONNECTION_TIMEOUT | src/wifi_manager.cpp:4 | 15000ms | Timeout for establishing a WiFi connection. |
ALARM_DURATION | include/alarm.h:6 | 3000ms | Duration for which the audible buzzer remains active. |
| PIR Calibration | src/pir_sensor.cpp:11 | 30000ms | Warm-up period for the PIR sensor after power-on. |
| Radar Confirmation | src/motion_logic.cpp:111 | 2000ms | Time threshold for sustained radar activity to confirm presence. |
Sources: HomeSecurity/README.md:207-213, HomeSecurity/src/wifi_manager.cpp:4, HomeSecurity/include/alarm.h:6, HomeSecurity/src/pir_sensor.cpp:11, HomeSecurity/src/motion_logic.cpp:111