{"slug": "esp32-self-hosted-iot-platform-your-first-mqtt-message-in-15-minutes", "title": "ESP32 Self-Hosted IoT Platform: Your First MQTT Message in 15 Minutes", "summary": "The ThingBoot project published a guide showing how to connect a stock ESP32 to a self-hosted Mosquitto MQTT broker in about 15 minutes, using either the ThingBoot ESP Arduino SDK or plain Arduino with PubSubClient. The walkthrough covers publishing telemetry to topics like things/esp32-demo/telemetry and receiving commands back, with a Docker one-liner for launching the broker and mosquitto_sub/mosquitto_pub commands for testing. The project says a planned follow-up will let AI agents control devices via MCP.", "body_md": "*This article is cross-posted from the [ThingBoot Guides](https://github.com/Kevin-ThingBoot/thingboot-guides) repository on GitHub, where you'll also find the [Chinese version](https://github.com/Kevin-ThingBoot/thingboot-guides/blob/main/guides/01-esp32-mqtt-platform.zh-CN.md).*\n\nMost ESP32 tutorials stop at \"blink an LED\". Real products need the next step:\n\nget your device talking to a platform you **own** — not someone else's cloud.\n\nThis guide walks you from a stock ESP32 to publishing telemetry and receiving\n\ncommands over MQTT against a self-hosted broker. It takes about 15 minutes.\n\n``` php\n[ESP32] --WiFi--> [MQTT Broker (self-hosted)] ---> [Your apps / dashboards / AI agents]\n         <-------- (commands, OTA triggers) ------\n```\n\nSelf-hosting the broker means: your data stays on your network, you control\n\nauth, and AI agents can talk to devices through the same topics later.\n\nThe fastest way to get a local broker:\n\n```\ndocker run -d -p 1883:1883 --name mosquitto eclipse-mosquitto\n```\n\nThen create a minimal `mosquitto.conf` allowing local testing:\n\n```\nlistener 1883\nallow_anonymous true\n```\n\nFor production: always enable auth + TLS. See the [OTA & safe-mode guide](https://github.com/Kevin-ThingBoot/thingboot-guides/blob/main/guides/02-esp32-ota-production.md).\n\nInstall the [ThingBoot ESP Arduino SDK](https://github.com/ThingBoot/thingboot-device-esp-arduino-sdk),\n\nwhich wraps WiFi provisioning, MQTT reconnect, and OTA into a setup()/loop()\n\nmodel. Or use plain Arduino with PubSubClient — the flow is the same:\n\n```\n#include <WiFi.h>\n#include <PubSubClient.h>\n\nWiFiClient net;\nPubSubClient mqtt(net);\n\nvoid setup() {\n  Serial.begin(115200);\n  WiFi.begin(\"YOUR_SSID\", \"YOUR_PASSWORD\");\n  while (WiFi.status() != WL_CONNECTED) delay(500);\n\n  mqtt.setServer(\"192.168.1.100\", 1883);   // your broker's LAN IP\n  mqtt.setCallback([](char* topic, byte* payload, unsigned int len) {\n    Serial.printf(\"command received on %s: %.*s\\n\", topic, len, (char*)payload);\n  });\n}\n\nvoid loop() {\n  if (!mqtt.connected()) mqtt.connect(\"esp32-demo\");\n  mqtt.loop();\n\n  static uint32_t last = 0;\n  if (millis() - last > 5000) {\n    last = millis();\n    mqtt.publish(\"things/esp32-demo/telemetry\",\n                 \"{\\\"temp\\\":25.5,\\\"rssi\\\":-60}\");\n  }\n}\n```\n\nSubscribe from your computer and watch data arrive:\n\n```\nmosquitto_sub -h 192.168.1.100 -t \"things/#\" -v\n```\n\nThen send a command back to the device:\n\n```\nmosquitto_pub -h 192.168.1.100 -t \"things/esp32-demo/cmd\" -m '{\"relay\":\"on\"}'\n```\n\nIf you see telemetry flowing and the device reacting to commands — congratulations,\n\nthat's the entire foundation of an IoT fleet: **device → platform → device**.\n\n| Goal | Guide | \n|---|---|\n| OTA updates for production fleets (A/B partitions, rollback, safe mode) | [Part 2](https://github.com/Kevin-ThingBoot/thingboot-guides/blob/main/guides/02-esp32-ota-production.md) | \n| Letting an AI agent control devices via MCP | Part 3 (planned) | \n| Full SDK with provisioning + rollback | [ThingBoot SDKs](https://github.com/ThingBoot) | \n\n*ThingBoot provides free device SDKs and a self-hosted IoT platform.\nQuestions? Open an [issue](https://github.com/Kevin-ThingBoot/thingboot-guides/issues).*", "url": "https://wpnews.pro/news/esp32-self-hosted-iot-platform-your-first-mqtt-message-in-15-minutes", "canonical_source": "https://dev.to/kevin-thingboot/esp32-self-hosted-iot-platform-your-first-mqtt-message-in-15-minutes-4i6p", "published_at": "2026-11-06 04:42:53+00:00", "updated_at": "2026-11-06 04:54:33.521813+00:00", "lang": "en", "topics": ["ai-agents", "agent-protocols", "developer-tools"], "entities": ["ThingBoot", "ESP32", "Mosquitto", "PubSubClient", "Arduino", "MCP", "Docker"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/esp32-self-hosted-iot-platform-your-first-mqtt-message-in-15-minutes", "markdown": "https://wpnews.pro/news/esp32-self-hosted-iot-platform-your-first-mqtt-message-in-15-minutes.md", "text": "https://wpnews.pro/news/esp32-self-hosted-iot-platform-your-first-mqtt-message-in-15-minutes.txt", "jsonld": "https://wpnews.pro/news/esp32-self-hosted-iot-platform-your-first-mqtt-message-in-15-minutes.jsonld"}}