------------------------------------------------------------
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
------------------------------------------------------------
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
🤖
TechTranscript
00:00Hi everyone and welcome. In this video we will see how to set up MQTT broker in
00:07Xiao ESP32C3 using embedded MQTT broker library. So if you want to use
00:13your Xiao ESP32C3 board as a MQTT broker then you can use it using
00:18embedded MQTT broker library. So instead of using Mosquito MQTT broker or
00:23Hive MQTT broker or EMQX broker, Nano MQTT broker you can use tiny little Xiao
00:31ESP32C3 board as a MQTT broker and you can place in your local area network
00:36and your MQTT client can exchange the data using this Xiao ESP32C3 MQTT
00:42broker. So let's see how you can create MQTT broker using Xiao ESP32C3.
00:48So I have ESP32C3 connected with my system and here is the Arduino IDE.
00:54Before uploading the code here is the connection diagram. So our ESP32C3
01:00board is in the center which will act as a MQTT broker and different
01:04different MQTT client can connect with this Xiao ESP32C3 MQTT broker and they
01:09can exchange the data. Now every client can publish and subscribe to any topic
01:15that is also possible and everything will be work in the local area network.
01:19So if you have multiple devices in your local area network then you can exchange
01:23the data. If you want to control some LED in your local area network then
01:28also you can do that. If you want to read some sensor data from anywhere in the
01:32local area network to your mobile phone to your dashboard then also you can do
01:36that. So all these options are possible with the embedded MQTT broker library. So
01:42here is our Arduino and I have already installed the embedded MQTT broker
01:46library. So I'm going to copy this and here we will search it. OK. Here you can
01:51see it is already installed in my Arduino IDE. You can also install and
01:55then you can use it. Now once you install this embedded MQTT broker
01:59library you have to go to the examples. OK. And here you have to search for the
02:05embedded MQTT broker folder and here it is. OK. Embedded MQTT broker and here we
02:11have the two example HTTP server and MQTT broker and another example is
02:16simple MQTT broker. Now I'm going to use this simple MQTT broker sketch to use
02:21my ESP32C3 as MQTT broker. OK. So here is our sketch. So first of all what you
02:29have to do is you have to provide your Wi-Fi SSID and password to connect your
02:34Xiao ESP32C3 with your Wi-Fi. OK. Or you can say to put your ESP32C3 in the
02:41local area networks. So here I'm going to provide the SSID and password of my
02:45Wi-Fi. So. OK. So here is the SSID and the password of my Wi-Fi. So our ESP32C3
02:54will connect with our Wi-Fi. OK. And it will act as an MQTT broker. So all of the
02:59MQTT client can use our ESP32C3 MQTT broker and they can exchange the
03:04data. OK. And then after here you can see in this line you have to specify that on
03:10which TCP port you want to start your MQTT broker. So right now the default
03:15port is 1883. OK. But if you want to change the TCP port for your MQTT
03:19broker then you can change it from here. OK. And you can leave the rest of the
03:24thing as it is and you can directly upload this code into your ESP32C3
03:29board. So here is my ESP32C3 connected. I'm going to upload this sketch
03:34into my ESP32C3 board.
03:40OK. So our sketch is successfully uploaded to the ESP32C3 board and now we can open
03:59the serial monitor.
04:02Let me press the reset button. OK. OK. Here you can see Wi-Fi connected. Broker
04:09started and the broker is running on this IP address 192.168.1.2 and the port
04:15is 1883. OK. So we can use this IP address and we can use this port number to
04:20connect with the MQTT broker running inside our ESP32C3 board. So I can open
04:26my MQTT Explorer software. OK. And I can provide the IP address which is 192.168.1.2
04:34OK. I am going to create one more connection and it's our ESP32C3. OK. I'm
04:43going to save it. The port number is 1883 and we can click on connect. OK. You can
04:51see it is connected. Now we can open one more MQTT client. OK. Which is MQTT
04:56Explorer and I'm going to use the same IP address and port number to connect
05:01with my ESP32C3 MQTT broker. But I'm not going to use the same client ID. So
05:09here you can see MQTT client ID. So I'm going to change my client ID and then we
05:13will go back and then we will connect. OK. So we are connected with our ESP32C3
05:18MQTT broker and in the topic I'm going to publish some values on the test
05:24topic. So topic is test. The value is 1 2 3. OK. And I'm going to publish it. And
05:30here you can see we have received the value in another client. Also I can
05:34update the same topic value from different clients. So 4 5 6 and I can
05:41publish. And here you can see we have received the value. OK. So this is how
05:47you can use your ESP32C3 board as a MQTT broker. So multiple client can
05:52connect with your ESP32C3 board and they can exchange the data. And your
05:56client can be your Python client, your Node-RED, your SCADA system, your
06:00Raspberry Pi. OK. Or any other ESP32C3 board or any other ESP32 board or
06:06NodeMCU board anything. So you can use this ESP32C3 as a MQTT broker. Instead
06:12of using Raspberry Pi and installing another MQTT broker in the Raspberry Pi
06:16you can use this tiny and low cost microcontroller to create your own MQTT
06:21broker. Also you can do the port forwarding and you can use this ESP32C3
06:26MQTT broker as a cloud MQTT broker as well. OK. But with the help of port
06:30forwarding. So you have to learn that how to do the port forwarding for your ESP32C3
06:35board. So I hope this thing is clear that how you can set up MQTT
06:40broker in the Xiao ESP32C3 board. And if you still have any questions or any
06:46doubt then you can always ping me on Telegram, Instagram, WhatsApp, anywhere.
06:49And if you want to know more about the embedded MQTT broker library then here I
06:53have provided the GitHub repository link for this library. You can go and you can
06:56check out the limitations and everything. OK. So I hope everything is clear and if
07:01you still have any questions or any doubt then you can always ping me on Telegram,
07:04Instagram, WhatsApp. All the social media link is available on our website. So
07:09let's meet in the future videos. OK. Till then take care. Goodbye and thank you.