Are you tired of relying on traditional motion detection systems that require complex wiring and bulky hardware? Then it's time to upgrade to an IoT-based motion detection system with ESP32! With this project, you can create a sleek and intelligent motion detection system that's easy to install and control from anywhere in the world.
Using the power of IoT technology, you can receive real-time alerts and even integrate other devices to enhance the system's functionality. Plus, with the ESP32's advanced features, you can customize the system to suit your needs and preferences. In this project, I'll guide you through building your own IoT-based motion detection system with an ESP32, step by step. So, get ready to start an exciting DIY journey and experience the convenience and innovation of IoT technology like never before!
Components
- ESP32 development board
- HC-SR501 PIR sensor module
- LED
- 220-ohm resistor
- Breadboard
- Jumper wires
- Micro USB cable
- Laptop or PC with Arduino IDE installed
ESP32 Development Board
The ESP32 development board is a highly capable microcontroller board that utilizes the ESP32 chipset. With its integrated Wi-Fi and Bluetooth connectivity, this board is an excellent option for various Internet of Things (IoT) applications.
One of the main advantages of the ESP32 board is its compatibility with the Arduino Integrated Development Environment (IDE). With the familiar Arduino IDE, developers can easily program and prototype IoT projects using the ESP32 board.
HC-SR501 PIR Sensor Module
A passive infrared (PIR) sensor module called the HC-SR501 can be used to look for people or track their activity. It is frequently employed in IoT projects for applications involving motion detection.
A pyroelectric sensor, a lens, and some electronics are all parts of the PIR sensor module, which processes the sensor's data. The sensor senses a change in the infrared radiation that the object (like a human body) emits when it comes within the sensor's detection range. The pyroelectric sensor in the module notices this shift in radiation, and the electronics in the module process it.
An IoT-based motion detection system can be built using the ESP32 microcontroller and the HC-SR501 PIR sensor module. The ESP32 can activate an action, like turning on a light or transmitting a notification to a smartphone, by reading the output signal from the sensor module with its integrated analog-to-digital converter (ADC).
Additionally, the ESP32 can be configured to interact with other IoT devices, like a home automation system, and initiate various activities in response to motion sensed by the HC-SR501 PIR sensor module.
Breadboard
A breadboard is an essential tool for anyone working on electronics projects. It's a type of prototyping board that provides a platform for the experimentation and testing of electronic circuits without requiring soldering.
In this project, the breadboard serves as the primary connecting platform for the various components, including the ESP32 board, PIR sensor, and other essential components. Using the breadboard, developers can easily experiment with different circuits, test their functionality, and make necessary changes without damaging any components.
Working Principle
Here’s the working principle for this project:
- Any infrared radiation given off by moving objects within the PIR sensor's field of vision is picked up by it. One potentiometer controls the sensitivity, and the other controls the delay time. The sensitivity potentiometer regulates the sensor's range of motion detection, while the delay time slider regulates how long the sensor maintains its HIGH output following motion.
- The ESP32 board receives the PIR sensor's output via one of its GPIO pins. If the output is HIGH, it indicates that motion has been detected. If there is no motion observed, the output will be LOW.
- The ESP32 board uses an LED connected to another GPIO pin to indicate when motion is recognized. Additionally, the SMTP protocol notifies a designated receiver via email. The email's subject is "Motion Detected!" while the content includes the current date and time.
- A web server accessible from any device linked to the same network is also created by the ESP32 chip. The web server displays a straightforward webpage with a message showing whether motion is detected.
Circuit Diagram
Here’s the circuit diagram for this project:
The diagram shows an ESP32 board connected to a PIR sensor and an LED. The PIR sensor has three pins: VCC (5V), GND (ground), and OUT (output). The VCC pin is connected to the 5V pin of ESP32, while the GND pin is connected to the GND pin of ESP32. The OUT pin is connected to GPIO14 of ESP32 through a jumper wire.
The LED has two pins: anode (+) and cathode (-). The anode pin is connected to GPIO2 of ESP32 through a 220-ohm resistor and a jumper wire. The cathode pin is connected to the GND pin of ESP32 through another jumper wire.
The micro USB cable connects the ESP32 board to the laptop or PC for programming and power supply.
Testing the Project
- To begin this project, connect the ESP32 board to your laptop or PC using a micro USB cable. Then, launch the Arduino IDE and select the appropriate board and port from the Tools option.
- Next, modify the code to include your specific WiFi credentials and email parameters. Make sure to adjust these values to match your network and email settings.
- After making the necessary code changes, you can compile the code and upload it to the ESP32 board using the send button in the IDE. Once uploaded, open the serial monitor and set the baud rate to 115200. This will enable you to monitor the LED and output from the ESP32 board.
- With the serial monitor open, move your palm in front of the PIR sensor and observe the LED and serial monitor output. You should see the LED light up and receive the corresponding output from the serial monitor.
- Finally, check your email for a message from the ESP32 board. If configured correctly, you should receive an email notification from the board.
You've completed the project's testing if everything performs as anticipated. Congratulations!
Conclusion
The ESP32-based IoT motion-detecting device is an example of how IoT technology may be used for security and surveillance. All you need is an ESP32 board, an HC-SR501 PIR sensor module, a breadboard, some jumper wires, and a USB cable to build and test your system swiftly. The device is controlled by the ESP32 board, and the PIR sensor detects movement within its detection range. A breadboard and some jumper wires make it simple to create and test novel electrical circuits.