ESP32 Multi-Interface Smart Edge Node Using MQTT and UART
by ayush4514be23 in Circuits > Electronics
11 Views, 0 Favorites, 0 Comments
ESP32 Multi-Interface Smart Edge Node Using MQTT and UART
This project demonstrates a smart IoT edge node developed using the ESP32-WROOM microcontroller and DHT22 temperature-humidity sensor. The system performs real-time environmental monitoring and simultaneously transmits data using MQTT over WiFi and UART serial communication.
Humidity data is published to an MQTT broker for cloud-based monitoring, while temperature data is displayed locally using UART serial communication. The project demonstrates multi-protocol IoT communication, embedded networking, and real-time telemetry systems using low-cost hardware.
Supplies
ESP32-WROOM
DHT22 Sensor
Breadboard
Jumper Wires
USB Cable
WiFi Network
Hardware Components
In this project, the ESP32-WROOM microcontroller is used as the central processing unit, while the DHT22 sensor is used for temperature and humidity sensing.
The ESP32 provides:
- Built-in WiFi
- UART communication
- GPIO control
- MQTT networking support
Circuit Connections
ESP32 3.3V → DHT22 VCC
ESP32 GND → DHT22 GND
ESP32 GPIO23 → DHT22 DATA
10kΩ pull-up resistor connected between VCC and DATA
Working Principle
The ESP32 continuously reads temperature and humidity values from the DHT22 sensor.
Humidity data is transmitted to an MQTT broker over WiFi for cloud monitoring.
Temperature data is simultaneously transmitted through UART communication for local monitoring using RealTerm.
This demonstrates simultaneous local and remote communication using embedded IoT architecture.
MQTT Communication
MQTT Communication
MQTT (Message Queuing Telemetry Transport) is a lightweight communication protocol widely used in Internet of Things (IoT) systems. It follows a publish-subscribe architecture, where devices publish data to a broker and clients subscribe to receive the data.
In this project, the ESP32 connects to a WiFi network and establishes communication with a public MQTT broker. The DHT22 sensor continuously measures humidity values, which are then published to the MQTT topic periodically.
The MQTT Explorer application is used to subscribe to the topic and visualize the transmitted sensor data in real time.
Workflow
- ESP32 connects to WiFi
- ESP32 connects to MQTT broker
- DHT22 sensor data is acquired
- Humidity values are published to MQTT topic
- MQTT Explorer receives and displays the data
Advantages of MQTT
- Lightweight communication protocol
- Low bandwidth usage
- Real-time data transmission
- Efficient for embedded IoT systems
- Supports cloud-based monitoring
MQTT Broker Used
A public MQTT broker is used for testing and monitoring sensor data transmission.
Real-Time Monitoring
The MQTT Explorer dashboard displays:
- Humidity values
- Device information
- Topic structure
- Timestamped telemetry data
This demonstrates successful cloud-based IoT communication using ESP32 and WiFi networking.
UART Communication
UART Communication
UART (Universal Asynchronous Receiver Transmitter) is a serial communication protocol commonly used for debugging, monitoring, and communication between embedded systems.
In this project, UART communication is used for local monitoring of temperature data acquired from the DHT22 sensor.
The ESP32 continuously sends temperature readings through the serial interface. The RealTerm serial terminal application receives and displays the transmitted data in real time.
Workflow
- ESP32 initializes UART communication
- Temperature values are read from DHT22 sensor
- Data is transmitted serially through UART
- RealTerm receives and displays the values
UART Configuration
- Baud Rate: 115200
- Data Bits: 8
- Stop Bits: 1
- Parity: None
Advantages of UART
- Simple serial communication protocol
- Useful for debugging embedded systems
- Real-time local monitoring
- Reliable point-to-point communication
Real-Time Serial Monitoring
The RealTerm terminal displays:
- Temperature values
- Continuous sensor updates
- Serial communication status
UART communication provides a simple and effective way to monitor embedded sensor data locally while MQTT communication handles remote cloud-based transmission.
Source Code
https://github.com/ayush4514be23-prog/STM32-IoT-Application-Development-Lab/tree/3b7e82b93c6e065e848b08f51b900bc25cdef873/evaluations/LabEval4/src
Downloads
Results
The system successfully demonstrated:
- Real-time temperature and humidity monitoring
- MQTT communication over WiFi
- UART serial transmission
- Embedded IoT telemetry
- Simultaneous cloud and local monitoring
FUTURE IMPROVEMENTS
Future improvements may include:
- Cloud dashboard integration
- Mobile app monitoring
- Sensor data logging
- Real-time alerts
- Multi-sensor expansion