This project takes inspiration from the beloved movie "Home Alone." Remember how the boy cleverly used boards that looked like people on a toy train to make it seem like someone was home and scare off intruders? Well, in our version, EdgeAI steps in and takes the boy's place! It's a fun twist on a classic idea!
This prototype is designed for an intruder detection system capable of identifying human presence and initiating preemptive measures. The system will activate a dog barking sound and illuminate specific lights to simulate the presence of a homeowner, thereby potentially deterring intruders from proceeding further into the residence. Statistical analysis indicates that in numerous western countries, intruders frequently gain entry into homes through garden areas. The proposed system employs the Arduino Portenta H7, which is integrated with a trained machine learning model to detect human presence as soon as an individual enters the garden. Upon detection, designated GPIO pins will be engaged to activate the dog barking sound, followed by a subsequent delay before the lights are turned on to enhance the illusion of human presence. This system may prove advantageous for homeowners who are away on vacation.
ArchitectureIn this project, I have utilized the Arduino Portenta H7 as the primary controller to operate a trained vision model from Edge Impulse for intruder detection. Additionally, the Raspberry Pi Pico has been employed as a secondary controller to play an MP3 file of a dog barking and to manage the power supply for a table lamp.
Model TrainingIn vision model, we need to follow the below steps In Edge Impulse.
To begin, we will create a database and label the images indicating human presence as "Intruder." Subsequently, we will initiate the model training process using Edge Impulse. Based on the outcomes of the validation, it may be necessary to adjust the training parameters or incorporate additional datasets, followed by retraining the model to enhance its performance. Once the model has been successfully trained and validated, achieving an acceptable level of accuracy, we will proceed to deploy it on the Portenta H7 hardware utilizing the Arduino library.
To connect the Arduino Portenta H7 board to the EI account, please follow the steps outlined in the link below.
After installing the firmware, open the command window/Terminal (MacOs) and type the following daemon command:
edge-impulse-daemon
Once the device is connected, navigate to the Data Acquisition section.
Begin collecting image data and label it as 'Intruder' by creating a bounding box around the human presence.
Model training in Edge ImpulseIn the Create Impulse section, please set the image width and height to 96, and select "Object Detection" as the learning block.
In the Image section, choose 'GrayScale' for the color depth, as the Arduino Portenta H7 exclusively supports grayscale imagery. Subsequently, generate the features.
Within the Object Detection section, configure the training cycles to 50 and select the model FOMO MobileNetV2 with 0.35. The model achieved an accuracy of 92.3% during the training phase, which is deemed sufficient to proceed to the next step.
During the testing phase, the model is evaluated using new datasets that were not incorporated in the training process.
Project Link : https://studio.edgeimpulse.com/studio/765469
DeploymentAfter successfully verifying the trained model, deploy it back to the Arduino Portenta H7.
However, we won't be deploying it directly to the Arduino Portenta H7 just yet, as we need to add more logic on top of the machine learning prediction.
Once the model is downloaded, follow these steps to import the library into the Arduino IDE:
Importing library in Arduino IDE:1. Open your Arduino IDE, go to **Sketch** > **Add File**, and select the downloaded file.
2. Once imported, navigate to **Examples** > **IntruderDetectionSystem_V2_Inferencing** > **Portenta_H7** > **Portenta_h7_camera**.
I have incorporated custom logic into this library to activate specific General Purpose Input/Output (GPIO) pins when an intruder is detected. A Link to the modified.ino file is provided for reference once the library has been added to the Arduino.
AlgorithmUpon the detection of an intruder, the Portenta H7 will activate the designated GPIO pin. For detailed information regarding circuit connections, please refer to the Schematics section of this document.
In the Pico configuration, GPIO2 is designated as an input. When the input reads HIGH, the system will play the DogBarking.mp3 file, after which it will activate the relay via GPIO3 for a duration of five seconds before deactivating it. A high-level algorithm is illustrated in the accompanying diagram.
Configuring the PicoInitially, it is necessary to flash the.uf2 file from the CircuitPython link to ensure compatibility with MicroPython.
Installing Micro python in Pico
Once this is completed, the Code.py and DogBarking.mp3 files should be downloaded from the specified Link and pasted onto the CircuitPython disk.
The final prototype, equipped with an enclosure, is depicted as follows. It is essential to ensure that the speaker is externally mounted so that intruders may hear the sound of the dog barking.
This functional prototype can be utilized in residential settings when homeowners are away for extended periods. The software allows for flexibility in selecting various dog barking sounds or incorporating human voice recordings to deter intruders. Furthermore, this project holds potential applicability in diverse scenarios such as preventing poaching activities in forested areas.
Comments