DEV Community

Cover image for MotionGuard IoT: Smart PIR Motion Monitoring Using ESP8266 and KiwisIoT
Harshan.M
Harshan.M

Posted on

MotionGuard IoT: Smart PIR Motion Monitoring Using ESP8266 and KiwisIoT

๐Ÿš€ MotionGuard IoT: Building a Real-Time PIR Motion Detection System Using ESP8266 and KiwisIoT

Have you ever wanted to monitor human movement remotely using IoT technology?

In this project, I built MotionGuard IoT, a smart motion detection system using an ESP8266 NodeMCU and a PIR (Passive Infrared) sensor.

The system detects human movement and sends the sensor information to the KiwisIoT Platform through Wi-Fi.

The dashboard displays the motion status in real time:

  • True โ€“ Motion Detected
  • False โ€“ No Motion Detected

Let's see how this project works!

๐Ÿ’ก 1. Project Overview

The main objective of MotionGuard IoT is to detect human movement and monitor the status remotely.

The PIR sensor detects changes in infrared radiation caused by movement. The ESP8266 processes the sensor signal and sends the result to the KiwisIoT dashboard.

๐Ÿงฐ 2. Components Required

Component Quantity
ESP8266 NodeMCU 1
PIR Motion Sensor 1
Jumper Wires As required
USB Cable 1
Computer 1

Software and Tools

  • Arduino IDE
  • ESP8266 Board Package
  • KiwisIoT Arduino Library
  • KiwisIoT Platform
  • Wi-Fi Connection

๐Ÿ”Œ 3. Circuit Connections

The PIR sensor is connected to the ESP8266 NodeMCU using jumper wires.

PIR Sensor ESP8266 NodeMCU
VCC Suitable power supply
GND GND
OUT D7

The OUT pin sends the motion detection signal to the ESP8266.

Important: Check your PIR module's voltage requirements. Some PIR modules require 5V power. Make sure the signal reaching the ESP8266 GPIO does not exceed 3.3V.

โš™๏ธ 4. How Does It Work?

The working process is simple:

  1. The PIR sensor monitors its surroundings.
  2. When a person moves in front of the sensor, it detects infrared changes.
  3. The ESP8266 receives the sensor signal.
  4. If movement is detected, the status becomes True.
  5. If there is no movement, the status becomes False.
  6. The ESP8266 sends the information through Wi-Fi.
  7. The KiwisIoT dashboard displays the motion status.

๐Ÿ’ป 5. Arduino Programming

I used Arduino IDE to program the ESP8266 NodeMCU.

The program reads the PIR sensor through digital pin D7 and sends the motion status to KiwisIoT Channel 0.

Before uploading, configure your Wi-Fi name, password, and KiwisIoT topic ID.

#include <ESP8266WiFi.h>
#include <KiwisIoT.h>

const char* ssid = "YOUR_WIFI_NAME";
const char* pass = "YOUR_WIFI_PASSWORD";

const char* topic = "YOUR_DASHBOARD_TOPIC_ID";

#define PIR_PIN D7

KiwisIoT kiwisiot(ssid, pass, topic);

void sendMotionStatus() {

  int pirState = digitalRead(PIR_PIN);

  String motionStatus;

  if (pirState == HIGH) {
    motionStatus = "True";
  }
  else {
    motionStatus = "False";
  }

  Serial.println();
  Serial.println("---------- PIR MONITORING ----------");

  Serial.print("PIR Sensor Value: ");
  Serial.println(pirState);

  Serial.print("Motion Status: ");
  Serial.println(motionStatus);

  if (pirState == HIGH) {
    Serial.println("Motion: DETECTED");
  }
  else {
    Serial.println("Motion: NOT DETECTED");
  }

  kiwisiot.send("0", motionStatus);

  Serial.print("Sent to KiwisIoT Channel 0: ");
  Serial.println(motionStatus);
}

void setup() {

  Serial.begin(115200);

  pinMode(PIR_PIN, INPUT);

  Serial.println("PIR MOTION MONITORING");

  kiwisiot.begin();

  Serial.println("Starting motion monitoring...");
}

void loop() {

  kiwisiot.run();

  static unsigned long lastSend = 0;

  if (millis() - lastSend >= 2000) {

    lastSend = millis();

    sendMotionStatus();
  }

  delay(100);
}
Enter fullscreen mode Exit fullscreen mode

โ˜๏ธ 6. KiwisIoT Dashboard Integration

One of the important features of this project is its integration with the KiwisIoT Platform.

The ESP8266 sends the motion status to Channel 0 through Wi-Fi.

Dashboard Configuration:

  • Platform: KiwisIoT
  • Widget Name: Motion Detection
  • Widget Type: Label
  • Channel ID: 0

The dashboard displays the received motion status as True or False.

๐Ÿงช 7. Live Testing and Results

I tested the project under two different conditions.

Test 1: Motion Detected

When someone moves in front of the PIR sensor:

PIR Sensor Value: 1
Motion Status: True
Motion: DETECTED
Dashboard Result: True
Enter fullscreen mode Exit fullscreen mode

๐ŸŒ 8. Real-World Applications

MotionGuard IoT can be used in:

  • Smart Home Monitoring
  • Room Movement Detection
  • Smart Lighting Systems
  • Entry Monitoring
  • Office Security
  • IoT-Based Monitoring Systems

๐Ÿ”ฎ 9. Future Improvements

In future versions, I would like to add:

  • LED indicators
  • Buzzer alerts
  • Mobile notifications
  • Automatic light control
  • Multiple PIR sensors
  • Motion activity history

๐ŸŽ“ 10. What I Learned

Through this project, I learned:

  • How to interface a PIR sensor with ESP8266.
  • How to detect human movement.
  • How to connect ESP8266 to Wi-Fi.
  • How to send sensor data to KiwisIoT.
  • How to monitor sensor information through an IoT dashboard.

๐Ÿ“Œ Conclusion

MotionGuard IoT demonstrates how a PIR sensor, ESP8266 NodeMCU, and KiwisIoT Platform can work together to create a simple remote motion monitoring system.

This project was a great learning experience that helped me understand sensor interfacing, Arduino programming, Wi-Fi communication, and IoT dashboard integration.

Thanks for reading!

I hope this project inspires other beginners to explore IoT technology.

Built With: ESP8266 NodeMCU | PIR Sensor | Arduino IDE | KiwisIoT Platform

Top comments (0)