Zbotic Logo Zbotic Logo
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

  • Shop
  • About Us
  • Contact Us
  • Reseller
  • Blogs
020 69134444
1800 209 0998
[email protected]
Help Desk
Facebook Twitter Instagram Linkedin YouTube
Zbotic Logo Zbotic Logo
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

All departments
  • 3D Print Service
  • 3D Printer
  • Batteries & Chargers
  • Development Boards
  • Drone Parts
  • EBike parts
  • Sensor Modules
  • Electronic Components
  • Electronic Modules
  • IoT and Wireless
  • Mechanical Parts and Workbench Tools
  • Motors & Drivers & Pumps & Actuators
  • DIY and Robot Kits
  • Show more
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
Return to previous page
Home Communication & Wireless Modules

MQ Telemetry Transport: ESP8266 MQTT with Node-RED Dashboard

MQ Telemetry Transport: ESP8266 MQTT with Node-RED Dashboard

March 11, 2026 /Posted byJayesh Jain / 0

MQTT (MQ Telemetry Transport) is the lightweight messaging protocol that powers the Internet of Things, and combining it with ESP8266 MQTT Node-RED dashboard gives you a professional-grade real-time monitoring system on zero budget. Indian engineering students, makers, and small businesses are increasingly turning to this stack because it is completely free, runs on a ₹150 Wi-Fi module, and produces beautiful, interactive dashboards accessible from any browser. This guide walks you through every step — from installing a local MQTT broker to publishing sensor data from the ESP8266 and visualising it on a live Node-RED dashboard.

Table of Contents

  1. Understanding MQTT: Topics, Brokers, and QoS
  2. Setting Up Mosquitto MQTT Broker
  3. Installing Node-RED and the Dashboard Plugin
  4. ESP8266 Hardware and Sensor Wiring
  5. Arduino IDE Sketch for ESP8266 MQTT Publisher
  6. Building the Node-RED Dashboard Flow
  7. Using a Cloud MQTT Broker (HiveMQ Free)
  8. Frequently Asked Questions

Understanding MQTT: Topics, Brokers, and QoS

MQTT is a publish/subscribe protocol designed for constrained devices and unreliable networks — exactly what IoT devices face. Three core concepts:

  • Broker: A central server (like Mosquitto) that receives published messages and routes them to subscribers. Think of it as a post office.
  • Topics: Hierarchical address strings like home/room1/temperature. Publishers push data to a topic; subscribers receive data from that topic.
  • QoS levels:
    • QoS 0 — At most once (fire and forget, no acknowledgement)
    • QoS 1 — At least once (broker acknowledges receipt)
    • QoS 2 — Exactly once (handshake ensures no duplicates)

For most ESP8266 sensor dashboards, QoS 1 is the right choice — reliable delivery without the overhead of QoS 2’s four-way handshake. MQTT over TCP uses port 1883; over TLS it uses 8883.

Why MQTT over HTTP REST (like Firebase)? MQTT uses a persistent TCP connection and has just a 2-byte fixed header overhead, while HTTP adds hundreds of bytes of headers per request. For sensors publishing every 500ms, this difference in bandwidth and battery life is significant.

Setting Up Mosquitto MQTT Broker

Mosquitto is the most widely used open-source MQTT broker. Install it on Windows, Linux, or a Raspberry Pi:

On Ubuntu/Debian/Raspberry Pi:

sudo apt update
sudo apt install mosquitto mosquitto-clients -y
sudo systemctl enable mosquitto
sudo systemctl start mosquitto

On Windows:

Download the Mosquitto installer from mosquitto.org/download and run it. Add C:Program Filesmosquitto to your PATH.

Basic Configuration

Edit /etc/mosquitto/mosquitto.conf (Linux) or mosquitto.conf (Windows) to allow connections from other devices on your network:

listener 1883 0.0.0.0
allow_anonymous true

Restart Mosquitto after editing. Test with the included CLI tools:

# In terminal 1 — subscribe:
mosquitto_sub -h localhost -t "test/topic" -v

