DEV Community

Cover image for Real-Time Motion Monitoring with KiwisIoT
S. Nishanth
S. Nishanth

Posted on Edited on

Real-Time Motion Monitoring with KiwisIoT

Story of my project

Have you ever wondered how we can detect movement in a room and monitor it from anywhere?

That simple question inspired me to build my Wireless Motion Monitoring System using ESP8266, PIR Sensor, and KiwisIoT.

At first, it was just an idea: detect human movement and make that information available online. But as I started working on it, I discovered how simple hardware components can become part of a powerful IoT solution.

circuit diagram

The Idea Behind the Project

I wanted to build a system that could detect motion and send the detected status to an IoT platform in real time.

Instead of just turning on an LED when movement is detected, I wanted to monitor the sensor status through an online dashboard.

Hardware setup

coding

#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);
  Serial.println("     PIR MOTION MONITORING    ");

  pinMode(PIR_PIN, INPUT);

  Serial.println("PIR sensor initialized");

  Serial.println("Connecting to KiwisIoT...");

  kiwisiot.begin();

  Serial.println("KiwisIoT initialized");
  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

How I Built It

I used a few essential components:

ESP8266 – For Wi-Fi connectivity and processing.

PIR Sensor – To detect human movement.

KiwisIoT – To send and monitor sensor data online.

Arduino IDE – To write and upload the code.

The PIR sensor detects movement and sends its output to the ESP8266. The ESP8266 connects to Wi-Fi and sends the sensor status to KiwisIoT.

When motion is detected, the dashboard receives True. When no motion is detected, it receives False.

The Working Process

The PIR sensor continuously monitors movement.

The ESP8266 reads the sensor output.

The ESP8266 connects to the Wi-Fi network.

Sensor data is sent to KiwisIoT.

The dashboard displays the real-time motion status.

KiwisIOT Dashboard

What I Learned

This project helped me understand:

How PIR sensors detect movement.

How ESP8266 connects hardware to the internet.

How to send sensor data to an IoT platform.

How real-time monitoring works using a dashboard.

How hardware and software work together in an IoT project.

Serial Monitor Output

What's Next?

This is just the beginning! I would love to explore more features, such as motion alerts, notifications, and smart automation.

Building this project was a great learning experience, and it gave me more confidence to explore the world of IoT.

KiwisIOT github link

https://github.com/Kiwistron/KiwisIoT-Projects/tree/main/esp8266/005-pir-kiwisiot

Sometimes, a small idea can turn into a meaningful project when you start building it.

Thanks for reading! Feel free to share your thoughts and suggestions.

Top comments (0)