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

ChatGPT Image Sep 12, 2026, 07_42_05 PM.png
  1. 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.
  2. 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.
  3. The sensor status can then be monitored from the KiwisIoT dashboard.
  4. 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

  1. NodeMCU ESP8266
  2. PIR Motion Sensor
  3. Buzzer
  4. Jumper Wires
  5. USB Cable

Software Requirements

  1. Arduino IDE
  2. Wi-Fi Connection
  3. KiwisIoT library

How It Works

The working process is very simple:

  1. The PIR sensor checks for movement.
  2. The NodeMCU reads the PIR sensor value.
  3. If motion is detected:
  4. The buzzer turns ON.
  5. The NodeMCU sends YES to KiwisIoT.
  6. The dashboard shows the motion status.
  7. If there is no motion:
  8. The buzzer turns OFF.
  9. The NodeMCU sends NO to KiwisIoT.
  10. The dashboard shows the no-motion status.


Hardware Connections

circuit_image.png

PIR Sensor to NodeMCU

PIR Sensor NodeMCU
VCC --> 3V3
GND --> GND
OUT --> D5

Buzzer to NodeMCU

Buzzer NodeMCU
Positive (+) --> D6
Negative (-) --> GND

The important pins used in the program are:

#define PIR_PIN D5
#define BUZZER_PIN D6


KiwisIoT Setup

KiwisloIT_832x551.png
ChatGPT Image Sep 12, 2026, 05_31_32 PM.png
Motion_Status_832x551.png

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:

dash_xxxxxxxxxxxxx

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:

YES = Motion Detected
NO = No Motion

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:

#include <KiwisIoT.h>


Code

After completing the connections:

  1. Connect the NodeMCU to your computer using a USB cable.
  2. Open the Arduino IDE.
  3. Select the correct ESP8266 board.
  4. Select the correct COM port.
  5. Enter your Wi-Fi details.
  6. Enter your KiwisIoT Topic ID.
  7. Verify the code.
  8. Upload the program to the NodeMCU.

After the upload is completed, open the Serial Monitor.

#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);
}

Understanding the Code

including the KiwisIoT Library

#include <KiwisIoT.h>

This includes the KiwisIoT library so that the NodeMCU can communicate with the KiwisIoT platform.

Wi-Fi Details

const char* ssid = "YOUR WI-FI NAME";
const char* pass = "YOUR_PASSWORD";

Enter your Wi-Fi network name and password here.

KiwisIoT Topic ID

const char* topic = "dash_xxxxxxxxxxxxx";

Replace this with the Topic ID from your KiwisIoT dashboard.

Create KiwisIoT Object

KiwisIoT kiwisiot(ssid, pass, topic);

This creates the KiwisIoT connection using the Wi-Fi details and Topic ID.

Define Sensor Pins

#define PIR_PIN D5
#define BUZZER_PIN D6

The PIR sensor is connected to D5 and the buzzer is connected to D6.

Start the System

Inside setup():

kiwisiot.begin();

This starts the Wi-Fi and KiwisIoT connection.

Keep the Connection Active

Inside loop():

kiwisiot.run();

This keeps the KiwisIoT connection running while the NodeMCU continuously checks the PIR sensor.

Read the PIR Sensor

int motion = digitalRead(PIR_PIN);
  1. The NodeMCU reads the output from the PIR sensor.
  2. If the value is HIGH, motion is detected.
  3. If the value is LOW, there is no motion.

Motion Detected

When motion is detected:

digitalWrite(BUZZER_PIN, HIGH);

The buzzer turns ON.

The program also prints:

Motion Detected!

to the Serial Monitor.

Then it sends the value 1 to KiwisIoT:

kiwisiot.send("1", YES);

No Motion

When there is no movement:

digitalWrite(BUZZER_PIN, LOW);

The buzzer turns OFF.

The program prints:

No Motion

and sends 0 to KiwisIoT:

kiwisiot.send("1", NO);

Testing the Project

Screenshot_2196_832x551.png

Test 1: No Motion

Keep the PIR sensor without any movement in front of it.

The Serial Monitor should display:

No Motion

The buzzer should remain OFF.

KiwisIoT should receive:

NO

Test 2: Motion Detected

Move your hand or walk in front of the PIR sensor.

The Serial Monitor should display:

Motion Detected!

The buzzer will turn ON.

KiwisIoT should receive:

YES

This confirms that the PIR sensor, NodeMCU, buzzer, Wi-Fi connection, and KiwisIoT dashboard are working together.



KiwisIoT Dashboard Output

ChatGPT Image Sep 12, 2026, 07_18_02 PM.png
ChatGPT Image Sep 12, 2026, 07_17_27 PM.png

The motion status is sent to Channel 1.

The values are:

YES → Motion Detected
NO → No Motion
  1. This allows the sensor status to be monitored remotely through the KiwisIoT dashboard.
  2. 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:

  1. Home security
  2. Room monitoring
  3. Office security
  4. Entry detection
  5. Restricted-area monitoring
  6. Smart alarm systems
  7. IoT learning projects


Troubleshooting

PIR sensor is not detecting motion

Check:

  1. PIR VCC connection.
  2. PIR GND connection.
  3. PIR OUT connection to D5.
  4. PIR sensor adjustment settings.
  5. Give the PIR sensor some time to initialize after powering it on.

Buzzer is not working

Check:

  1. Buzzer positive connection to D6.
  2. Buzzer negative connection to GND.
  3. Make sure the buzzer type is compatible with the circuit.

KiwisIoT is not receiving data

Check:

  1. Wi-Fi name and password.
  2. Internet connection.
  3. KiwisIoT Topic ID.
  4. Channel number.
  5. KiwisIoT library installation.

Also make sure that:

kiwisiot.begin();

and

kiwisiot.run();

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.