IoT-Based IR Object Detection Using ESP8266 NodeMCU and KiwisIoT
Introduction
Have you ever wondered how we can detect objects and monitor them remotely using IoT?
In this project, I developed an IoT-based object detection system using an ESP8266 NodeMCU and an IR sensor. The system detects nearby objects and sends the detection status to the KiwisIoT dashboard through Wi-Fi.
The main objective is to understand how sensors, microcontrollers, wireless communication, and IoT platforms work together in a real-time monitoring application.
Components Required
Hardware Components
- ESP8266 NodeMCU
- IR Sensor Module
- Jumper Wires
- USB Cable
- Computer
Software Requirements
- Arduino IDE
- ESP8266 Board Package
- KiwisIoT Arduino Library
- KiwisIoT Account
- Wi-Fi Connection
Circuit Connections
The IR sensor is connected to the ESP8266 NodeMCU.
| IR Sensor | ESP8266 NodeMCU |
|---|---|
| VCC | 3.3V (if supported) |
| GND | GND |
| OUT | D7 |
The sensor sends a digital signal to the ESP8266 based on object detection.
CIRCUIT IMAGE:
How Does It Work?
- The IR sensor detects whether an object is present.
- The ESP8266 reads the digital output using
digitalRead(). - If the sensor output is LOW, the status becomes DETECTED.
- If the sensor output is HIGH, the status becomes NOT DETECTED.
- The ESP8266 sends the status to KiwisIoT using Wi-Fi.
- The dashboard displays the object detection status.
Arduino Programming
I used Arduino IDE to program the ESP8266 NodeMCU.
The program uses:
- ESP8266WiFi library for Wi-Fi connectivity.
- KiwisIoT library for IoT communication.
-
digitalRead()for reading sensor values. -
if-elseconditions for object detection. -
kiwisiot.send()to send information to the dashboard.
Arduino Code:
#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 IR_PIN D7
KiwisIoT kiwisiot(ssid, pass, topic);
void sendObjectStatus() {
int irState = digitalRead(IR_PIN);
String objectStatus;
if (irState == LOW) {
objectStatus = "DETECTED";
} else {
objectStatus = "NOT DETECTED";
}
Serial.println();
Serial.println("---------- IR MONITORING ----------");
Serial.print("IR Sensor Value: ");
Serial.println(irState);
Serial.print("Object Status: ");
Serial.println(objectStatus);
kiwisiot.send("0", objectStatus);
Serial.print("Sent to KiwisIoT Channel 0: ");
Serial.println(objectStatus);
}
void setup() {
Serial.begin(115200);
Serial.println();
Serial.println(" IR OBJECT MONITORING ");
pinMode(IR_PIN, INPUT);
Serial.println("IR sensor initialized");
Serial.println("Connecting to KiwisIoT...");
kiwisiot.begin();
Serial.println("KiwisIoT initialized");
Serial.println("Starting object monitoring...");
}
void loop() {
kiwisiot.run();
static unsigned long lastSend = 0;
if (millis() - lastSend >= 2000) {
lastSend = millis();
sendObjectStatus();
}
delay(100);
}
KiwisIoT Dashboard
The KiwisIoT platform is used to monitor the object detection status remotely.
The ESP8266 sends the sensor information through Wi-Fi, and the dashboard displays two possible statuses:
- DETECTED
- NOT DETECTED
This helps monitor object presence without continuously checking the physical sensor.
Applications
- Object Detection Systems
- Entry Monitoring
- Smart Parking Concepts
- Obstacle Detection
- Industrial Automation
- IoT Monitoring Systems
What I Learned
Through this project, I learned how to connect an IR sensor with an ESP8266 NodeMCU, read digital sensor values, establish Wi-Fi communication, and send real-time data to an IoT dashboard.
This project improved my practical understanding of IoT, Arduino programming, sensor interfacing, and embedded systems.
I used the reference to understand the concept and implement the project.
GitHub Reference:1.https://github.com/Kiwistron/KiwisIoT-Projects/tree/main/esp8266/003-ultrasonic-kiwisiot
My GitHub Repository:https://github.com/bala02102008/ESP8266-Ultrasonic-KiwisIoT
Future Improvements
- Adding a buzzer for object detection alerts.
- Integrating multiple IR sensors.
- Adding mobile notifications.
- Storing detection history in a cloud database.
- Developing an automated monitoring system.
Conclusion
This project demonstrates how an IR sensor, ESP8266 NodeMCU, and KiwisIoT platform can be combined to build a simple real-time object monitoring system.
It was a valuable learning experience that helped me explore the practical applications of IoT and embedded systems.
I hope this project helps other beginners who are interested in learning IoT and hardware development.


Top comments (0)