In this post you’re going to How to Install Mosquitto Broker on Raspberry Pi.
What is a MQTT broker?
MQTT Broker is a central server or middle-ware which act as an interface between publisher & subscriber and used to collect the data from the publisher device and send it to the subscribers device. A device wants to send data to the broker, it is called a publisher and a device wants to receive data from the broker, it is called as subscriber
What is Mosquitto ?
Eclipse Mosquitto is an open source (EPL/EDL licensed) message broker that implements the MQTT protocol versions 3.1 and 3.1.1. It is one of the most famous MQTT broker. Its very easy to install and easy to use. It is lightweight and is suitable for use on all devices from low power single board computers to full servers. The MQTT protocol provides a lightweight method of carrying out messaging using a publish/subscribe model. This makes it suitable for Internet of Things messaging such as with low power sensors or mobile devices such as phones, embedded computers or microcontrollers. The Mosquitto project also provides a C library for implementing MQTT clients, and the very popular mosquitto_pub and mosquitto_sub command line MQTT clients. Its can be installed on Unix machines. It can be secured via SSL and passwords.
After having your Raspberry Pi board prepared with Raspbian OS, you can continue with this tutorial. Let’s install the Mosquitto Broker.
How to Install Mosquitto Broker on Raspberry Pi (Raspbian OS)
Open a new Raspberry Pi terminal window:
To install the Mosquitto Broker enter these next commands:
[email protected]:~ $ sudo apt update [email protected]:~ $ sudo apt install -y mosquitto mosquitto-clients
You’ll have to type Y and press Enter to confirm the installation. To make Mosquitto auto start on boot up enter:
[email protected]:~ $ sudo systemctl enable mosquitto.service
Open terminal and write command:
[email protected]:~ $ mosquitto -v
This returns the Mosquitto version that is currently running in your Raspberry Pi.
Note: sometimes the command mosquitto -v prompts a warning message saying “Error: Address already in use“. That warning message means that your Mosquitto Broker is already running, so don’t worry about that.
How To Find IP Address
To use Mosquitto broker later on your projects, you’ll need your Raspberry Pi IP address. To retrieve your Raspberry Pi IP address, type the next command in your Terminal window:
[email protected]:~ $ hostname -I
In our case, the Raspberry Pi IP address is 192.168.1.121. Save your Raspberry Pi IP address because you’ll need it in future projects.
Do you have any questions? Leave a comment down below!
Thanks for reading. If you like this post probably you might like my next ones, so please support me by subscribing my blog.