New: the AI firewall watches every module and explains each incident in plain words. See how it works

Which MQTT topic should my device publish telemetry to?

Which MQTT topic should my device publish telemetry to?

1 2

I have a small ESP32 sensor and want to send temperature and humidity to Hermetry over MQTT. Which broker address, credentials and topic do I use, and what does the JSON payload look like?

Edge gateways all day.
♥ 0

Connection

  • Host: use the broker host shown on the device's Connection details card. You can also read it from the REST API: GET /api/iot/devices/{deviceId}/connection returns the MQTT host and port, the HTTPS base and the topics.
  • Port: use 8883 (TLS).
    • Plain port 1883 works only if the device profile turns on Plain MQTT.
    • That setting is off by default, so a login on 1883 is refused unless someone enables it.
  • Protocol: MQTT 3.1.1. An MQTT 5 CONNECT is refused with CONNACK 1.
  • Session settings: send clean session = true and use MQTT keepalive.
  • TLS:
    • TLS 1.2 minimum, 1.3 preferred.
    • SNI is required, so connect by host name, not by IP address.
    • Verify the server certificate against your normal CA bundle and the host name.
    • Small devices like an ESP32 may ask for 4 KB TLS records (max_fragment_length).

Credentials (access token, the default login)

  • Client ID: any valid ID: 1–64 characters from A–Z a–z 0–9 . _ : -
  • Username: the device access token
  • Password: empty

A CONNECT without a username is refused. When a device is created via POST /api/iot/devices, the access token is returned only once, so store it then.

Topic

Publish telemetry to v1/telemetry. Anything else under v1/ that isn't a known topic is rejected. Three rejected topics in a minute close the session.

Payload

Any of these forms works:

  • A flat object:
{"temperature": 21.5, "humidity": 40}
  • An object with a timestamp in milliseconds:
{"ts": 1759572000000, "values": {"temperature": 21.5, "humidity": 40}}
  • An array of either form.

If the connection is refused

  • 4 (bad username or password): Back off for at least 5 minutes
  • 5 (not authorised): Back off with the long schedule

The reason behind code 5 is not sent to the device. It is written to the device's Log.

Sources

Written by AI from the documentation and solved topics. If it solved your problem, mark it as the solution; if not, the team will follow up.

♥ 0
Viewing 2 posts – 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Join the conversation

Sign in to ask and answer, like helpful posts and mark the reply that solved your problem. Every contribution earns points and levels.

Share