Wednesday, December 18, 2024
How ToIoT HardwaresIoT ProtocolsRaspberry PiTutorials/DIY

How to Install Mosquitto Broker on Raspberry Pi

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.

Read More Mosquitto MQTT broker | Install Broker in AWS | Setting Up

Recommended:

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:

pi@raspberry:~ $ sudo apt update
pi@raspberry:~ $ 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:

pi@raspberry:~ $ sudo systemctl enable mosquitto.service

Testing Installation

Open terminal and write command:

pi@raspberry:~ $ 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:

pi@raspberry:~ $ 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.


 

Harshvardhan Mishra

Hi, I'm Harshvardhan Mishra. Tech enthusiast and IT professional with a B.Tech in IT, PG Diploma in IoT from CDAC, and 6 years of industry experience. Founder of HVM Smart Solutions, blending technology for real-world solutions. As a passionate technical author, I simplify complex concepts for diverse audiences. Let's connect and explore the tech world together! If you want to help support me on my journey, consider sharing my articles, or Buy me a Coffee! Thank you for reading my blog! Happy learning! Linkedin

9 thoughts on “How to Install Mosquitto Broker on Raspberry Pi

Leave a Reply

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