Skip to player
Skip to main content
Search
Connect
Watch fullscreen
Like
Bookmark
Share
More
Add to Playlist
Report
ESP32 as MQTT Broker | How to Setup Basic MQTT Broker in ESP32 using PicoMQTT Library
Fusion Automate
Follow
1 year ago
Category
🤖
Tech
Transcript
Display full video transcript
00:00
Hi everyone and welcome. In this video we will see how to use your ESP 32 board
00:07
as MQTT broker. Okay so yes we can use our ESP 32 board as MQTT broker. So
00:15
instead of Hive MQTT broker, Mosquito MQTT broker, Nano MQTT broker or
00:22
any other cloud MQTT broker you can directly use this ESP 32 board as MQTT
00:27
broker. So you don't need to install Mosquito MQTT broker in the Raspberry Pi.
00:32
You don't have to purchase any other cloud broker services for communication.
00:36
You can use your ESP 32 as a cheapest MQTT broker. Okay and with the help of
00:43
these three library you can perform that action. So the first one is Pico MQTT. The
00:48
second one is Embedded MQTT broker and the third one is S-MQTT broker. So now in
00:53
this video we are going to cover the first topic. Okay how to set up basic
00:58
MQTT broker in the ESP 32 board using Pico MQTT library. Okay so let's see how
01:05
you can do that and before that here is the diagram. So we have our ESP 32 board
01:11
in the center which work as the MQTT broker and here is our MQTT client and
01:16
you can exchange the data between each of your client and this is diagram for
01:21
the local area networks. So once you deploy your ESP 32 board as MQTT broker
01:25
in the local area network your n number of client in the local area network can
01:30
connect with this ESP 32 MQTT broker and they can exchange the data. Also you can
01:34
do the port forwarding of your ESP 32 MQTT broker and then after you can
01:39
access your ESP 32 MQTT broker from anywhere in the world over the internet.
01:44
So that is also possible but you have to do some port forwarding stuff for that
01:48
but in the local area it will work absolutely fine without any problem. So
01:53
let's see how you can load the code and how you can use it. So here I have
01:58
already installed the Pico MQTT library in my Arduino IDE. So here you can see
02:02
Pico MQTT which is already installed and I'm going to the examples. Okay here in
02:09
the example you will have to find Pico MQTT folder as you can see Pico MQTT
02:14
and we are going to select the basic server example. Okay so here is the basic
02:20
server example or you can say basic MQTT broker example for ESP 32 board. So
02:25
first of all what will happen your ESP 32 board will connect with Wi-Fi. Okay
02:30
for your local area network communication and then after your Python
02:34
client your ESP 32 C3 or any other NodeMCU board will connect with this ESP 32
02:40
MQTT broker. So first of all we have to make ESP 32 available in the local area
02:44
network by connecting to the Wi-Fi. So here I'm going to provide the SSID which
02:50
is and here is the password. Okay and that's it. So in this example all you
02:58
have to do is you just have to change the SSID and you just have to change
03:02
your Wi-Fi password. So ESP 32 board will connect with your Wi-Fi and then after it
03:07
will act as a MQTT broker. Okay now we can select our board. Okay and we can
03:13
select the COM port. That's it. We can directly upload the code in our ESP 32
03:17
board.
03:31
Okay so you can see done uploading. So we have successfully uploaded this code into
03:36
our ESP 32 board. Now I'm going to open the serial monitor here and I'm going to
03:41
press the reset button in my ESP 32 board. You can see connecting to Wi-Fi.
03:47
Wi-Fi connected and here is the IP address. Okay so this is the IP address
03:52
which we are going to use to connect with our MQTT broker. Now I am going to
03:57
open the MQTT Explorer software which is our MQTT client. Okay so you can use any
04:04
MQTT client software. It can be your Node-RED. It can be your SCADA system. It
04:07
can be your test MQTT client anything. Okay all of your MQTT client will
04:13
connect with this ESP 32 MQTT broker and right now in this code the default port
04:18
for communication is 1883. Okay you can change this port number as well in this
04:24
code but that we are going to see in the future videos. Now here we have the IP
04:28
address 192.168.1.11. So I'm going to copy this and I'm going to add new
04:33
connection which is my ESP 32. I'm going to provide the IP address of my
04:38
ESP 32 here and here is the port number 1883 which is default for this basic
04:44
server code. Okay and I'm going to click on the connect and here you can see we
04:49
are connected. Also let me open another MQTT Explorer. Okay and again we will
04:57
add new connection which is ESP 32 and I'm going to provide the IP address of
05:02
my ESP 32 and I'm going to save it and then I'm going to click on connect. So
05:07
you can see both of the client is connected with my ESP 32 broker and also
05:12
I can publish the data. So I'm going to publish the data on the test topic and
05:16
I'm going to publish 111 and here you will receive that. Okay and on the same
05:21
topic I can publish another value. Okay and you will see the update in both of
05:27
the clients. Also we can try for one more value and here you can see. So what
05:33
exactly happening is we have two clients. Okay so this is the first client and
05:38
this is the second client. So both are connected to our ESP 32 MQTT broker and
05:42
both are exchanging the data. Okay so this is how you can use ESP 32 as the
05:47
MQTT broker and this is the basic code. Okay we haven't secured our MQTT broker
05:53
with the password as well and we haven't configured custom port but that thing we
05:58
are going to see in the future videos. Okay so custom port configuration and
06:02
username and password configuration is only available with the Pico MQTT
06:06
library. Okay so those are limitation for other libraries. So if you are going to
06:10
use the embedded MQTT broker then you cannot set up security in that broker.
06:14
Also the same case with the S-MQTT broker and there are some other
06:18
limitation as well. So I'm going to provide the GitHub repository link for
06:22
all these three library and there you can view the limitation of this brokers.
06:27
Okay but for normal use case it will work fine. Okay here and here you can see
06:33
both clients are connected. If I remove my ESP 32 from my system okay and then
06:41
after we were not able to publish any data. So if I publish data to 4444 on the
06:46
topic test then we are not able to publish it. Okay and if we disconnect and
06:52
if we try to connect then we are not able to connect. So let me again connect
06:56
my ESP 32 with my system.
07:02
You can see Wi-Fi connected and here you can see it is connected. Okay let me
07:10
connect this client again. Okay and we can publish the data and that is
07:14
available here. So it is working absolutely fine with ESP 32 board. Okay
07:20
so I hope everything is clear that how you can use ESP 32 board as MQTT
07:24
broker using Pico MQTT library and the code you can get the code from example
07:31
only. So you have to go to the example you have to search for the Pico MQTT and
07:35
you can use this basic server example. Okay so I hope everything is clear and
07:42
if you still have any questions or any doubt in this then you can always ping
07:46
me on Telegram Instagram WhatsApp anywhere. All social media link is
07:49
available on our website. So let's meet in the next video and in the next video
07:54
we are going to cover this topic that how you can set the custom port for your
07:58
ESP 32 MQTT broker. So let's meet in the next video. Till then take care goodbye
08:05
and thank you.
Be the first to comment
Add your comment
Recommended
8:03
|
Up next
ESP32 as MQTT Broker | How to Setup Secure MQTT Broker in ESP32 using PicoMQTT Library with Username and Password Authentication |
Fusion Automate
1 year ago
7:27
ESP32 as MQTT Broker | How to Setup MQTT Broker with Custom TCP Port in ESP32 using PicoMQTT Library |
Fusion Automate
1 year ago
7:23
ESP8266 as MQTT Broker | How to Setup Basic MQTT Broker in NodeMCU ESP8266 using sMQTTBroker Library
Fusion Automate
1 year ago
5:50
ESP8266 as MQTT Broker | Setup Secure MQTT Broker in NodeMCU ESP8266 using sMQTTBroker Library |
Fusion Automate
1 year ago
6:53
How to Flash Micropython Firmware in Seeed Studio XIAO ESP32C3 | ESP32 | IoT | IIoT |
Fusion Automate
2 years ago
31:33
Surprising My Best Friend for His Birthday
The Royalty Family
3 days ago
24:13
Opening his Dream Christmas Present
The Royalty Family
6 days ago
32:37
HOME ALONE Without Parents for 24 Hours (Again!)
The Royalty Family
3 weeks ago
9:41
Getting Started with D-Robotics RDK X5 | Flash Ubuntu Desktop OS to SD Card | HDMI Screen Setup |
Fusion Automate
2 months ago
0:59
D-Robotics RDK X5 Single Board Computer Unboxing & First Impressions
Fusion Automate
2 months ago
0:59
DIY Mini PC Using D Robotics RDK X5 SBC | Ubuntu Desktop Linux | Elecrow 7 inch Touch Monitor |
Fusion Automate
2 months ago
0:50
Assembling Your RDK X5 with the D-Robotics RDK X5 Metal Case
Fusion Automate
2 months ago
0:45
Protect Your RDK X5 in Style – Unboxing the Official D-Robotics RDK X5 SBC Case
Fusion Automate
2 months ago
1:48
DIY Android Tablet Using Orange Pi Zero 3 | Android V12 | VIEWE Display | 10.1 Inch HDMI Display |
Fusion Automate
9 months ago
1:30
DIY Hacking Device using Kali Linux in Orange Pi Zero 3 | OPI Zero 3 | Hacking | KALI |
Fusion Automate
9 months ago
1:18
Running Raspberry Pi OS in Orange Pi Zero 3 | OPI Zero 3 |
Fusion Automate
9 months ago
0:45
Unboxing Orange Pi 32gb EMMC Module | Orange Pi 4A | OPI | eMMC Storage |
Fusion Automate
9 months ago
11:04
How to Build a Mini NAS Server using Banana Pi M4 Zero with External Storage Drive
Fusion Automate
11 months ago
8:27
How to Control Banana PI M4-Zero GPIO with Node-RED and node-red-contrib-opi-gpio node |
Fusion Automate
11 months ago
5:55
How to Control Banana PI M4-Zero GPIO with Python using RPI.GPIO Library |
Fusion Automate
11 months ago
8:02
How to Control Banana PI M4-Zero GPIO using Wiring Pi Python Library |
Fusion Automate
11 months ago
7:02
How to Setup WiringPi Package in Banana PI M4 Zero for GPIO Control |
Fusion Automate
11 months ago
5:53
How to Setup WiringPi Package in Banana PI M4-Berry for GPIO Control |
Fusion Automate
11 months ago
9:04
How to Control Banana PI M4-Berry GPIO using Wiring Pi Python Library |
Fusion Automate
11 months ago
5:11
How to Control Banana PI M4-Berry GPIO with Python using RPI.GPIO Library |
Fusion Automate
11 months ago
Be the first to comment