Skip to main content
Skip to footer
Search
Connect
Watch fullscreen
Like
Comments
Bookmark
Share
Add to Playlist
Report
ESP8266 as MQTT Broker | How to Setup Basic MQTT Broker in NodeMCU ESP8266 using sMQTTBroker Library
Fusion Automate
Follow
9/4/2024
------------------------------------------------------------
Website: https://fusionautomate.in
Telegram: https://t.me/fusion_automate_admin
Telegram Group: https://t.me/fusionautomate
WhatsApp: https://wa.me/message/B7RXUT4OUXWUF1
WhatsApp Group: https://chat.whatsapp.com/DW7K2yo3ee52mtG4ODTvtc
Instagram: https://instagram.com/fusion_automate
LinkedIn: https://www.linkedin.com/company/fusion-automate
GitHub: https://github.com/papercodeIN
Join this channel to get access to perks: https://www.youtube.com/channel/UCKKhdFV0q8CV5vWUDfiDfTw/join
------------------------------------------------------------
Category
🤖
Tech
Transcript
Display full video transcript
00:00
Hi everyone and
00:02
Welcome in this video. We will see ESP8266 as an MQTT broker
00:07
So if you have a NodeMCU or also you can say ESP8266 and you want to use that board as MQTT broker
00:15
Then how you can use it?
00:16
So instead of using Mosquitto MQTT broker, Hive MQTT broker or EMQX broker or Nano MQTT broker
00:23
You can use your NodeMCU board as an MQTT broker. So that thing we are going to cover in this video
00:29
So we are going to use SMQTT broker library to create MQTT broker in the ESP8266 board
00:36
I have ESP8266 board connected with my system and we will see how you can program your ESP8266
00:43
To work as a MQTT broker. So let me show you the diagram
00:47
So here we have our ESP8266 board in the center working as MQTT broker
00:53
So any of your MQTT client can connect with that ESP8266 MQTT broker and they can exchange the data
01:00
Now our ESP8266 board will connect with the Wi-Fi
01:03
Okay
01:04
And your Python MQTT client, NodeMQTT client connect with the same Wi-Fi and they can exchange data
01:10
Using this ESP8266 MQTT broker. So I hope the diagram or the basic detail is clear
01:17
Now let's move to the Arduino IDE and let's see SMQTT broker is installed in my system or not
01:23
So here is the Arduino IDE and here I'm going to check that SMQTT broker is installed or not
01:29
So yes, we have the SMQTT broker in my system. Okay, and
01:34
NodeMCU is already connected with my system. So I am going to the example. Okay, and in the example
01:40
We will search for SMQTT folder
01:43
Okay here you can see SMQTT folder and I'm going to select the simple MQTT broker
01:49
Example, so we will click here and we will open our simple MQTT broker example
01:54
Okay, so here is our example now if you want to use this example
01:59
Then you have to change two things first your Wi-Fi SSID and second your Wi-Fi password
02:04
So if you want to use your NodeMCU board as MQTT broker
02:08
Then first of all, we will connect our NodeMCU board with the Wi-Fi
02:12
So other client can connect with the same Wi-Fi and they can use our ESP8266 as MQTT broker
02:19
So first of all, we have to make connection with the Wi-Fi and then we can you know run the MQTT broker inside it
02:26
So this is the entire code. Okay
02:28
So in this code it will first connect with the Wi-Fi and then it will run the MQTT broker on the port number
02:35
1883 if you want to change the port then you can change the port number here and you can change your MQTT broker port
02:42
From 1883 to any other TCP port number. Okay
02:47
Now I'm going to provide my Wi-Fi SSID and the password and then we will upload this sketch into my NodeMCU board
02:54
Okay, I have changed my Wi-Fi SSID and password and here is the MQTT broker port number
02:59
So what I'm going to do is I am just going to upload this sketch into my NodeMCU board as you can see it is
03:05
Already selected here
03:16
Okay, so we have successfully uploaded our sketch into our ESP8266 board and here is the serial monitor
03:23
I'm going to press the reset button on my NodeMCU
03:27
And
03:29
Here you can see the IP address. Okay, so this is the IP address of my NodeMCU board
03:33
And we can use this IP address and 1883 port to connect with this NodeMCU MQTT broker
03:40
So I can open my MQTT Explorer software. Okay, which is MQTT client software
03:47
so I'm going to add new connection and it's my NodeMCU and
03:53
The IP address of my NodeMCU is 192.168.1.9
03:58
I am going to provide it here and here is the port number 1883, which is default in this example
04:04
Okay, 1883. So I'm going to leave it as it is
04:07
We will save it. Okay, and we will click on connect and here you can see we are connected
04:12
Also, I'm going to again open the MQTT Explorer as my second MQTT client
04:17
Okay, and here is our
04:21
Connection. Okay. I'm going to change the client ID here. Okay, and then I'm going to connect
04:27
So we are connected. Okay, our both the client is connected with our NodeMCU MQTT broker
04:34
So basically we have uploaded the sketch into our NodeMCU board and then after it will
04:39
Started acting as an MQTT broker. So I have this MQTT Explorer software in my system
04:45
So I have opened two instance of this software and both instance are connected with ESP8266 board
04:52
Okay, and now they are ready to exchange the data. So if I publish some data to any topic
04:59
Okay, then on the second client we are able to receive that data
05:03
So second second client is a subscriber. Now. The first client is the publisher now
05:08
Now we can use our second client as a publisher
05:11
so we are going to select the test topic and then we will publish some data from this second client and
05:16
Our first client will receive that data. So our first client will act as a subscriber and our second client will act as a
05:23
Publisher. Okay. So now you can use your
05:28
NodeMCU board as an MQTT broker with n number of MQTT client and then you can exchange the data
05:34
So if you are working in the home automation
05:36
Or if you want to read any sensor data via Wi-Fi in your mobile phone in your tablet in your laptop or in your desktop
05:42
Then you can use your ESP8266 board as an MQTT broker. Okay, it can be your central MQTT broker to
05:51
Exchange the data. Okay. So this is how you can use your NodeMCU board as an MQTT broker
05:56
So all you have to do is you just have to install this SMQTT broker library in your Arduino IDE
06:02
then after you have to launch the
06:06
Simple MQTT broker code from SMQTT broker folder in the examples
06:11
okay, so simple MQTT broker code and then after you have to change few things and the few things is your Wi-Fi SSID and
06:18
the Wi-Fi password to connect your
06:21
ESP8266 board with the Wi-Fi and then after it will start acting as a
06:27
MQTT broker and then after you can use it. Okay
06:30
So, I hope this thing is clear and if you still have any questions or any doubt in this
06:35
Okay, then you can always ping me on telegram Instagram. What's up anywhere? Also, you can comment on this video
06:40
Also, you can send me a mail
06:42
Now in the future videos, we are going to see how to set up secure MQTT broker in the NodeMCU
06:48
Okay, so right now in this code, we don't have any username and password
06:53
So when we try to connect with this broker, okay, we haven't specified any username and password
06:59
Okay without specifying any username and password we are able to connect with that MQTT broker
07:04
Which is running inside ESP8266, but we want to make a secure MQTT broker
07:09
Then how we can do that? So that thing we are going to cover in the next video
07:13
Okay, so stay tuned for the next video till then take care
07:18
goodbye, and
07:20
Thank you
NodeMCU ESP8266
7:23
|
Up next
ESP8266 as MQTT Broker | How to Setup Basic MQTT Broker in NodeMCU ESP8266 using sMQTTBroker Library
Fusion Automate
9/4/2024
5:50
ESP8266 as MQTT Broker | Setup Secure MQTT Broker in NodeMCU ESP8266 using sMQTTBroker Library |
Fusion Automate
9/4/2024
Recommended
7:27
ESP32 as MQTT Broker | How to Setup MQTT Broker with Custom TCP Port in ESP32 using PicoMQTT Library |
Fusion Automate
9/3/2024
8:03
ESP32 as MQTT Broker | How to Setup Secure MQTT Broker in ESP32 using PicoMQTT Library with Username and Password Authentication |
Fusion Automate
9/3/2024
8:09
ESP32 as MQTT Broker | How to Setup Basic MQTT Broker in ESP32 using PicoMQTT Library
Fusion Automate
9/2/2024
0:52
Unboxing Elecrow ESP32 Serial Port to Ethernet Module | WT32-ETH01 Development Board Module | IoT |
Fusion Automate
10/28/2024
1:04
ZLAN 5143D Modbus Serial to TCP Converter Gateway | Protocol Converter | IoT | IIoT | Modbus |
Fusion Automate
10/28/2024
0:59
Running TFT Demo in LILYGO T-HMI Display | HMI | IoT | Demo | Lilygo | IIoT |
Fusion Automate
10/28/2024
4:37
NORVI ESP32 Based Industrial Controller | ESP32 PLC | NORVI GSM-AE04-V-G | SIM800C | RS485 | IoT |
Fusion Automate
11/21/2024
0:39
Unboxing LILYGO T-Internet-COM | ESP32 Wifi Bluetooth Board For T-PCIE Ethernet IOT Module |
Fusion Automate
10/28/2024
4:45
BusLogFi IIoT Gateway from SilTech Industries | Modbus | MQTT | Data Logger | OTA | Web Config |
Fusion Automate
9/22/2024
1:48
DIY Android Tablet Using Orange Pi Zero 3 | Android V12 | VIEWE Display | 10.1 Inch HDMI Display |
Fusion Automate
4/13/2025
1:30
DIY Hacking Device using Kali Linux in Orange Pi Zero 3 | OPI Zero 3 | Hacking | KALI |
Fusion Automate
4/13/2025
1:18
Running Raspberry Pi OS in Orange Pi Zero 3 | OPI Zero 3 |
Fusion Automate
4/13/2025
0:45
Unboxing Orange Pi 32gb EMMC Module | Orange Pi 4A | OPI | eMMC Storage |
Fusion Automate
4/13/2025
11:04
How to Build a Mini NAS Server using Banana Pi M4 Zero with External Storage Drive
Fusion Automate
2/17/2025
8:27
How to Control Banana PI M4-Zero GPIO with Node-RED and node-red-contrib-opi-gpio node |
Fusion Automate
2/17/2025
5:55
How to Control Banana PI M4-Zero GPIO with Python using RPI.GPIO Library |
Fusion Automate
2/17/2025
8:02
How to Control Banana PI M4-Zero GPIO using Wiring Pi Python Library |
Fusion Automate
2/17/2025
7:02
How to Setup WiringPi Package in Banana PI M4 Zero for GPIO Control |
Fusion Automate
2/17/2025
5:53
How to Setup WiringPi Package in Banana PI M4-Berry for GPIO Control |
Fusion Automate
2/17/2025
9:04
How to Control Banana PI M4-Berry GPIO using Wiring Pi Python Library |
Fusion Automate
2/17/2025
5:11
How to Control Banana PI M4-Berry GPIO with Python using RPI.GPIO Library |
Fusion Automate
2/17/2025
8:18
How to Control Banana PI M4-Berry GPIO with Node-RED and node-red-contrib-opi-gpio node |
Fusion Automate
2/17/2025
16:49
Getting Started with Orange Pi Zero 3 | Flash Ubuntu Noble Server Linux to SD Card |
Fusion Automate
1/31/2025
10:22
Elecrow CrowPanel ESP32 4.2” E-paper HMI Display Wifi_Http_Openweather_Demo | ESP32 | E-Paper |
Fusion Automate
1/25/2025
15:38
Getting Started with Orange Pi Zero 3 - Flash Ubuntu Jammy Server Linux OS to SD Card - Configure USB Debugging - SSH Access
Fusion Automate
1/24/2025