Skip to player
Skip to main content
Skip to footer
Search
Connect
Watch fullscreen
Like
Bookmark
Share
Add to Playlist
Report
ESP32 as MQTT Broker | How to Setup MQTT Broker with Custom TCP Port in ESP32 using PicoMQTT Library |
Fusion Automate
Follow
9/3/2024
Training Index: https://fusion-automate.super.site/1f38090ec617464884074d74a9561856
------------------------------------------------------------
Website: https://fusionautomate.in
Telegram: https://t.me/fusion_automate_admin
WhatsApp: https://wa.me/message/B7RXUT4OUXWUF1
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 welcome. In the previous video, we have covered ESP 32 as an MQTT broker,
00:09
and we have used Pico MQTT library to convert our ESP 32 into the MQTT broker. So instead
00:15
of Hive MQTT broker, Mosquito MQTT broker or Nano MQTT broker or any other cloud MQTT
00:22
broker, you can use your ESP 32 board as an MQTT broker for your small scale application.
00:28
But in that video, in that code, we have used port 1883, which is the default port
00:35
for MQTT broker. Okay, but for some security reason, if you don't want to keep the default
00:41
port 1883 for TCP communication or MQTT broker, then how you can change it in the Pico MQTT
00:47
library. So that thing we are going to cover in this video. So basically, we will see how
00:52
to set up basic MQTT broker with a custom port, okay, custom TCP port in ESP 32 using
00:58
Pico MQTT library. So again, we are going to set up MQTT broker in the ESP 32 board.
01:04
But instead of the port 1883, which is the default, we are going to select some other
01:08
TCP port for MQTT communication. Okay, so let's see how you can do that. And here is
01:15
the communication diagrams. So our ESP 32 board is in the center, which act as an MQTT
01:20
broker for all of the client, and all of the client can publish to any topic, okay, and
01:25
all of the client can subscribe to any topic, and they can exchange the data and everything
01:30
will happen in the local area network communication. Okay, so your ESP 32 will connect with the
01:35
Wi Fi, your ESP 32 c three or Python MQTT client also connect with the Wi Fi and they
01:40
can publish and subscribe the messages. So instead of port 1883, we want to start our
01:46
MQTT broker with some different ports. So let's see how you can do that. So here is
01:51
the Arduino ID. Okay, I have already installed Pico MQTT library in my Arduino ID, you can
01:58
see Pico MQTT is already installed. Now we will go to the examples and here we will search
02:04
for the Pico MQTT folder. Okay, here you can see Pico MQTT. And here you can see the example
02:11
server with custom port. So we are going to select this example. When you load this example
02:17
into the ESP 32 board, your ESP 32 board will act as an MQTT broker, but it will run
02:23
your MQTT broker on custom MQTT port. Okay, here you can see. So whatever TCP port you
02:30
define here, your MQTT broker will run on that TCP port. Okay, so first of all, you
02:36
have to provide your Wi Fi SSID here. So my Wi Fi SSID is and here we have to provide
02:43
the password for your Wi Fi. And then after on whatever TCP port you want to start your
02:50
MQTT broker, you can specify that in this line. So instead of port 1883, if you want
02:57
to start your MQTT broker on the port 9000, then you can specify the port 9000 here. So
03:03
your client has to use the port 9000 to connect with your ESP 32 MQTT broker, they cannot
03:10
use port 1883 to connect with this MQTT broker. Okay, and rest of the code is same as the
03:15
previous video. So it will connect with the Wi Fi. Okay, and then it will continuously
03:20
run our broker. So I'm going to upload this sketch into our ESP 32 board. Okay, so I'm
03:27
going to hit the upload button. Okay, here you can see done uploading. Now we can open
03:46
serial monitor to find the IP address of our ESP 32 board. So I'm going to press reset
03:52
button on my ESP 32. And here you can see connecting to Wi Fi. And here we have the
03:57
IP address of our ESP 32 board. Now, in the previous video, also we have the same IP address
04:03
of our ESP 32. But the port number was 1883. Now we have a different port number for MQTT
04:10
communication. So let's open the MQTT client and let's connect with our ESP 32 MQTT broker.
04:17
So I'm going to open MQTT Explorer here. And here you can see in the previous video,
04:24
we have used port 1883 to connect with our ESP 32 broker. But if I try to connect then
04:29
it won't able to connect because the MQTT broker is running on port 9000. So I have
04:35
to abort it. And then I have to change the port number to 9000. And then I can connect
04:40
it. Okay, here you can see we are connected. So if I use port 1883 then it won't let us
04:50
connect Okay, it will always stay in the connection mode. Okay, it will try to connect but MQTT
04:58
broker or ESP 32 won't respond to that connection request because of different port. So we have
05:03
to change the port number to 9000. We have to abort it and then we have to connect again.
05:07
And here you can see we are connected. I can again open one more MQTT Explorer client.
05:13
Okay, and I can change the port number to 9000. And I can click on connect to connect
05:19
with our ESP 32 MQTT broker on the different TCP port. Now the different TCP port is sometimes
05:25
required due to firewall issues or some security reasons. Okay, so if we keep the port 1883
05:32
as a default, then anyone can get access to our ESP 32 MQTT broker. And if we change
05:37
the port, okay, instead of 9000 or 1883, if we change the port to something else, okay,
05:43
as per our requirement, and as per our firewall rules, then no one can connect with that ESP
05:48
32 MQTT broker. So that's why custom TCP port is required. Now I can publish some data to
05:54
the test topic. Okay, the data is 123. And here we are going to receive the data. And
06:00
also I can publish the data from here 456. And that I'm going to receive it here. Okay,
06:06
so our MQTT broker running inside the ESP 32 is working fine. Our two different client
06:12
can exchange the data with each other. So this client is also publishing and subscribing
06:18
to the test topic. And this client also is publishing and subscribing to the same topic.
06:23
So this is how you can use your ESP 32 as an MQTT broker with a custom port. Okay, or
06:28
you can say custom TCP port for your MQTT broker communication. So I hope this thing
06:34
is clear that how to set up basic MQTT broker with custom TCP port in ESP 32 using Pico
06:40
MQTT library. If you still have any questions or any doubt, then you can always ping me
06:44
on Telegram, Instagram, WhatsApp anywhere. All the social media link is available here
06:49
on our website. So let's meet in the future videos. And in the next video, we will see
06:53
how to set up secure MQTT broker in the ESP 32 using Pico MQTT library. So right now,
07:00
whenever you try to connect with your ESP 32 broker, it won't ask for any username and
07:04
password. Okay, you can see username and password field is empty. So if you want to set up the
07:10
username and password, okay, if you want to make your ESP 32 broker secure, then how we
07:15
can do that. So that thing we are going to cover in the next video. Okay, so stay tuned
07:19
for the next video. Till then, take care. Goodbye. And thank you
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
9/3/2024
7:23
ESP8266 as MQTT Broker | How to Setup Basic MQTT Broker in NodeMCU ESP8266 using sMQTTBroker Library
Fusion Automate
9/4/2024
8:09
ESP32 as MQTT Broker | How to Setup Basic MQTT Broker in ESP32 using PicoMQTT Library
Fusion Automate
9/2/2024
5:50
ESP8266 as MQTT Broker | Setup Secure MQTT Broker in NodeMCU ESP8266 using sMQTTBroker Library |
Fusion Automate
9/4/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
9:18
How to Connect Node RED with Mosquitto MQTT Broker as a MQTT Publisher and MQTT Subscriber | IoT |
Fusion Automate
4/15/2024
0:39
Unboxing LILYGO T-Internet-COM | ESP32 Wifi Bluetooth Board For T-PCIE Ethernet IOT Module |
Fusion Automate
10/28/2024
4:37
How to transfer Files from a Windows Machine to the LuckFox Pico Pro/Max RV1106 Linux Micro Development Board via SSH
Fusion Automate
11/7/2024
0:13
💡✨A Robot Revolution #Robots #Humanoids #AI #ShanghaiRoboticsEvent #FutureTech
✨DailyFavoriteSearch
11/16/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