IoT IR Sensor Monitoring Using NodeMCU ESP8266 and KiwisIoT
by kggopi666 in Circuits > Sensors
71 Views, 0 Favorites, 0 Comments
IoT IR Sensor Monitoring Using NodeMCU ESP8266 and KiwisIoT
In this project, I connected an IR sensor to a NodeMCU ESP8266 and sent the sensor readings to a web-based IoT dashboard using KiwisIoT.
The main goal was to make a simple IoT system where the IR sensor could be connected to the ESP8266, the sensor value could be read using Arduino code, and the result could be monitored remotely through a web dashboard.
I used KiwisIoT.com to visualize the sensor data without having to build a separate dashboard from scratch.
This is a beginner-friendly project and can also be used as a starting point for more advanced IoT applications such as object detection, automation, counting systems, and smart monitoring.
Supplies
- Microcontroller: NodeMCU ESP8266
- Sensor: IR obstacle sensor
- Sensor pin: D2
- KiwisIoT Channel ID: 1
- Communication: Wi-Fi
- Dashboard: KiwisIoT
- Programming environment: Arduino IDE
- Platform : https://kiwisiot.in/
- Arduino Library: Kiwisiot
Components Required
You will need:
- NodeMCU ESP8266
- IR sensor module
- Jumper wires
- USB cable
- Computer
- Wi-Fi connection
- KiwisIoT account
The IR sensor module normally provides a digital output that changes between HIGH and LOW depending on whether an object is detected.
Create a KiwisIoT Dashboard
Now we need a place to receive and display the IR sensor value.
I used KiwisIoT, a web-based IoT platform for sending and receiving device data.
Go to:
https://kiwisiot.in/
Create or log in to your account and create a dashboard/panel.
Once the panel is available, we can configure a widget to display the IR sensor value.
Configure the IR Sensor Widget
Inside the KiwisIoT dashboard, add a widget that can display the incoming value.
For this project, I created an IR widget and configured:
- Name: IR
- Channel ID: 1
- Unit: optional / left blank
The important part is the Channel ID.
Our Arduino code will send the IR sensor value to:
Therefore, the dashboard widget also needs to listen to Channel ID 1.
Install the Required Library
Open the Arduino IDE and make sure your ESP8266 board support is installed.
The project uses the KiwisIoT library:
Install the KiwisIoT library according to the library/project documentation.
The ESP8266 will use the library to connect to Wi-Fi and communicate with the KiwisIoT platform.
CODE
Here is the complete code I used for the IR sensor.
Important: Replace the Wi-Fi credentials with your own credentials before
1.What the important parts do
This includes the KiwisIoT library required for communication with the platform.
2. Wi-Fi credentials
These are used by the ESP8266 to connect to your Wi-Fi network.
3. KiwisIoT topic
This identifies the KiwisIoT panel/topic used by the device.
4. IR sensor pin
The IR sensor's digital output is connected to D2.
5. Configure the pin
The ESP8266 reads the IR sensor as a digital input.
6. Read the sensor
This reads the current state of the IR sensor.
The result will normally be either:
or
The exact meaning of 0 and 1 depends on the IR sensor module's logic configuration. Some modules output LOW when an object is detected, while others may behave differently.
7. Send the value to KiwisIoT
This sends the sensor value to Channel ID 1.
This is the connection between the ESP8266 code and the dashboard widget.
Upload the Code
Connect the NodeMCU ESP8266 to your computer using USB.
In Arduino IDE:
- Select the correct ESP8266 board.
- Select the correct COM port.
- Verify the code.
- Upload the sketch.
- Open the Serial Monitor.
Set the Serial Monitor baud rate to:
9600 baud
Check the Serial Monitor
After uploading the program, open the Serial Monitor.
You should see output similar to:
Check the KiwisIoT Dashboard
Now open the KiwisIoT panel.
The value sent by the ESP8266 should appear in the IR widget.
In my test, the dashboard displayed:
The value changed when the state of the IR sensor changed.
How the Complete System Works
The complete data flow is very simple:
Every 500 milliseconds, the ESP8266 reads the sensor and sends the value to KiwisIoT.
The relevant section is:
So the sensor doesn't need to be connected directly to the dashboard. The ESP8266 acts as the IoT device that collects and transmits the data.
My Experience Using KiwisIoT
I wanted to keep this project simple rather than spending most of the development time creating an IoT backend and dashboard.
What I found useful about KiwisIoT was that I could concentrate on the actual hardware and sensor logic while using the platform for the data communication and visualization side.
For this experiment, the workflow was straightforward:
Connect sensor → write ESP8266 code → send channel data → configure widget → view the result.
The Channel ID concept was particularly useful because it provides a simple way to connect a value generated in the Arduino code with a widget on the dashboard.
For a beginner experimenting with ESP8266 and IoT, this makes the project easier to understand because the hardware code and dashboard configuration remain relatively simple.
I also liked being able to see the sensor value on a web dashboard instead of relying only on the Serial Monitor.
That makes the project feel more like an actual IoT application rather than just a sensor-reading experiment.
You can explore the platform at https://kiwisiot.in/
What I Learned
This small project helped me understand several important concepts:
- How to read a digital sensor using ESP8266
- How digitalRead() works
- How IoT devices communicate with a cloud/web platform
- How sensor values can be mapped to dashboard channels
- How to visualize device data through a web interface
- How a microcontroller can act as an IoT edge device
More importantly, it demonstrates the basic pattern used in many IoT systems:
Sense → Process → Transmit → Visualize
Possible Applications
Once this basic system is working, it can be extended into several projects.
Object Detection
Use the IR sensor to detect whether an object is present.
Object Counter
Use repeated IR events to count objects moving through a particular location.
Smart Door
Use an IR sensor as part of an automatic door or entry-monitoring system.
Industrial Monitoring
Multiple sensors can be connected to an ESP8266 and their values can be sent to different channels.
Automation
The sensor value can be combined with IoT logic to trigger another device or action.
Possible Improvements
The current project is intentionally simple, but there are several ways to improve it.
1. Add a graphical widget
Instead of displaying only 0 or 1, the dashboard could show the sensor state using an indicator or status widget.
2. Add alerts
An alert could be triggered when the IR sensor detects an object.
3. Add multiple sensors
For example:
This would turn the project into a small multi-sensor IoT monitoring system.
4. Add automation
The IR sensor could become an input for an IoT automation workflow.
For example:
Troubleshooting
The Serial Monitor always shows 1
Check the IR sensor's potentiometer and detection range.
Different IR modules use different output logic, so check whether your particular module outputs LOW or HIGH when an object is detected.
The Serial Monitor always shows 0
Check:
- IR sensor VCC
- GND
- OUT connection
- GPIO pin definition
- Sensor detection range
Make sure the sensor OUT pin is actually connected to D2.
The dashboard doesn't update
Check:
- ESP8266 Wi-Fi connection.
- KiwisIoT topic.
- Channel ID.
- KiwisIoT widget configuration.
- Whether kiwisiot.run() is continuously called.
The channel used in the Arduino code and the channel configured in the dashboard must match.
For this project:
Final Result
After completing the project, I was able to read the IR sensor using the NodeMCU ESP8266 and send the value to a KiwisIoT dashboard.
The final setup looks like:
This is a very simple project, but it demonstrates the fundamental architecture behind a connected IoT device.
For anyone starting with ESP8266 + sensors + IoT dashboards, I think this is a good project to understand the complete flow from a physical sensor to a web-based visualization.