MQTT is an Internet of Things connectivity protocol. It was designed as an extremely lightweight publish/subscribe messaging transport. It is useful for connections with remote locations where a small code footprint is required and/or network bandwidth is at a premium"

(Source: MQTT.org).

MQTT is specially useful to push data from the cloud to your devices. Imagine a cloud-controlled device to open/close a door remotely. In the case of HTTP, the device would have to continuously make GET requests to the Ubidots server to see if there’s a change in a variable, say "Door Control Variable", and then take an action depending on the last reading. This takes a lot of requests and it’s not entirely a real-time interaction since it depends of the polling frequency. With MQTT, the device can "listen" to the cloud and only get notified when there’s a change in the variable. This way, the connection between the device and the cloud is left open but data only travels when is necessary, saving battery, network bandwidth and improving the real-time experience.

In this section you will find the documentation needed to handle your devices with Ubidots over MQTT.

Quality of Service

In MQTT, the quality of service, QoS for short, guarantees the delivery of a specific message. There are three leves of QoS:

0, At most once: This level does not guarantee the message delivery, it would be labeled as best-effort server QoS.

1, At least once: This level guarantees that the message is delivered at least one time to the receiver. The receiver answer with a puback packet, if this puback packet is not received the sender sends again the message.

2, Exactly once: Guarantees that the message is received only once by the receptor. It is the slowest packet interchange QoS as it requires two request/response flows.

📘

QoS in Ubidots

Ubidots supports QoS up to 1 (at least once).