IoT-Based Motion Detection and Alert System Using NodeMCU and KiwisIoT
by ananthi rk in Circuits > Sensors
39 Views, 0 Favorites, 0 Comments
IoT-Based Motion Detection and Alert System Using NodeMCU and KiwisIoT
- In this project, we are going to build a simple IoT-Based Motion Detection and Alert System using a NodeMCU ESP8266, PIR motion sensor, and buzzer.
- The PIR sensor detects movement in the surrounding area. When motion is detected, the NodeMCU turns ON the buzzer and sends the motion status to the KiwisIoT platform through Wi-Fi.
- The sensor status can then be monitored from the KiwisIoT dashboard.
- This project is simple to build and is useful for learning how sensors, microcontrollers, Wi-Fi, and IoT dashboards can work together.
Supplies
Hardware Requirements
- NodeMCU ESP8266
- PIR Motion Sensor
- Buzzer
- Jumper Wires
- USB Cable
Software Requirements
- Arduino IDE
- Wi-Fi Connection
- KiwisIoT library
How It Works
The working process is very simple:
- The PIR sensor checks for movement.
- The NodeMCU reads the PIR sensor value.
- If motion is detected:
- The buzzer turns ON.
- The NodeMCU sends YES to KiwisIoT.
- The dashboard shows the motion status.
- If there is no motion:
- The buzzer turns OFF.
- The NodeMCU sends NO to KiwisIoT.
- The dashboard shows the no-motion status.
Hardware Connections
PIR Sensor to NodeMCU
Buzzer to NodeMCU
The important pins used in the program are:
KiwisIoT Setup
Step 1: Open KiwisIoT
Log in to your KiwisIoT account. https://kiwisiot.in/login
Step 2: Create a Dashboard / Panel
Create a new dashboard or panel for the motion detection project.
Step 3: Get the Topic ID
After creating the dashboard, get the Topic ID.
It will look similar to:
We will use this Topic ID in the NodeMCU code.
Step 4: Create a Channel
Create or use Channel 1 for the motion sensor.
In this project:
So, when the PIR sensor detects movement, the NodeMCU sends YES to Channel 1.
When there is no movement, it sends NO.
Software Setup
You can use Arduino IDE or another supported development environment to program the NodeMCU.
Make sure the ESP8266 board support is installed and the required KiwisIoT library is available.
The program uses:
Code
After completing the connections:
- Connect the NodeMCU to your computer using a USB cable.
- Open the Arduino IDE.
- Select the correct ESP8266 board.
- Select the correct COM port.
- Enter your Wi-Fi details.
- Enter your KiwisIoT Topic ID.
- Verify the code.
- Upload the program to the NodeMCU.
After the upload is completed, open the Serial Monitor.
Understanding the Code
including the KiwisIoT Library
This includes the KiwisIoT library so that the NodeMCU can communicate with the KiwisIoT platform.
Wi-Fi Details
Enter your Wi-Fi network name and password here.
KiwisIoT Topic ID
Replace this with the Topic ID from your KiwisIoT dashboard.
Create KiwisIoT Object
This creates the KiwisIoT connection using the Wi-Fi details and Topic ID.
Define Sensor Pins
The PIR sensor is connected to D5 and the buzzer is connected to D6.
Start the System
Inside setup():
This starts the Wi-Fi and KiwisIoT connection.
Keep the Connection Active
Inside loop():
This keeps the KiwisIoT connection running while the NodeMCU continuously checks the PIR sensor.
Read the PIR Sensor
- The NodeMCU reads the output from the PIR sensor.
- If the value is HIGH, motion is detected.
- If the value is LOW, there is no motion.
Motion Detected
When motion is detected:
The buzzer turns ON.
The program also prints:
to the Serial Monitor.
Then it sends the value 1 to KiwisIoT:
No Motion
When there is no movement:
The buzzer turns OFF.
The program prints:
and sends 0 to KiwisIoT:
Testing the Project
Test 1: No Motion
Keep the PIR sensor without any movement in front of it.
The Serial Monitor should display:
The buzzer should remain OFF.
KiwisIoT should receive:
Test 2: Motion Detected
Move your hand or walk in front of the PIR sensor.
The Serial Monitor should display:
The buzzer will turn ON.
KiwisIoT should receive:
This confirms that the PIR sensor, NodeMCU, buzzer, Wi-Fi connection, and KiwisIoT dashboard are working together.
KiwisIoT Dashboard Output
The motion status is sent to Channel 1.
The values are:
- This allows the sensor status to be monitored remotely through the KiwisIoT dashboard.
- The main advantage of using KiwisIoT is that the sensor data is not limited to the Serial Monitor. The NodeMCU can send the information to the IoT platform through Wi-Fi.
Applications
This project can be used as a basic system for:
- Home security
- Room monitoring
- Office security
- Entry detection
- Restricted-area monitoring
- Smart alarm systems
- IoT learning projects
Troubleshooting
PIR sensor is not detecting motion
Check:
- PIR VCC connection.
- PIR GND connection.
- PIR OUT connection to D5.
- PIR sensor adjustment settings.
- Give the PIR sensor some time to initialize after powering it on.
Buzzer is not working
Check:
- Buzzer positive connection to D6.
- Buzzer negative connection to GND.
- Make sure the buzzer type is compatible with the circuit.
KiwisIoT is not receiving data
Check:
- Wi-Fi name and password.
- Internet connection.
- KiwisIoT Topic ID.
- Channel number.
- KiwisIoT library installation.
Also make sure that:
and
are present in the program.
Conclusion
In this project, we built a simple IoT-Based Motion Detection and Alert System using NodeMCU ESP8266, a PIR motion sensor, a buzzer, and KiwisIoT.
The PIR sensor detects movement, the NodeMCU processes the sensor data, and the buzzer provides a local alert. At the same time, the motion status is sent to KiwisIoT through Wi-Fi, allowing the data to be monitored from the IoT dashboard.
This project is a good starting point for learning how sensors, ESP8266, Wi-Fi, and IoT platforms can be combined to create practical smart systems.
The same basic setup can later be expanded into a more advanced security or smart-home project by adding notifications, cameras, multiple sensors, data logging, or AI features.