How to install MQTT Broker on Raspberry Pi | IoT Server | Getting Started and Testing

Опубликовано: 01 Декабрь 2024
на канале: Electrofun
494
9

In this video, I have explained how you can install MQTT Mosquitto Broker on Raspberry Pi. I have given a background on what is MQTT and tested it using Windows MQTTBox software

Hope you like it !!

*Installing Mosquitto Broker on Raspberry Pi*

1) Boot your Raspberry Pi, Open SSH terminal or VNC Viewer and Login into your RPI

2) Run the following command to upgrade and update your system

sudo apt update && sudo apt upgrade

It is always good to update and upgrade. This step will take time depending on what is installed and updated.

3) To install the Mosquitto Broker enter these next command

sudo apt install -y mosquitto mosquitto-clients

5) To make Mosquitto auto start when the Raspberry Pi boots, you need to run the following command

sudo systemctl enable mosquitto.service

This command will automatically start Mosquitto Broker on Raspberry Pi boot

6) To check the installation, run the following command to check the Mosquitto Broker version

mosquitto -v

This returns the Mosquitto version that is currently running on your Raspberry Pi



*Broker Enable Remote Access/ Authentication*

*****************************************************************
*No Authentication Process*

1) Edit the file mosquitto.conf

Go to the root directory of the file sudo nano /etc/mosquitto/mosquitto.conf

2) Add these lines at the end

allow_anonymous true #Allow any node to connect with the broker - without any authentication
listener 1883 #Defining the listener port

Save and Exit

3) Restart the Mosquitto Broker

sudo systemctl restart mosquitto

This will reflect the changes done the config file


********************************************************************

*Authentication Process*

1) Run the following command

sudo mosquitto_passwd -c /etc/mosquitto/PASSWORD USERNAME

This will allow you to add a new username by creating a folder in /etc/mosquitto directory.
As soon as you type it, it will ask you for the password that will be hidden


2) Edit the file mosquitto.conf

Go to the root directory of the file sudo nano /etc/mosquitto/mosquitto.conf

3) Add these lines at the end

allow_anonymous false #Allow specific nodes to connect with the broker - with authentication
listener 1883 #Defining the listener port
password_file /etc/mosquitto/PASSWORD

Save and Exit

3) Restart the Mosquitto Broker

sudo systemctl restart mosquitto

This will reflect the changes done to the config file


Informative Website - https://mosquitto.org/man/mosquitto_s...

-----------------------------------------------------------------------------------------------------------

You can support my channel at-- Paytm: +91-8655761125

Paypal: https://paypal.me/electrofunedu

-----------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------
Some of my other videos are:

What is MQTT | How it works? | IoT Projects | Features and Comparison
   • What is MQTT | How it works? | IoT Pr...  

How to Install MQTT Mosquitto Broker in Windows | IoT Development | Publish-Subscribe messaging
   • How to Install MQTT Mosquitto Broker ...  

How to Install MQTT Mosquitto Broker Software in Windows | IoT Development
   • How to Install MQTT Mosquitto Broker ...  

How to Install Anydesk on Raspberry Pi | Remote Control & Access
   • How to Install Anydesk on Raspberry P...  

DHT22 Temperature and Humidity Interfacing with Arduino | Digital One wire sensor
   • DHT22 Temperature and Humidity Interf...  

MLX90614 Arduino Tutorial | Non-contact Temperature sensor | I2C Protocol | Infrared Sensor
   • MLX90614 Arduino Tutorial | Non-conta...  

-----------------------------------------------------------------------------------------------------------