MQTT is a lightweight publish-subscribe protocol for exchanging messages. nRF Cloud is built on AWS and uses the MQTT broker in AWS IoT Core to process MQTT messages sent and received over MQTT topics.
The publish-subscribe process over MQTT is as follows:
- A device, or the MQTT client running in the modem, connects to the nRF Cloud MQTT endpoint.
- The device publishes a JSON message on a topic.
- The MQTT broker receives the message. If a rule is specified, the rule is run, and if the rule's criteria are met, it triggers an action. Typical actions might include storing a message in a database or republishing a subset of the data to another topic.
MQTT connection information
To acquire the MQTT broker hostname, call the
FetchAccountInfo endpoint. This method requires you to use the REST API. The JSON response includes two fields, the
mqttTopicPrefix. The endpoint is always the same for nRF Cloud operations. The topic prefix is unique to your team, as in the following example:
If you do not want to use the REST API to get this information, you can also form the
mqttTopicPrefix using your Team ID:
- Log in to the nRF Cloud portal.
- Click the drop-down menu in the upper right corner.
- Click Teams.
- Find the Team ID under the team name.
- The value of
- Use this value when calling the MQTT API.
In addition to AWS core topics, nRF Cloud includes MQTT topics for its own operations.