Using the MQTT API – Atmosphere IoT

Using the MQTT API


 

Atmosphere currently supports v3.1.1 of the MQTT protocol which will allow you to send device events to Atmosphere IoT managed devices and also recieve cloud events as well.

 

Connecting to MQTT Server

 

You can simply connect with any supported MQTT client to the hostname “mqtt.atmosphereiot.com” to subscribe to and publish on MQTT topics.

Authentication will be required by passing your device’s ID as the username and the device’s token as the password to connect.

 

Sending Device Events

 

A device can send device events from your device my publishing data on the following topic.

atmosphere/events//device/

You can send an event along with data to all of the Device Event elements in your project by simply dropping the element name in the MQTT topic path like so

atmosphere/events//device

All data published to this topic will then be processed by your device’s cloud plane by triggering the “Event Recieved” on your specified Device Event Element with the data sent to this topic.

 

Example with mosquitto_pub

 

To use this example you will need to download and install the mosquitto clients from mosquitto.org

mosquitto_pub -h
mqtt.atmosphereiot.com -u -P -t
atmosphere/events//device/ NAME> -m "Data" -p 8883 --capath /etc/ssl/certs

 

Receiving Cloud Events

 

Just as before but instead of publishing to the device topic we subscribe to the cloud topic using the following topic

atmosphere/events//cloud/

Just like the Device Events you can remove the Cloud Event name from the path and get cloud events from all Cloud Event elements in your project like the following,

atmosphere/events//cloud

 

Example with mosquitto_sub

 

mosquitto_sub -h
mqtt.atmosphereiot.com -u -P -t
atmosphere/events//cloud/ NAME> -p 8883 --capath /etc/ssl/certs