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 Arduino & Microcontrollers

ESP32 MQTT: Publish Sensor Data to Cloud Dashboards

ESP32 MQTT: Publish Sensor Data to Cloud Dashboards

April 1, 2026 /Posted by / 0

Esp32 Mqtt Sensor Cloud — this detailed tutorial covers everything from hardware selection to complete working code, designed for Indian makers, students, and engineers.

Table of Contents

  • Understanding MQTT Protocol for IoT
  • Setting Up MQTT on ESP32
  • Sending JSON Sensor Data
  • Free Cloud Dashboards for MQTT Data
  • QoS Levels and Security
  • Setting Up a Local Mosquitto Broker
  • Frequently Asked Questions

Understanding MQTT Protocol for IoT

MQTT (Message Queuing Telemetry Transport) is the de facto standard for IoT communication. It uses a publish/subscribe model where devices publish messages to topics, and interested clients subscribe to those topics. An MQTT broker (server) routes messages between publishers and subscribers. MQTT is lightweight — a minimal packet is just 2 bytes — making it perfect for ESP32 and ESP8266 devices with limited bandwidth. Popular free brokers include Mosquitto (self-hosted), HiveMQ Cloud (free tier: 100 connections), and EMQX Cloud.

🛒 Recommended: Waveshare ESP32-S3 1.46inch Round Display Development Board, 412×412, Support… — Add a visual display to your ESP32 project.

Setting Up MQTT on ESP32

Install the PubSubClient library from Arduino IDE Library Manager:

#include <WiFi.h>
#include <PubSubClient.h>

const char* ssid = "Your_WiFi";
const char* password = "Your_Password";
const char* mqtt_server = "broker.hivemq.com";

WiFiClient espClient;
PubSubClient client(espClient);

void reconnect() {{
  while (!client.connected()) {{
    if (client.connect("ESP32_Zbotic")) {{
      client.subscribe("zbotic/commands");
    }} else {{
      delay(5000);
    }}
  }}
}}

void callback(char* topic, byte* payload, unsigned int length) {{
  String message;
  for (int i = 0; i < length; i++) message += (char)payload[i];
  Serial.printf("Topic: %s Message: %sn", topic, message.c_str());
}}

void setup() {{
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) delay(500);
  client.setServer(mqtt_server, 1883);
  client.setCallback(callback);
}}

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

  static unsigned long lastMsg = 0;
  if (millis() - lastMsg > 5000) {{
    lastMsg = millis();
    client.publish("zbotic/temperature", "28.5");
  }}
}}

Sending JSON Sensor Data

Real-world IoT applications send structured JSON payloads. Use ArduinoJson library to build clean JSON messages with sensor readings, device ID, timestamp, and status fields. Subscribe to command topics to receive instructions from the dashboard — like changing sampling rate or toggling outputs.

🛒 Recommended: Waveshare ESP32-S3 1.47inch Display Development Board, 172×320, 262K Color, U… — Add a visual display to your ESP32 project.

Free Cloud Dashboards for MQTT Data

Several free options exist for visualising MQTT data:

  • Node-RED Dashboard: Self-hosted, drag-and-drop flow editor with built-in MQTT nodes and dashboard widgets
  • ThingsBoard Community Edition: Open-source IoT platform with device management and dashboards
  • Grafana + InfluxDB: Store MQTT data in InfluxDB via Telegraf, visualise in Grafana (free self-hosted)
  • MQTT Explorer: Desktop app for debugging MQTT topics during development

QoS Levels and Security

MQTT offers three QoS (Quality of Service) levels: QoS 0 (at most once, fire-and-forget), QoS 1 (at least once, may duplicate), and QoS 2 (exactly once, highest overhead). For sensor data, QoS 0 is usually sufficient. For critical commands (like turning off a motor), use QoS 1. Always use TLS encryption (port 8883) for production deployments. Free brokers like HiveMQ Cloud support TLS by default.

Setting Up a Local Mosquitto Broker

For privacy-sensitive applications, run your own MQTT broker on a Raspberry Pi or old laptop. Install Mosquitto on Ubuntu with sudo apt install mosquitto mosquitto-clients. Configure authentication and TLS for security. A Raspberry Pi 4 can handle thousands of connected ESP32 devices on a local network.

🛒 Recommended: Waveshare ESP32-S3 1.69inch Display Development Board, 240MHz Dual-Core Proce… — Add a visual display to your ESP32 project.

Frequently Asked Questions

Is MQTT free to use?

The MQTT protocol itself is open and free. Brokers can be self-hosted (Mosquitto, free) or cloud-hosted (HiveMQ free tier: 100 devices, EMQX free tier: 1M messages/month). For small Indian IoT projects, free tiers are usually sufficient.

Can ESP32 use MQTT over cellular/GSM?

Yes, if you add a SIM800L or SIM7600 module for cellular connectivity. The MQTT library works over any TCP connection, regardless of whether it is WiFi, Ethernet, or cellular.

What is the difference between MQTT and HTTP for IoT?

MQTT is bidirectional, lightweight, and maintains a persistent connection — ideal for real-time control. HTTP is request-response only, heavier, and creates a new connection each time. Use MQTT for live dashboards and control, HTTP for periodic data uploads to APIs.

Conclusion

The ESP32 platform continues to impress with its versatility and value for money. This project demonstrates just one of hundreds of applications possible with affordable microcontrollers. Indian makers have a unique advantage — access to affordable components, a growing community, and endless real-world problems to solve with technology. Whether you are building this for learning, a college project, or a commercial product prototype, the fundamentals covered here will serve you well.

Ready to start building? Browse our ESP32 development boards at Zbotic for the best prices in India with fast shipping!

Tags: Cloud, ESP32, iot, MQTT
Share Post
  • Facebook
  • Linkedin
  • Whatsapp
Membrane Keypad 4×4: Inte...
blog membrane keypad 4x4 interface with arduino 613084
blog tesla coil build musical singing tesla coil 613088
Tesla Coil Build: Musical Sing...

Related posts

Svg%3E
Read more

Arduino Batch Programming: Flash Multiple Boards Quickly

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... Continue reading
Svg%3E
Read more

Arduino Based Radar System with Ultrasonic Sensor

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... Continue reading
Svg%3E
Read more

Arduino Automatic Plant Monitor: Sunlight, Moisture, Temperature

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... Continue reading
Svg%3E
Read more

Arduino Lie Detector: GSR Sensor Polygraph Project

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... Continue reading
Svg%3E
Read more

Arduino Metal Detector: Build a Treasure Finder

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... 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