Welcome back guys to video number 4.5. And in this
year video, we're going to set up the mesh Network. Actually. We
have a lot of use cases regarding the
mesh Network where we cannot depend upon
the routers. For example, we are
going to deploy our sensors in a smart agriculture field
where we have a hundreds of
sensors, which are Wi-Fi enabled so
we can't apply the Wi-Fi routers across all
the fields and there are some other
use cases like in smart cities, for example, if you want
to monitor the garbage pins, so we
cannot deploy the router on every State Street and
same like if we
want to get the reading for the electric meters or
water meters. So the mash Network have a wide
variety of use cases to send the data from one
to another node. And the other node will be responsible to
send the its own data and
the previous note data to the next node and this
Will make a chain and specially it is a good
option in case of natural disasters where
we cannot use the
heavy equipment for the communication. Then Wi-Fi. Mesh
networks are good to go with that. Okay before
moving on we need to set up some
libraries. So just click on the sketch and click
on the manage libraries.
Firstly we need to install a library called
painless mesh Library
just type the painless and you will get the
library. I already have installed. And by
the way, this Library will depend on three other
libraries one is Arduino Jason
and others are async TCP
and the espa sync TCP.
Async TCP is for esp32 development
boards and espe async TCP
libraries for esp826 series
4, so just type A sync TCP.
And here we need to find the library.
I will show you which other Library
we need to use. Yes, the actually that devrel this
is the author and the
fork from the github.com me no
Dev. Async TCP. You need to
install that library and the other is
ESP async TCP if
you are going to use only esp32 development boards,
then you didn't have required to
install that but if you are going to use esp8266 series
development board, then this library is mandatory
either you have all the esp826 series
board or you have a mixture of esp32 and
esp826. Then we're good to go with that. Okay after installing
that Library click on the file and
in the example come here
and here we have a painless mesh and
just click on the basic. Okay. So if
I go to the tools and see the
com ports, okay on the Comm 15,
we have a esp32 oncom 14. We have
the most D1 mini ESP 32 and on
Chrome 7. We have esp826 series
4, by the way, these are the development
boards that I connected and
these are the power down. I didn't use
Camera for that because there's a no requirement to use.
Okay.
Right. Now we only have option to monitor the
one calm and which is come 14 and the
vmos D1 mini sp32 is connected on that
click on the serial Monitor and here we're
getting the data what how we can see the data from
the other nodes. So that's why
I use the putty. So click on
that and here select the com.
15
for the esp32 and the speed
Is here?
Sorry, we need to copy that speed from here the serial
Port speed. Okay?
No worries. Okay open up
and here we will see all the stuff. Okay.
And again, we need another pretty
terminal for the
vmos D1 Mini esp82 double 6
And open up and we are good to go with that.
And if you see here, they are showing all the stuff
the data is coming from the node. You will
see here. The data is coming from the 49 and the
91 node, but it's not showing the third note because
this node is not showing its
own messages. But if you see here, you will
get the different IDs here like seven seven
nine one and seven eight
six nine. Okay. So if we
talk here then the 949 is that
esp32 node number? Okay,
and if we come here then it's showing
the 949.
And 869 and
other is not coming here. Okay.
so
I will do some experiment with that.
Just resetting the esp8266 and
here you will see that we have a reset everything,
okay?
but certainly you will see here adjusted
time is there and
The new node is coming here and the data is
coming from there. So this is the experiment by which
I show you how that thing is
a working on now. It's time to come to the
code. So here is the painless mesh.h library
and
This is the perfect for the my smart agriculture
match. Okay. The one thing is that if you click here, then you
will see that mesh Network in the Wi-Fi. My
smart agree mesh. Okay. This is
the password and this is the mesh port number. You can
change it according to your requirement on that
board. The tcp/ip server will
be started for the communication.
By the way, this library is using the
user scheduler library to schedule the task instead of
a timer. This is more enhanced as compared
to the diamond Library. Okay, here we are.
Creating a painless mesh object by
the name of mesh and here is the message send message
and in the tasks and message. What it will
do is after one second. It will call that
message. Send message and here is the implementation of
send message. What it is doing is the messages.
Hello from the node. And here is the mesh.get node
it and this message dots and
broadcast. By the way, you guys can send the messages
to the specific node by mentioning to
the node Name. By the way, there are
examples come to the file example.
And in the painless mesh here is
the named mesh and here you
need to.
Mention the node name and then
you also need to mention or to which
node you want to send the message. And by the way, this is
a good to send the message to the specific nodes to control
the traffic load.
Okay. Now let's come back to the point and send the broadcast
and after that again call that method after
the random interval to send
the message actually why this is random interval to
avoid the flooding of messages. For
example, if you put the delay of one second two second
or five seconds, then it will start making flooding in
the mash Network which will make it
down right now. We have a three nodes, but if you have 100 nodes,
it will make a complex. So it is a good option to
use random. By the
way, if we talk about the applied mesh
Network in the field, then we have a specific
time. We cannot send the message randomly
because there we
will Define the rules when we need to send the data to
other node. Okay, and here are the received callbacks
new connection call back if you want to.
Add new functionality the on the receiving callback. Then
this method is there and if you want to set up some
functionality regarding a when new connection come then
you can use that method and
here is the change connection callback. For
example connection type has been changed another type. You
can use that method and no time adjusted call
back to adjust the node time. Okay, and here
is a setup where we are beginning serial dot
begin and setting up the mesh Network on
receive at task and enable and
in the loop. We have a mesh Dart update. It's
running in the loop to get updated
if there's any node coming
if there is any more leaving by the way,
it is a mandatory task to maintain the routing table of a
mesh Network. So this is the complete code
and I hope you guys like that now,
Implement with the DHT 11 or
dht22 sensor to send the temperature and humidity
from one node to the any other node, or you
can make it.
for example
you can put a sensor on the street and in the
middle just Place different esp826 series
board and in the end of
street, especially your street should be
300 to 500 meter long
Where you will test how?
We can take the benefit of mesh Network.
So guys in the next video. We're going to
talk about pros and cons of Wi-Fi and see you in the next video. Have a good
day. Bye.