Real-Time Distance Monitoring With ESP8266 and KiwisIoT
by prakatheeshwaranR in Circuits > Arduino
37 Views, 0 Favorites, 0 Comments
Real-Time Distance Monitoring With ESP8266 and KiwisIoT
In this project, I built a simple IoT-based distance monitoring system using a NodeMCU ESP8266, HC-SR04 ultrasonic sensor, and KiwisIoT platform. The main idea was to measure the distance of an object and make that information available online in real time.
The HC-SR04 ultrasonic sensor detects the distance between the sensor and the object. The ESP8266 reads the sensor data, calculates the distance in centimeters, and sends the result to the KiwisIoT cloud platform through Wi-Fi. Once the data is uploaded, it can be viewed and monitored easily from the KiwisIoT dashboard.
This project is a simple way to understand how sensors, ESP8266, Wi-Fi, and IoT cloud platforms can work together to create a real-time monitoring system.
Supplies
NodeMCU ESP8266 – 1
HC-SR04 Ultrasonic Sensor – 1
Jumper Wires – Female to-Female
USB Cable – 1
Computer/Laptop – for programming the ESP8266
Wi-Fi Connection – for sending data to KiwisIoT
KiwisIoT Account – for viewing the distance data online
Arduino IDE – for programming the NodeMCU
How the Project Works
The HC-SR04 ultrasonic sensor sends out a short ultrasonic pulse and waits for it to bounce back from an object. The NodeMCU measures how long the echo takes to return and uses that time to calculate the distance.
Once the distance is calculated, the ESP8266 sends the reading to the KiwisIoT platform over Wi-Fi. This makes it possible to monitor the measured distance remotely from the KiwisIoT dashboard.
For example, if an object is placed about 30 cm away, the sensor will measure the distance and the KiwisIoT dashboard should display a value close to 30 cm.
Circuit Connections
The HC-SR04 is connected to the NodeMCU as follows:
- VCC → VIN
- GND → GN
- TRIG → D5
- ECHO → D6
Since the HC-SR04 ECHO pin can output 5V and the ESP8266 GPIO works at 3.3V, I use a voltage divider on the ECHO connection to protect the NodeMCU.
Programming the ESP8266
Testing the Project
The process starts with the HC-SR04 ultrasonic sensor, which sends out a short ultrasonic pulse toward the object. When the pulse hits the object, it reflects back to the sensor.
The NodeMCU measures the time taken for the echo to return and uses this information to calculate the distance of the object in centimeters.
Once the distance is calculated, the NodeMCU connects to the internet through Wi-Fi using the ESP8266. The measured distance is then sent to the KiwisIoT platform, where it can be viewed on the dashboard in real time.
This allows us to easily monitor the distance between the sensor and the object from the KiwisIoT dashboard.
Future Improvements
In the future, this project can be made more useful by adding features such as:
- Distance alerts when an object comes too close to the sensor.
- Real-time graphs to track how the distance changes over time.
- Mobile notifications to receive alerts directly on a phone.
- Multiple ultrasonic sensors to monitor different areas at the same time.
- Automatic object detection and monitoring for more advanced applications.
- Data storage and analysis to study distance measurements over a longer period.
Conclusion
This project successfully demonstrates how an HC-SR04 ultrasonic sensor can be used to measure the distance of an object. The NodeMCU reads the sensor data, calculates the distance, and sends the measured value to the KiwisIoT cloud platform through Wi-Fi. The distance can then be viewed in real time on the KiwisIoT dashboard.
By working on this project, I gained a better understanding of how ultrasonic sensors detect objects, how the ESP8266 processes sensor readings, and how data can be transmitted to an IoT cloud platform. Overall, this project gave me practical experience in connecting sensors, microcontrollers, Wi-Fi, and cloud-based IoT services