Hardware Requirements
Relevant source files
The following files were used as context for generating this wiki page:The HomeSecurity system is an IoT-based anti-intrusion solution built around the ESP32 microcontroller. It integrates multiple sensors for multi-layered detection, actuators for local alerts, and status indicators. The hardware is designed to be an affordable and customizable security solution, forming the "Edge Tier" of the system architecture, responsible for data acquisition and local processing.
The core of the hardware is the ESP32 DOIT DevKit V1, which orchestrates the reading of sensor data, controls visual and audible alarms, and communicates with the cloud backend. The system also includes an external IP camera for live video streaming, which is accessed by the client application but does not interface directly with the ESP32.
Sources: HomeSecurity/README.md:23-26, 44-53, 80-83
Bill of Materials
The following table lists the essential hardware components required for the project.
| Component | Model | Purpose | Quantity |
|---|---|---|---|
| Microcontroller | ESP32 DOIT DevKit V1 | Central processing unit | 1 |
| Magnetic Sensor | KY-003 (Hall Effect) | Door/window open detection | 1 |
| PIR Sensor | HC-SR505 | Passive infrared motion detection | 1 |
| Radar Sensor | RCWL-0516 | Doppler microwave motion detection | 1 |
| Buzzer | KY-012 (Active) | Audible alarm | 1 |
| LEDs | 5mm (Various colors) | Visual status indicators | 5 |
| Resistors | 100Ω | Current limiting for LEDs | 5 |
| Power Supply | 2x 3.6V batteries | 7.2V source (regulated to 5V) | 1 set |
| IP Camera | TP-Link Tapo C200 | Live video streaming (RTSP) | 1 |
Sources: HomeSecurity/README.md:85-97
ESP32 Pin Configuration
The ESP32's GPIO pins are mapped to various sensors and actuators. The configuration is crucial for the correct functioning of the system's detection and notification logic.
This diagram illustrates the connections between the ESP32 and the peripheral components.
Detailed Pin Table
The following table provides a detailed mapping of each component to its corresponding ESP32 GPIO pin, its type, and its function within the system.
| Pin | Component | Type | Description | Source Files |
|---|---|---|---|---|
| GPIO 33 | Hall Sensor | INPUT_PULLUP | Magnetic door sensor | [hall_sensor.h:5](https://github.com/VeliceaFabianPavel/test-repo/blob/HEAD/hall_sensor.h#L5), [hall_sensor.cpp:4](https://github.com/VeliceaFabianPavel/test-repo/blob/HEAD/hall_sensor.cpp#L4), [README.md:113](https://github.com/VeliceaFabianPavel/test-repo/blob/HEAD/README.md#L113) |
| GPIO 21 | PIR Sensor | INPUT | Motion detection | [pir_sensor.h:6](https://github.com/VeliceaFabianPavel/test-repo/blob/HEAD/pir_sensor.h#L6), [pir_sensor.cpp:7](https://github.com/VeliceaFabianPavel/test-repo/blob/HEAD/pir_sensor.cpp#L7), [README.md:114](https://github.com/VeliceaFabianPavel/test-repo/blob/HEAD/README.md#L114) |
| GPIO 22 | Radar Sensor | INPUT | Doppler motion detection | [microwave_sensor.h:6](https://github.com/VeliceaFabianPavel/test-repo/blob/HEAD/microwave_sensor.h#L6), [microwave_sensor.cpp:4](https://github.com/VeliceaFabianPavel/test-repo/blob/HEAD/microwave_sensor.cpp#L4), [README.md:115](https://github.com/VeliceaFabianPavel/test-repo/blob/HEAD/README.md#L115) |
| GPIO 25 | Buzzer | OUTPUT | Audio alarm | [alarm.h:6](https://github.com/VeliceaFabianPavel/test-repo/blob/HEAD/alarm.h#L6), [alarm.cpp:7](https://github.com/VeliceaFabianPavel/test-repo/blob/HEAD/alarm.cpp#L7), [README.md:118](https://github.com/VeliceaFabianPavel/test-repo/blob/HEAD/README.md#L118) |
| GPIO 19 | Yellow LED | OUTPUT | Hall sensor triggered | [led.h:6](https://github.com/VeliceaFabianPavel/test-repo/blob/HEAD/led.h#L6), [led.cpp:4](https://github.com/VeliceaFabianPavel/test-repo/blob/HEAD/led.cpp#L4), [README.md:113](https://github.com/VeliceaFabianPavel/test-repo/blob/HEAD/README.md#L113) |
| GPIO 18 | Blue LED | OUTPUT | PIR motion detected | [led.h:7](https://github.com/VeliceaFabianPavel/test-repo/blob/HEAD/led.h#L7), [led.cpp:5](https://github.com/VeliceaFabianPavel/test-repo/blob/HEAD/led.cpp#L5), [README.md:114](https://github.com/VeliceaFabianPavel/test-repo/blob/HEAD/README.md#L114) |
| GPIO 23 | Red LED | OUTPUT | Intrusion confirmed by radar | [led.h:8](https://github.com/VeliceaFabianPavel/test-repo/blob/HEAD/led.h#L8), [led.cpp:6](https://github.com/VeliceaFabianPavel/test-repo/blob/HEAD/led.cpp#L6), [README.md:115](https://github.com/VeliceaFabianPavel/test-repo/blob/HEAD/README.md#L115) |
| GPIO 4 | Green LED | OUTPUT | System calibrated/ready | [led.h:9](https://github.com/VeliceaFabianPavel/test-repo/blob/HEAD/led.h#L9), [led.cpp:7](https://github.com/VeliceaFabianPavel/test-repo/blob/HEAD/led.cpp#L7), [README.md:120](https://github.com/VeliceaFabianPavel/test-repo/blob/HEAD/README.md#L120) |
| GPIO 13 | White LED | OUTPUT | WiFi connected | [led.h:10](https://github.com/VeliceaFabianPavel/test-repo/blob/HEAD/led.h#L10), [led.cpp:8](https://github.com/VeliceaFabianPavel/test-repo/blob/HEAD/led.cpp#L8), [README.md:121](https://github.com/VeliceaFabianPavel/test-repo/blob/HEAD/README.md#L121) |
Component Details
Sensors
The system uses a multi-layered sensor approach to provide robust intrusion detection and minimize false alarms.
Hall Effect Sensor (KY-003)
- Pin:
GPIO 33 - Principle: Detects magnetic field changes. It is used for perimeter detection on doors or windows.
- Configuration: The pin is configured as
INPUT_PULLUP. AHIGHsignal indicates the sensor is triggered (magnet moved away). - Application: Mounted on a door frame with a magnet on the door. Triggers an immediate Stage 1 alert.
Sources: HomeSecurity/README.md:100-103, HomeSecurity/include/hall_sensor.h:5, HomeSecurity/src/hall_sensor.cpp:4, 7-15
PIR Sensor (HC-SR505)
- Pin:
GPIO 21 - Principle: Detects passive infrared radiation from warm bodies, indicating movement.
- Range: Up to 3 meters.
- Calibration: Requires a 30-second warm-up period upon system boot, during which it is not active. The green LED indicates when calibration is complete.
- Application: General motion detection in a room. Triggers a Stage 1 alert.
Sources: HomeSecurity/README.md:105-109, HomeSecurity/include/pir_sensor.h:6, HomeSecurity/src/pir_sensor.cpp:12-16
Radar Sensor (RCWL-0516)
- Pin:
GPIO 22 - Principle: Uses Doppler effect microwave detection to sense movement. It can detect motion through non-metallic materials.
- Range: Up to 7 meters.
- Application: Used for presence confirmation. If this sensor detects continuous motion for over 2 seconds after a Stage 1 alert, it triggers a Stage 2 confirmation alert.
Sources: HomeSecurity/README.md:111-115, HomeSecurity/include/microwave_sensor.h:6, HomeSecurity/src/motion_logic.cpp:106-110
Actuators
Active Buzzer (KY-012)
- Pin:
GPIO 25 - Function: Provides an audible alarm upon initial detection by the PIR or Hall sensor.
- Operation: The buzzer is activated for a non-blocking duration of 3000 milliseconds when
triggerAlarm()is called. ThehandleAlarm()function manages turning it off after the duration expires.
Sources: HomeSecurity/README.md:89, 118, HomeSecurity/include/alarm.h:6-7, HomeSecurity/src/alarm.cpp:16-23
Status Indicators (LEDs)
Five LEDs provide visual feedback on the system's status. All LED pins are configured as OUTPUT.
| LED Color | GPIO Pin | Status Meaning |
|---|---|---|
| 🟢 Green | GPIO 4 | System calibrated and ready |
| ⚪ White | GPIO 13 | WiFi connected successfully |
| 🟡 Yellow | GPIO 19 | Hall sensor triggered (door opened) |
| 🔵 Blue | GPIO 18 | PIR motion detected |
| 🔴 Red | GPIO 23 | Intrusion confirmed by radar |
Sources: HomeSecurity/README.md:181-188, HomeSecurity/include/led.h:6-10