Linux Format

What is MQTT?

-

MQTT stands for Message Queue Telemetry Transport and it works as a lightweigh­t messaging protocol for use on top of the TCP/IP protocol. MQTT is an ideal choice for working with devices that have limited network bandwidth, as it can even be used with a dial-up internet connection. The first version of MQTT was authored in 1999 by Andy Stanford-Clark and Arlen Nipper and since then it has been used in home automation projects, sensor networks and to control Christmas tree lights from across the world.

As we mentioned at the start of the tutorial, MQTT is a machine-to-machine protocol that enables devices to publish and subscribe to ‘topics’ that are of interest. In our project we created a small network where one Publisher sent data to a Broker which distribute­d messages to clients, called Subscriber­s, who reacted to a particular topic of data.

MQTT is not just limited to Python, in fact by installing the MQTT packages for Linux we can send and receive data from our terminal. To install MQTT open a terminal and type: $ sudo apt install mosquitto mosquitto-clients

So if you wanted to have your Linux desktop subscribe to the “temp” data in this project we would have to run. $ mosquitto_sub -d -h 192.168.0.13 -t temp The switches are as follows: -d Debug mode, this shows every error and step taken by the MQTT client. -h Specifies the IP address of the Broker. -t The topic that we wish to subscribe to. You can read more about MQTT by browsing over to http://mqtt.org.

Newspapers in English

Newspapers from Australia