Troubleshooting Guide
Relevant source files
The following files were used as context for generating this wiki page:
This guide provides solutions for common issues encountered with the HomeSecurity ESP32 system. It covers problems related to system startup, sensor functionality, WiFi connectivity, and alert notifications. The primary diagnostic tools are the onboard LED status indicators and the serial monitor output.
System Startup and Calibration
Problems during startup often relate to sensor calibration or initial task creation. The system is only fully operational after the PIR sensor calibration is complete.
Issue: Green LED does not turn ON
The Green LED indicates that the system is calibrated and ready. If it remains off, it signifies that the PIR sensor calibration has not finished.
- Symptom: The Green LED (GPIO 4) never illuminates after powering on the device.
- Cause: The
calibratePirSensorTaskis responsible for a 30-second calibration period. After this period, it callsturnGreenLedOn(). If this doesn't happen, the task may not be running or the timer condition is not met. - Solution:
- Ensure the device has been powered on for at least 30 seconds.
- Check the serial monitor for the
[SYSTEM] Initializare completă. Aștept calibrare...message, which confirms thesetup()function completed. - Verify the PIR sensor is correctly connected. The calibration task runs regardless of the sensor's state, but a faulty sensor might cause other issues.
The diagram below shows the startup and calibration flow.
WiFi Connectivity Issues
The system requires a stable WiFi connection to send notifications. The White LED provides a visual cue for the connection status.
Issue: White LED is OFF / No WiFi Connection
- Symptom: The White LED (GPIO 13) is off, and the serial monitor shows "Conectare esuata (timeout)!" or "Conexiune WiFi pierduta."
- Cause:
- Incorrect WiFi credentials (SSID/Password).
- The WiFi network is out of range or down.
- Connection times out after 15 seconds (
WIFI_CONNECTION_TIMEOUT).
- Solution:
- Verify the
WIFI_SSIDandWIFI_PASSWORDinHomeSecurity/src/wifi_manager.cpp. - Move the ESP32 closer to the WiFi router.
- Check the serial monitor. The
WiFiCheckTaskwill periodically attempt to reconnect, printing status messages.
- Verify the
This flowchart illustrates the WiFi connection and auto-reconnect logic.
Sensor Malfunctions
Each sensor is linked to a specific LED for easy diagnosis. If a sensor is not behaving as expected, check its corresponding LED and the physical connections.
Component Pinout Table
| Component | ESP32 GPIO | LED Indicator | LED GPIO |
|---|---|---|---|
| Hall Sensor | GPIO 33 | Yellow | GPIO 19 |
| PIR Sensor | GPIO 21 | Blue | GPIO 18 |
| Radar Sensor | GPIO 22 | Red | GPIO 23 |
| Buzzer | GPIO 25 | N/A | N/A |
Sources: HomeSecurity/README.md, HomeSecurity/include/led.h:6-10, HomeSecurity/include/hall_sensor.h:4, HomeSecurity/include/pir_sensor.h:6, HomeSecurity/include/microwave_sensor.h:6, HomeSecurity/include/alarm.h:5
Issue: PIR Sensor Not Detecting Motion (Blue LED Off)
- Symptom: The Blue LED (GPIO 18) does not turn on when there is clear movement in front of the PIR sensor.
- Cause:
- The system is still in its 30-second calibration phase (
pirCalibratedisfalse). - The PIR sensor is faulty or wired incorrectly to GPIO 21.
- The system is still in its 30-second calibration phase (
- Solution:
- Wait for the Green LED to turn on, indicating calibration is complete.
- Verify the wiring for the PIR sensor on GPIO 21.
- Check the
handlePirMovementTaskinmotion_logic.cppto ensure it's reading the sensor state correctly.
Sources: HomeSecurity/src/motion_logic.cpp:33-45, HomeSecurity/src/pir_sensor.cpp:20-31
Issue: Hall Sensor Not Triggering (Yellow LED Off)
- Symptom: Opening the door/window does not turn on the Yellow LED (GPIO 19).
- Cause: The Hall effect sensor is not detecting the absence of the magnet, or it is wired incorrectly.
- Solution:
- Confirm the sensor is connected to GPIO 33 and is configured as
INPUT_PULLUP. - Check the
isHallSensorTriggeredfunction; it should returntruewhen the sensor pin readsHIGH. - Verify the magnet's position relative to the sensor.
- Confirm the sensor is connected to GPIO 33 and is configured as
Sources: HomeSecurity/src/motion_logic.cpp:20-31, HomeSecurity/src/hall_sensor.cpp:3-15
Issue: Radar Confirmation Not Working (Red LED Off)
- Symptom: The Red LED (GPIO 23) never turns on, even with sustained motion after an initial alert.
- Cause:
- The motion is not continuous for at least 2 seconds. The
handleRadarMovementTaskhas a 2000ms threshold. - The radar sensor is faulty or wired incorrectly to GPIO 22.
- The motion is not continuous for at least 2 seconds. The
- Solution:
- Ensure there is continuous movement in the sensor's range for more than 2 seconds.
- Check the serial monitor for
[ALERT] Radarul detectează mișcare!. - Verify the wiring for the radar sensor on GPIO 22.
Sources: HomeSecurity/src/motion_logic.cpp:111-133, HomeSecurity/src/microwave_sensor.cpp:6-16
Alert and Notification Failures
Alerts consist of a local audible alarm and a remote push notification. Failures can occur at either stage.
Issue: No Audible Alarm (Buzzer)
- Symptom: The buzzer on GPIO 25 does not sound when the PIR or Hall sensor is triggered.
- Cause:
- The
triggerAlarm()function is not being called frompossibleHumanMovementDetectedTask. - The buzzer is wired incorrectly.
- The
ALARM_DURATIONis set to a very low value.
- The
- Solution:
- Check the serial monitor for
[ALARM] Alarma a fost pornită.. - Verify that
triggerAlarm()is called whenpirActiveorhallActiveis true. - Confirm the buzzer is connected to GPIO 25. The alarm runs for
ALARM_DURATION(default 3000ms) and is managed byhandleAlarm().
- Check the serial monitor for
Sources: HomeSecurity/src/motion_logic.cpp:52-55, HomeSecurity/src/alarm.cpp:7-30, HomeSecurity/include/alarm.h:6
Issue: No Push Notifications Received
- Symptom: The mobile application does not receive any push notifications.
- Cause:
- The ESP32 has no WiFi connection (White LED is off).
- The Firebase Cloud Function URL in
motion_logic.cppis incorrect. - The FCM device token in
motion_logic.cppis invalid or expired. - The
sendNotificationcall is failing.
- Solution:
- First, resolve any WiFi issues.
- Check the serial monitor for logs from
[FirebaseNotifier]. It will print the HTTP status code of the POST request. A code of200indicates success. - Verify the
FirebaseNotifierURL andfcmTokenconstants inHomeSecurity/src/motion_logic.cpp. - The code uses
client.setInsecure()to bypass SSL certificate validation, which is necessary for HTTPS calls to Google Cloud Functions on ESP32. Ensure this line is present.
The sequence diagram below shows the notification process.