This guide describe How to install Mosquitto in Raspberry Pi. Mosquitto MQTT Broker is most popular MQTT Broker.
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 MQTT Broker ?
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, which we will describe below. Mosquitto is part of the Eclipse Foundation and is an iot.eclipse.org project.
Mosquitto is highly portable and available for a wide range of platforms. Go to the dedicated download page to find the source or binaries for your platform.
Mosquitto provides a Public MQTT Broker for testing purpose.
|info||web page, Xively statistics, topics and HTTP bridge|
How to Install Mosquitto on Raspberry Pi
After having your Raspberry Pi board prepared with Raspbian OS, you can continue with this tutorial. Let’s install the Mosquitto Broker.
if you have a Headless Pi and need guide for installation. visit this : Raspberry Pi Headless mode setup
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
Now You can find 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.
Thanks for reading. If you like this post probably you might like my next ones, so please support me by subscribing my blog.
You may like also: