- This project is a simple IoT-based motion detection and alert system built using a NodeMCU ESP8266, PIR motion sensor, buzzer, and KiwisIoT.
- The PIR sensor detects movement in the surrounding area. When motion is detected, the NodeMCU activates the buzzer and sends the motion status to the KiwisIoT platform over Wi-Fi.
- The sensor status can be monitored remotely using a KiwisIoT dashboard.
- This project demonstrates a basic IoT workflow where a physical sensor is connected to a microcontroller, processed locally, and then sent to an online dashboard.
The system follows a simple process:
- The PIR sensor monitors the surrounding area.
- The sensor detects movement and generates an output signal.
- The NodeMCU reads the PIR sensor output.
- If motion is detected, the buzzer is turned ON.
- The motion status is sent to KiwisIoT through Wi-Fi.
- The dashboard displays the current sensor status.
- When movement stops, the buzzer turns OFF and the dashboard is updated.
Motion Detected β Buzzer ON β KiwisIoT shows YES
No Motion β Buzzer OFF β KiwisIoT shows NO
Hardware Required- NodeMCU ESP8266
- PIR Motion Sensor
- Buzzer
- Jumper Wires
- USB Cable
- Arduino IDE
- ESP8266 Board Package
- KiwisIoT Library
- Wi-Fi Connection
PIR Sensor to NodeMCU Pin
VCC --> 3V3
GND --> GND
OUT --> D5Buzzer β NodeMCUBuzzer Pin to NodeMCU Pin
Positive (+) --> D6
Negative (-) --> GNDThe PIR sensor is connected to D5, and the buzzer is connected to D6.
KiwisIoT SetupOpen the KiwisIoT platform and log in to your account. https://kiwisiot.in/login
Create a new dashboard or panel for the motion detection system.
After creating the dashboard:
- Create a channel for the motion status.
- Use Channel 1 for the sensor data.
- Get the Topic ID generated for the dashboard.
- Add a suitable widget to display the motion status.
- Use the Topic ID in the NodeMCU program.
The dashboard uses two status values:
- YES β Motion Detected
- NO β No Motion
Connect the NodeMCU ESP8266 to your computer using a USB cable.
Open Arduino IDE and configure the ESP8266 board.
Before uploading the program:
- Select the ESP8266 board.
- Select the correct COM port.
- Install the KiwisIoT library.
- Enter your Wi-Fi credentials.
- Enter your KiwisIoT Topic ID.
- Verify the code.
- Upload the program.
#include <KiwisIoT.h>
// WiFi Details
const char* ssid = "YOUR WI-FI NAME";
const char* pass = "YOUR_PASSWORD";
// KiwisIoT Dashboard Topic ID
const char* topic = "dash_xxxxxxxxxxxxx";
KiwisIoT kiwisiot(ssid, pass, topic);
// PIR and Buzzer Pins
#define PIR_PIN D5
#define BUZZER_PIN D6
void setup() {
Serial.begin(115200);
pinMode(PIR_PIN, INPUT);
pinMode(BUZZER_PIN, OUTPUT);
digitalWrite(BUZZER_PIN, LOW);
// Start WiFi + KiwisIoT
kiwisiot.begin();
Serial.println("Motion Detection System Started");
}
void loop() {
// Keep KiwisIoT connection active
kiwisiot.run();
// Read PIR sensor
int motion = digitalRead(PIR_PIN);
if (motion == HIGH) {
// Motion detected
digitalWrite(BUZZER_PIN, HIGH);
Serial.println("Motion Detected!");
// Send 1 to KiwisIoT Channel 1
kiwisiot.send("1", yes);
} else {
// No motion
digitalWrite(BUZZER_PIN, LOW);
Serial.println("No Motion");
// Send 0 to KiwisIoT Channel 1
kiwisiot.send("1", no);
}
delay(1000);
}Code ExplanationThe KiwisIoT library is included to allow the NodeMCU to communicate with the KiwisIoT platform.
The Wi-Fi name, password, and dashboard Topic ID are provided to the KiwisIoT object.
The PIR sensor is configured as an input and the buzzer is configured as an output.
int motion = digitalRead(PIR_PIN);This reads the current output of the PIR sensor.
When the sensor returns HIGH, motion is detected. The buzzer is activated and the value YES is sent to KiwisIoT.
When the sensor returns LOW, the buzzer is switched OFF and NO is sent to the dashboard.
The function:
kiwisiot.run();keeps the KiwisIoT communication active while the NodeMCU continuously checks the sensor.
Testing
Power on the NodeMCU and keep the area in front of the PIR sensor still.
The Serial Monitor should display:
No MotionThe buzzer should remain OFF.
The KiwisIoT dashboard should display:
NOTest 2 β Motion DetectedMove your hand or walk in front of the PIR sensor.
The Serial Monitor should display:
Motion Detected!The buzzer should turn ON.
The KiwisIoT dashboard should display:
YESThis confirms that the PIR sensor, NodeMCU, buzzer, Wi-Fi connection, and KiwisIoT dashboard are working together.
KiwisIoT Dashboard
The NodeMCU sends the motion status to Channel 1 of the KiwisIoT dashboard.
The dashboard displays:
YES β Motion Detected
NO β No MotionThis makes it possible to monitor the motion sensor remotely instead of relying only on the Serial Monitor.
ApplicationsThis project can be used as a basic building block for:
- Home security systems
- Room monitoring
- Office security
- Entry detection
- Restricted-area monitoring
- Smart alarm systems
- IoT learning projects
The same concept can be expanded by adding additional sensors, notifications, cameras, or data logging.
TroubleshootingPIR Sensor Not Detecting MotionCheck:
- PIR VCC connection
- PIR GND connection
- PIR OUT connection to D5
- PIR sensor adjustment
- Sensor initialization time
Check:
- Buzzer positive connection to D6
- Buzzer negative connection to GND
- Buzzer compatibility with the circuit
Check:
- Wi-Fi name and password
- Internet connection
- KiwisIoT Topic ID
- Channel number
- KiwisIoT library installation
kiwisiot.begin()insetup()kiwisiot.run()inloop()
The IoT-Based Motion Detection and Alert System provides a simple way to combine motion sensing, local alerts, Wi-Fi communication, and cloud-based monitoring.
The PIR sensor detects movement, the NodeMCU processes the sensor signal, and the buzzer provides an immediate local alert. At the same time, the motion status is sent to KiwisIoT so that it can be monitored from the dashboard.
This project is a useful starting point for developing more advanced IoT security and monitoring applications.




_JnuTDtq8iW.jpeg?auto=compress%2Cformat&w=48&h=48&fit=fill&bg=ffffff)








Comments