Skip to content

Device Integration Overview

This section is for device and firmware developers integrating hardware with EMQX Fleets. It covers how devices connect, authenticate, and exchange data with the Fleets backend.

Two Integration Paths

Devices can communicate with Fleets over MQTT or HTTPS (or both).

MQTTHTTPS
Connection typeLong-lived, bidirectionalPer-request, request-response only
Receive cloud-to-device messagesYes (subscribe to topics)No push; poll using GET requests
Offline message queueYes (with persistent MQTT session)No
Shadow updatesReceived via delta topic subscriptionPoll via GET /api/v1/thing-datas/{thingName}/shadow
CommandsReceived via command topic subscriptionNot supported for inbound commands
Jobs notificationsReceived via jobs/notify topicPoll using POST /api/v1/thing-datas/jobs/get
Reporting state / eventsPublish to MQTT topicsPOST to ThingDatas API endpoints
Protocol overheadLowHigher (TLS handshake per request)
SDK requiredMQTT client libraryStandard HTTP client

Use MQTT if the device needs to receive commands, shadow desired state, or job notifications pushed from the cloud. This is the recommended path for most IoT devices.

Use HTTPS if the device only needs to report data (events, shadow state) and can poll for desired state changes. Suitable for constrained devices or environments where persistent TCP connections are impractical.

Device Identity

Before a device can communicate with Fleets, it must be registered as a Thing. Two identity fields are relevant for device communication:

FieldUsed for
Thing name{thingName} in all MQTT system topics and in ThingDatas API request bodies
MQTT Client IDThe MQTT CONNECT packet Client ID; used for lifecycle event tracking

These values may be the same or different. Use the Thing name consistently in topic paths and API payloads.

Authentication

MQTT Connection to EMQX Broker

Devices connect to the EMQX Broker associated with your Fleets deployment using standard MQTT authentication. Refer to your deployment's connection settings for the host, port, and credentials.

HTTPS (ThingDatas API)

All /api/v1/thing-datas/* endpoints require authentication. Use a Deployment API Key with Basic Auth:

text
Authorization: Basic <base64(apiKey:apiSecret)>

See Manage API Keys to create an API key for device use.

MQTT System Topics

All Fleets system topics use the $emqx/ prefix. Custom telemetry topics (if configured) use application-defined paths.

Topic patternDirectionPurpose
$emqx/things/{name}/shadow/updateBidirectionalShadow state (desired from cloud; reported from device)
$emqx/things/{name}/shadow/update/deltaCloud → DeviceDelta notification
$emqx/things/{name}/events/{type}Device → CloudEvents (QoS 1)
$emqx/commands/things/{name}/executions/{id}/requestCloud → DeviceCommand request
$emqx/commands/things/{name}/executions/{id}/responseDevice → CloudCommand response
$emqx/things/{name}/jobs/notifyCloud → DevicePending jobs changed
$emqx/things/{name}/jobs/notify-nextCloud → DeviceNext pending job changed
$emqx/things/{name}/jobs/getDevice → CloudRequest pending jobs list
$emqx/things/{name}/jobs/start-nextDevice → CloudStart next pending job
$emqx/things/{name}/jobs/{jobId}/getDevice → CloudGet a specific job execution
$emqx/things/{name}/jobs/{jobId}/updateDevice → CloudReport job execution status

Next Steps

  • MQTT Integration: Full MQTT setup, subscriptions, publish formats, and flow diagrams for shadow, commands, and jobs
  • HTTPS Integration: ThingDatas API reference for devices using HTTPS only
  • Device Shadow Sync: Step-by-step shadow synchronization flow from the device perspective