Install MQTT

Summary of what you are going to install:

  1. MQTT

Summary of the commands:

sudo apt install mosquitto
sudo apt install mosquitto-clients
sudo service mosquitto status
sudo service mosquitto start
sudo service mosquitto stop
sudo service mosquitto restart
mosquitto_sub -h localhost -t livingroom
mosquitto_pub -h localhost -t livingroom -m "hello

Installation of MQTT is quite easy. You can easily install it via apt. After installation, MQTT will be enabled even after reboot.

Here are the steps:

Step 1 – Install Mosquito

sudo apt install mosquitto 
sudo apt install mosquitto-clients

Step 2 – Check the status of Mosquito

sudo service mosquitto status

Step 3 – Control Mosquito

Control mosquito service via the following commands:

sudo service mosquitto start
sudo service mosquitto stop
sudo service mosquitto restart
sudo service mosquitto status

Step 4 – Create publishers/subscribers to test Mosquito

All subscribers of a topic receive automatically all messages published to the same topic:

mosquitto_sub -h localhost -t livingroom
mosquitto_pub -h localhost -t livingroom -m "hello"

References:

Leave a Reply