Install Mosquitto in Raspberry Pi | Mosquitto broker

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.

fieldvalue
addresstest.mosquitto.org
port1883, 8883 (SSL), 8884 (SSL), 80 (WebSockets)
typemosquitto
infoweb 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

Testing Installation

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:

Harshvardhan Mishra

Hi, I'm Harshvardhan Mishra. I am a tech blogger and an IoT Enthusiast. I am eager to learn and explore tech related stuff! also, I wanted to deliver you the same as much as the simpler way with more informative content. I generally appreciate learning by doing, rather than only learning. Thank you for reading my blog! Happy learning! Follow and send tweets me on @harshvardhanrvm. If you want to help support me on my journey, consider sharing my articles, or Buy me a Coffee!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this:
satta king tw