MQTT Broker Guide (HiveMQ Cloud)
Full guide on how to setup DecentIoT with HiveMQ RTDB + Auth.
MQTT is recommended for device connectivity because it's lightweight and well supported. This guide uses HiveMQ Cloud (free tier available).
If you prefer firebase, skip to the Firebase Guide.
Create HiveMQ Cloud account
-
Go to HiveMQ Cloud → Sign up.
-
Create a new cluster (free tier). Select region and finish.
Create Credentials
-
In the cluster dashboard → Credentials → create a username/password pair for your device(s).
-
Copy & Note the credentials:
-
host
(e.g.,xxxx.hivemq.cloud
) -
port
(usually8883
for TLS,1883
for non-TLS) -
username
andpassword
-
-
If using WebSockets, note the
ws
path (often/mqtt
) and use port8883
or443
as configured.
Enable WebSocket/TLS as needed
- For device firmware on the web or browser clients, enable WebSocket support. For embedded devices use TLS on
8883
.
Topic Naming Convention (recommended)
Use a consistent hierarchical topic scheme:
-
Device → Server (device publishes sensor data / state)
decentiot/<projectId>/<deviceId>/toServer
-
Server → Device (server publishes commands)
decentiot/<projectId>/<deviceId>/toDevice
-
Optional admin/announce topics:
-
decentiot/<projectId>/broadcast
(for broadcast messages) -
decentiot/<projectId>/<deviceId>/lwt
(last will/testament)
-
Example payloads
-
From server to device (command):
{ "widget": "led1", "type": "boolean", "value": 1, "ts": 169### // unix ms timestamp }
-
From device to server (state update):
{ "deviceId": "esp32-01", "state": { "led1": 1, "temp": 27.3 }, "ts": 169### // unix ms timestamp }
Test your broker
-
Use the HiveMQ WebSocket client (in HiveMQ Console) or MQTT Explorer / MQTT.fx to test subscribe/publish.
-
Subscribe to
decentiot/+/+/toDevice
and publish a test JSON to see it arrive.