MQTT (Message Queue Telemetry Transport) is a communications protocol that is commonly used in IoT for exchanging messages between a device and a server. It is used by millions of sensors and devices all over the world for sending data to servers or receiving commands.
MQTT is a client-server protocol. The MQTT broker is the server in a MQTT network and communicates with MQTT clients. MQTT clients send data to a MQTT broker by PUBLISHING messages to a TOPIC and receive data by SUBSCRIBING to a TOPIC.
MQTT Protocol Workflow
Here are 3 reasons you might want to use MQTT and 1 reason not to.
Lightweight and efficient – Once a connection is established, MQTT sends far fewer bytes per message than HTTP. This is important when connectivity costs are high or difficult (satellite, dial-up, infrequent availability, etc.).
Battery and low power microcontroller friendly – MQTT can run on even small microcontrollers without the need for an RTOS. Compared with HTTPS, MQTT enables 93 times higher mobile throughput using 11 times less battery to send and 170 times less battery to receive.
Variable Quality of Service (QoS) – If you have a sensor that sends atmospheric temperature information every few minutes, it might be acceptable if some of the data doesn’t make it through. Typically, the higher the quality of service, the greater the overhead (processing power, communications overhead). MQTT allows you to tag a message with 1 of 3 levels of QoS - 0: At most deliver once, 1: At least deliver once, 2: Deliver exactly once. If you are controlling a mission-critical device, you will likely choose QoS 2. If you are setting up a weather station at home or have an extremely reliable connection (i.e. – wired Ethernet), QoS 0 may work just fine. Oh, and what about QoS 1? If you want to know for sure that the message got through and your application can handle duplicate messages, QoS 1 may be a good compromise.
So why wouldn’t you use MQTT?
Video - MQTT is just not the right protocol for transmitting video. If cameras are key to your system, look to other protocols to send and receive video content.
Another protocol worth considering is CoAP. It has several interesting capabilities that are described and compared to MQTT here. There are many other possible protocols to choose from but after careful research, you may just find MQTT is the right one for your unique application.
コメント