# In terminal 2 — publish:
mosquitto_pub -h localhost -t "test/topic" -m "Hello MQTT"

If terminal 1 shows test/topic Hello MQTT, your broker is working correctly.

Installing Node-RED and the Dashboard Plugin

Node-RED is a browser-based visual programming tool built on Node.js. Install it on the same machine as your Mosquitto broker (or a Raspberry Pi):

# Install Node.js (if not already installed)
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs

# Install Node-RED globally
sudo npm install -g --unsafe-perm node-red

# Start Node-RED
node-red

Access the Node-RED editor at http://localhost:1880. Install the dashboard plugin:

  1. Click the hamburger menu (top right) → Manage palette.
  2. Go to the Install tab and search for node-red-dashboard.
  3. Click Install. This adds gauge, chart, text, button, and slider nodes.

Your dashboard will be accessible at http://localhost:1880/ui.

Ai-Thinker ESP32-C3-12F Module

Ai-Thinker ESP32-C3-12F Wi-Fi + BLE Module

An affordable Wi-Fi + BLE module compatible with the ESP8266 MQTT workflow — upgrade to ESP32-C3 for more RAM and better MQTT library support.

View on Zbotic

ESP8266 Hardware and Sensor Wiring

This tutorial uses a NodeMCU ESP8266 board (most common in India) and a DHT11 sensor. NodeMCU has a built-in USB-to-serial converter, making programming straightforward.

DHT11 Pin NodeMCU Pin
VCC 3.3V
DATA D4 (GPIO2) with 10kΩ pull-up to 3.3V
GND GND

If your DHT11 module already has a built-in pull-up resistor (most breakout boards do), you can connect DATA directly to D4 without an external resistor.

