Connecting Internet of Things to the Cloud with MQTT

By Leon Anavi

MQTT is a lightweight publish/subscribe machine-to-machine protocol with a reliable bi-directional communication which provides near real-time notifications of events. The protocol is very convenient for Internet of Things as it has a small footprint and can run on devices with a constrained hardware capabilities such as the low cost WiFi micro controller ESP8266.

In this talk Leon Anavi and Arthur Chan will provide an overview of the protocol and its advanced features for web sockets, security, last will and testament. The presentation will provide guidelines for deployment to the cloud of popular open source MQTT brokers such as Mosquitto, HiveMQ and Mosca. Furthermore you will learn how to take advantage of open source MQTT clients implemented in various programming languages using the Paho project, writing your own Node.js, C or Lua MQTT client. The presentation will provide examples of MQTT on powerful embedded devices powered by both GNU/Linux distributions on Intel, ARM, MIPS SoC as well as on the cheap Wifi development module ESP8266.


Date & Time
Day 2 (25th June) 13:35 - 14:05
Function Room 3
Internet of Things
English (with English Slides)
Target Audience
Developers, IT Managers

MQTT is a one of the popular messaging protocols for use on top of the TCP/IP protocol. It is convenient for near real time communication between Internet of Things. MQTT was invented in 1999 and initially it was used internally only by IBM. In 2010 version 3.1 was released royalty free and nowadays there are a lot of open source software MQTT brokers and clients.

The most popular open source MQTT brokers are Mosquitto, HiveMQ, ActiveMQ and Mosca. Mosquitto is an Eclipse incubating project and it is written in the C programming language. HiveMQ is written in Java and it know as a enterprise MQTT broker. Mosca is popular among web developers as it is written in JavaScript.

MQTT implements the publish-subscribe messaging pattern using a broker. All clients connect to the broker and subscribe to different topics. Each client is capable of publishing messages. The broker is responsible for delivering messages to subscribed clients. The work flow of a MQTT client is first to establish a connection with MQTT broker and after that to subscribe to a topic. At this point the client will receive messages from the broker depending on their topics. Furthermore, the client is capable of publishing messages at any time. Each MQTT message contains a topic which is used by the broker to forward it to the interested clients. Typically, the message also has a payload that could be a binary data, plain text, JSON, XML or anything else defined by the developer.

The Last Will and Testament (LWT) is an advanced MQTT feature to notify other clients about an ungracefully disconnected client. Upon connecting to the broker each client can specify MQTT message which will be its last will. The broker will store the message until it detects that the client has disconnected ungracefully. This way the developer can understand when Internet of Things have disappeared unexpectedly. Furthermore popular MQTT brokers also support web sockets so web developers can expose data instantly to HTML5 web pages.

Security if very important topic for Internet of Things. MQTT supports transport layer security (TLS/SSL) and authentication with username and password. Authorization policies can be implemented using access control lists. There is module for Mosquitto which allows integration with NoSQL and SQL databases.

Leon Anavi

Photo of Leon Anavi
Konsulko Group


Engineer and an open source enthusiast. He works for Konsulko Group and he is the author of the Tizen Cookbook printed by Packt Publishing. Leon is a co-maintainer of Tizen on Yocto and a contributor to a lot of open source projects. His professional experience includes web and mobile application development for various platforms as well as porting Tizen to devices with i.MX6, Rockchip and Allwinner (aka sunxi) SoC. Leon holds a masters in Information Technology from Technical University Sofia. His previous speaking experience includes talks about open source software during events in San Francisco, Hong Kong, Shanghai, Shenzhen, Brussels, Bratislava, Sofia and his hometown Plovdiv.