What is MQTT?
MQTT stands for Message Queuing Telemetry Transport.
MQTT is a lightweight publish/subscribe messaging protocol designed for M2M (machine to machine) telemetry in low bandwidth environments.
- It is designed for constrained devices with low bandwidth. So, it’s the perfect solution to exchange data between multiple IoT devices.
- It was designed by Andy Stanford-Clark (IBM) and Arlen Nipper in 1999 for connecting Oil Pipeline telemetry systems over satellite.
- It was released Royalty free in 2010 and became an OASIS standard in 2014.

What Port does MQTT Normally Use?
The standard port that MQTT use is 1883.
Can you use MQTT without a broker?
No you will need a Broker.
There are many MQTT brokers available that you can use for testing and for real applications.
There are free self hosted brokers , the most popular being Mosquitto and commercial ones like HiveMQ.
Mosquitto MQTT Broker
Mosquitto is a lightweight open source message broker that Implements MQTT versions 3.1.0, 3.1.1 and version 5.0
How to Install The Mosquitto MQTT Broker on Raspberry Pi
wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
sudo apt-key add mosquitto-repo.gpg.key
Then make the repository available to apt:
cd /etc/apt/sources.list.d/
sudo wget http://repo.mosquitto.org/debian/mosquitto-buster.list
apt-get update
apt-get install mosquitto
Upgrading
sudo apt-get update
sudo apt-get install mosquitto
sudo apt-get install mosquitto-clients
Running
sudo apt-get install mosquitto
Stopping and Starting
Mosquitto is installed as a service and should start automatically after install
To Stop and start the service you needed to use
sudo service mosquitto stop
sudo service mosquitto start #see note later
Next we will see how to use it in IOT projects.