Required libraries in Arduino IDE:

  • ESP8266 board package (URL: http://arduino.esp8266.com/stable/package_esp8266com_index.json)
  • PubSubClient by Nick O’Leary (MQTT library)
  • DHT sensor library by Adafruit
  • ArduinoJson by Benoit Blanchon (for structured JSON payloads)
0.96 Inch I2C OLED Module

0.96 Inch I2C IIC OLED LCD Module 4pin White SSD1306 Chip

Pair an OLED with your ESP8266 MQTT node to display broker connection status and last sensor values locally alongside the Node-RED dashboard.

View on Zbotic

Arduino IDE Sketch for ESP8266 MQTT Publisher

This sketch connects the ESP8266 to Wi-Fi and the Mosquitto broker, then publishes temperature and humidity as a JSON payload every 5 seconds:

#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <DHT.h>
#include <ArduinoJson.h>

#define WIFI_SSID   "Your_WiFi_SSID"
#define WIFI_PASS   "Your_WiFi_Password"
#define MQTT_SERVER "192.168.1.100"  // Your broker IP
#define MQTT_PORT   1883
#define MQTT_TOPIC  "home/room1/climate"

#define DHTPIN  2   // D4 = GPIO2 on NodeMCU
#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);
WiFiClient espClient;
PubSubClient client(espClient);

void connectWiFi() {
  WiFi.begin(WIFI_SSID, WIFI_PASS);
  Serial.print("Connecting to Wi-Fi");
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("nConnected: " + WiFi.localIP().toString());
}

void reconnectMQTT() {
  while (!client.connected()) {
    Serial.print("Connecting to MQTT...");
    if (client.connect("ESP8266_Sensor")) {
      Serial.println("connected!");
    } else {
      Serial.print("failed, rc=");
      Serial.print(client.state());
      Serial.println(" retrying in 5s");
      delay(5000);
    }
  }
}

void setup() {
  Serial.begin(115200);
  dht.begin();
  connectWiFi();
  client.setServer(MQTT_SERVER, MQTT_PORT);
}

void loop() {
  if (!client.connected()) reconnectMQTT();
  client.loop();

  static unsigned long lastMsg = 0;
  if (millis() - lastMsg > 5000) {
    lastMsg = millis();

    float temp = dht.readTemperature();
    float hum  = dht.readHumidity();

    if (!isnan(temp) && !isnan(hum)) {
      StaticJsonDocument<128> doc;
      doc["temperature"] = round(temp * 10.0) / 10.0;
      doc["humidity"]    = round(hum  * 10.0) / 10.0;
      doc["device"]      = "esp8266_room1";

      char payload[128];
      serializeJson(doc, payload);
      client.publish(MQTT_TOPIC, payload, true); // retained message
      Serial.println(String("Published: ") + payload);
    }
  }
}

The true flag in client.publish() sets the message as retained — the broker remembers the last value and immediately delivers it to any new subscriber, so your dashboard shows the latest reading instantly on refresh rather than waiting for the next publish cycle.

Building the Node-RED Dashboard Flow

Now create the visual dashboard in Node-RED:

  1. Add an MQTT-in node: Drag it from the left panel. Double-click to configure: Server = localhost:1883, Topic = home/room1/climate, Output = a parsed JSON object.
  2. Add a function node after MQTT-in to extract individual values:
    msg.payload = msg.payload.temperature;
    return msg;
  3. Add a Gauge node from the Dashboard section: Label = “Temperature”, Unit = “°C”, Range 0–50.
  4. Repeat steps 2–3 for humidity with range 0–100%.
  5. Add a Chart node connected after MQTT-in to show a time-series graph of both values.
  6. Click Deploy (top right red button).
  7. Open http://localhost:1880/ui to see your live dashboard.

You can export the complete flow as JSON and import it in other Node-RED instances. The dashboard is mobile-responsive by default — open it on your phone’s browser for a portable IoT monitor.

Waveshare ESP32-S3 AMOLED Display Board

Waveshare ESP32-S3 1.43inch AMOLED Display Development Board 466×466

Upgrade your MQTT sensor node with this gorgeous AMOLED display — show live data locally while simultaneously publishing to Node-RED dashboard over MQTT.

View on Zbotic

Using a Cloud MQTT Broker (HiveMQ Free)

If you want your dashboard accessible from anywhere without port forwarding, use a free cloud MQTT broker. HiveMQ Cloud offers a free tier with up to 100 connections:

  1. Sign up at hivemq.com and create a free cluster.
  2. Note your cluster URL (e.g., abc123.s1.eu.hivemq.cloud) and port 8883 (TLS).
  3. Create credentials in the HiveMQ dashboard (username + password).

Update your ESP8266 sketch for TLS connection:

#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <PubSubClient.h>

WiFiClientSecure espClient;
PubSubClient client(espClient);

void setup() {
  // ...
  espClient.setInsecure(); // Skip cert verification (for testing only)
  client.setServer("abc123.s1.eu.hivemq.cloud", 8883);
}

// In reconnectMQTT():
client.connect("ESP8266_Device", "hivemq_user", "hivemq_pass");

In Node-RED, update the MQTT-in server to the HiveMQ URL with port 8883 and enable TLS + credentials. Your dashboard is now cloud-accessible from any browser worldwide.

0.96 Inch SPI OLED Module Blue

0.96 Inch SPI OLED LCD Module 6pin Blue SSD1306 Chip

Add local feedback to your MQTT node — display connection status, topic, and last published values on this compact SPI OLED display.

View on Zbotic

Frequently Asked Questions

Q: What is the difference between MQTT and HTTP for IoT sensor data?

HTTP is a request-response protocol — the client always initiates. MQTT is publish-subscribe — the broker pushes new data to subscribers immediately. For real-time dashboards, MQTT is far more efficient because the connection stays open (no TCP handshake overhead per message) and latency is under 10ms for local networks versus 50–200ms for HTTP REST calls.

Q: Can I run Mosquitto and Node-RED on a Raspberry Pi 3?

Yes, easily. A Raspberry Pi 3B with Raspberry Pi OS Lite runs both services using less than 200MB of RAM, leaving plenty of headroom. The Raspberry Pi can then act as an always-on home automation hub alongside the MQTT broker and Node-RED.

Q: How do I secure my Mosquitto broker with a password?

Create a password file: sudo mosquitto_passwd -c /etc/mosquitto/passwd myuser. Then add to your config: password_file /etc/mosquitto/passwd and set allow_anonymous false. Update your ESP8266 sketch to pass username and password in the client.connect() call.

Q: My PubSubClient drops connection frequently. How do I fix it?

Call client.setKeepAlive(60) before connecting. Increase the keepalive interval and ensure your loop() calls client.loop() at least once per second. Also set client.setSocketTimeout(10) to prevent blocking. Frequent drops on ESP8266 often also indicate weak Wi-Fi signal — move the board closer to the router or add an external antenna.

Q: Can Node-RED send a WhatsApp or Telegram message when a threshold is crossed?

Yes. Install node-red-contrib-telegrambot from the palette manager. Create a Telegram bot via BotFather, then in your flow add a switch node to check if temperature exceeds your threshold, followed by a Telegram sender node. This lets your ESP8266 MQTT data trigger Telegram alerts through Node-RED with no additional coding.

Start Your MQTT IoT Project

Get ESP8266 NodeMCU boards, sensors, and display modules from Zbotic — quality components with fast shipping across India for your next IoT build.

Shop Wi-Fi Modules

Tags: esp8266, IoT Dashboard, Mosquitto, MQTT, Node-RED
Share Post
  • Facebook
  • Linkedin
  • Whatsapp
Differential Amplifier Using O...
blog differential amplifier using op amp design and applications 597220
blog ir remote control build a custom tv remote with arduino 597222
IR Remote Control: Build a Cus...

Related posts

Svg%3E
Read more

ESP-NOW: Direct ESP32-to-ESP32 Communication Without WiFi

April 1, 2026 0
ESP-NOW ESP32 communication is a game-changing protocol developed by Espressif that enables direct peer-to-peer wireless communication between ESP32 boards without... Continue reading
Svg%3E
Read more

SDR Getting Started: HackRF and RTL-SDR Projects India

April 1, 2026 0
Software Defined Radio (SDR) lets you explore the electromagnetic spectrum using your computer, replacing expensive hardware radios with affordable USB... Continue reading
Svg%3E
Read more

Zigbee vs WiFi vs BLE: Choosing the Right Wireless Protocol for IoT

April 1, 2026 0
Choosing between Zigbee vs WiFi vs BLE for your IoT project is one of the most important design decisions you... Continue reading
Svg%3E
Read more

RFID Module Guide: RC522, PN532, and Long-Range UHF Options

April 1, 2026 0
The RFID module RC522 Arduino combination is the starting point for thousands of access control, attendance, and inventory tracking projects... Continue reading
Svg%3E
Read more

RS485 Modbus Communication: Industrial Sensors with Arduino

April 1, 2026 0
RS485 Modbus Arduino interfacing opens the door to industrial-grade sensor communication. Unlike hobbyist I2C or SPI sensors, RS485 Modbus sensors... Continue reading

Add comment Cancel reply

Your email address will not be published. Required fields are marked

Facebook Twitter Instagram Pinterest Linkedin Youtube

Get the latest deals and more.

Download on Google Play Download on the App Store

Call us: 020 69134444 / 1800 209 0998

Monday - Saturday 09:30 AM - 06:00 PM
For Technical Supports Email: [email protected]
For Sales / Enquiries Email: [email protected]

  • My Account

    • Cart

    • Wishlist

    • Checkout

    • My Orders

    • Track Order

    • My Account

  • Information

    • FAQs

    • Blogs

    • Career

    • About Us

    • Contact Us

    • Payment Options

  • Policies

    • Privacy Policy

    • Terms & Conditions

    • GST Input Tax Credit

    • Shipping Return Policy

    • E-Waste Collection Points

    • Our Sitemap

© Zbotic.in is registered trademark of Moxie Supply Pvt Ltd – All Rights Reserved
Login
Use Phone Number
Use Email Address
Not a member yet? Register Now
Reset Password
Use Phone Number
Use Email Address
Register
Already a member? Login Now