ESP32 MQTT Publish and Subscribe with Node-RED and Mosquitto
Implement MQTT publish/subscribe protocol with ESP32 to communicate with Node-RED dashboard and Mosquitto broker for IoT data exchange.
- Suitable forB.Tech IoT students
- Build time2-3 weeks
- LevelIntermediate
- Available atAjvika Labs, Kakinada
About this project
Implements MQTT publish/subscribe pattern with ESP32 as client and Mosquitto as broker. ESP32 publishes temperature and humidity from DHT22 to topics: home/temperature, home/humidity every 10 seconds. ESP32 subscribes to home/relay to receive on/off commands from Node-RED dashboard. Node-RED flow: MQTT-in nodes receive sensor data, dashboard gauge and chart widgets display values, button widget sends commands. Features: last will and testament (LWT) so broker knows if ESP32 disconnects, retained messages, QoS levels (0, 1, 2). Reconnect logic: ESP32 automatically reconnects to broker after WiFi/broker disconnection. Secure MQTT: TLS encryption and username/password authentication. Mosquitto installation: sudo apt install mosquitto mosquitto-clients. Libraries: PubSubClient, WiFi, DHT, ArduinoJson.
Detailed Project Description
ESP32 MQTT Publish and Subscribe with Node-RED and Mosquitto connects an embedded device to the network so its data can be viewed and its outputs controlled from a browser, app or cloud service.
How It Works
1. The device joins the network and registers with the server/cloud (or hosts its own web page).
2. Sensor values are published and outputs are controlled through HTTP, MQTT, BLE or a cloud SDK.
3. A web/app front-end shows live values in gauges and charts and offers control buttons.
4. Data is stored for history and the firmware can be updated over the air where supported.
Key Components and Their Role
- ESP32: dual-core Wi-Fi + Bluetooth microcontroller that runs the firmware, reads the sensors and hosts the network connection.
- DHT22: digital temperature and humidity sensor with better accuracy than DHT11.
- Relay module: electrically isolated switch that lets the controller turn AC/DC loads on and off.
- MQTT: lightweight publish/subscribe messaging protocol used for IoT data.
- Node-RED: flow-based tool used to build the dashboard and automation logic.
Implementation Steps
1. Collect the components and study each module's datasheet (pin-out, voltage, interface).
2. Wire the circuit on a breadboard following the pin mapping; power sensors from the correct rail (3.3 V / 5 V).
3. Install Arduino IDE, PubSubClient Library, Mosquitto Broker and the required libraries; flash a minimal test sketch for each module separately.
4. Write the main firmware: read sensors → process → drive outputs / send data.
5. Configure network or cloud credentials and test communication end-to-end.
6. Calibrate thresholds, add error handling (reconnect, sensor time-out) and run a long-duration test.
7. Finalise on a PCB / enclosure and document wiring, code and results.
Key Features
- Live data in the browser/app
- Remote control
- History storage
- Secure access
Expected Output
On completion the student will have a responsive web/app dashboard reflecting the device state in real time.
Deliverables
- Complete source code with comments
- Circuit diagram and pin mapping
- Project report with screenshots and results
- Demonstration-ready build
Detailed Project Description
ESP32 MQTT Publish and Subscribe with Node-RED and Mosquitto connects an embedded device to the network so its data can be viewed and its outputs controlled from a browser, app or cloud service.
How It Works
1. The device joins the network and registers with the server/cloud (or hosts its own web page).
2. Sensor values are published and outputs are controlled through HTTP, MQTT, BLE or a cloud SDK.
3. A web/app front-end shows live values in gauges and charts and offers control buttons.
4. Data is stored for history and the firmware can be updated over the air where supported.
Key Components and Their Role
- ESP32: dual-core Wi-Fi + Bluetooth microcontroller that runs the firmware, reads the sensors and hosts the network connection.
- DHT22: digital temperature and humidity sensor with better accuracy than DHT11.
- Relay module: electrically isolated switch that lets the controller turn AC/DC loads on and off.
- MQTT: lightweight publish/subscribe messaging protocol used for IoT data.
- Node-RED: flow-based tool used to build the dashboard and automation logic.
Implementation Steps
1. Collect the components and study each module's datasheet (pin-out, voltage, interface).
2. Wire the circuit on a breadboard following the pin mapping; power sensors from the correct rail (3.3 V / 5 V).
3. Install Arduino IDE, PubSubClient Library, Mosquitto Broker and the required libraries; flash a minimal test sketch for each module separately.
4. Write the main firmware: read sensors → process → drive outputs / send data.
5. Configure network or cloud credentials and test communication end-to-end.
6. Calibrate thresholds, add error handling (reconnect, sensor time-out) and run a long-duration test.
7. Finalise on a PCB / enclosure and document wiring, code and results.
Key Features
- Live data in the browser/app
- Remote control
- History storage
- Secure access
Expected Output
On completion the student will have a responsive web/app dashboard reflecting the device state in real time.
Deliverables
- Complete source code with comments
- Circuit diagram and pin mapping
- Project report with screenshots and results
- Demonstration-ready build
Technologies used
Hardware components
- ESP32 DevKit
- DHT22 Sensor
- Relay Module
- Breadboard
Software & tools
- Arduino IDE
- PubSubClient Library
- Mosquitto Broker
- Node-RED Dashboard
What you get
- Working project / hardware kit, tested before delivery
- Complete source code with explanation
- Project demo and guidance for your viva
- Project report, PPT and IEEE paper support (on request)
Delivery & Payment
Delivery takes a minimum of two weeks from the date your inquiry is confirmed.
Payment is in two parts:
• 50% advance to start the project
• Remaining 50% before delivery
Note:
• Documentation and PPT are not included by default
• If you need documentation/PPT, it can be arranged for extra time and cost
We'll confirm the exact timeline and cost with you after reviewing your requirements.