Hello, guys, and welcome back.
Now we've seen how we can install our ESB or not MCU libraries, we know how to select our board.
Now it's time to connect our MCU to Wi-Fi.
So the hello word usually for any board is to blink and to lead the hello world for the Iot devices
like the MCU, E.S.P, 82, 66, all of those the hello word for it is connecting it to Wi-Fi, connecting
it to your router so that you can connect to the Internet, you can receive data and send data.
So in order to do that, we need to include a library which will make this very easy for us.
So first we're going to do include and then ESB 82.
66, then wi fi.
Now we notice the eyes, here are small letters and the W and the F or capital letters that H.
Meaning your header, and by that, we have added the library now the first thing we want to do is add
our password and our I.D. in order to connect to the Internet.
So I'm going to have a const.
Character.
And it's going to be a pointer to SS I.D..
Now, this will equal to whatever your voter or network name.
So to do that, you just open Wi-Fi and you check what is the name of your network and you just type
it in between those double quotations.
Next, you need the password.
So you're going to say const char again, pointer, let's call it pass and here you will type your password.
OK, we need a semicolon here and that's it.
Now, a pointer here, because if you want to write this string, not one character, you would need
to use a pointer.
Now, a pointer is a topic we will not get into, at least for now.
But a pointer is it's like you are pointing to every character individually, like you point to the
first character, then you can point to the second character.
So it's the the name is implied in it.
So it's a pointer pointing to something.
So let's say this is the name of my network.
The pointer will be pointing to this with some shift operation will be pointing to this, then this,
then this will be pointing to this one by one, depending on where the pointer is.
OK, next.
Let's say you have filled your password and the SS ID name or the network name, what's next?
Well, we need some cereal here in order to check the status if our device is connected to the router
or not.
So this will be 96 zero zero.
I'm going to delay a little bit here.
And I'm going to print a message indicating that I am trying to connect, so I'm going to say circle
dot.
Friend Ellen.
And I'm going to print connecting.
To.
So that if I open my cereal, I know that I am in the state of checking my connection or trying to connect.
And also, I want to print what is the name of my network, so surreal print.
I'm going to print here my aside.
OK, I'm going to print this string that is written in here next.
Now remember the cereal begin?
There was something in NMC, MCU or inside this library here called wi fi begin.
So I'm going to type wi fi also.
These are small letters.
Don't begin, and I'm going to pass to it is this I.D. and password.
OK.
So this will initiate my life right now.
This should be enough next to what I want to do is I want to try to connect.
Now, let's assume that the connection is successful with Wi-Fi begin.
I'm going to print serial dot.
Friend Alan.
WI fi connected.
So these are all statuses, all I care about actually is this wi fi begin right here and these two,
but all of these statuses.
Now, how about if I typed my idea on going my password wrong?
How would I know that this is not connected?
I need some type of interactive messaging here, so I'm going to add the following line.
So if I say while wi fi that status.
Is not equal to W.L. Connected.
I'm going to say delay.
For, let's say, half a second and I just want to bring a adult.
No, Elland just printing a don't like that.
What does this mean wi fi status is actually a method coming from this library here.
Remember this wi fi biggin is coming from here the same as I can begin.
I could also check the status.
So if I write wi fi status and I call this method of function, it's going to return something.
There was they are returned keywords that we can use.
And the key word we will be counting on is W.L. connected.
So this wi fi status, when it's connected, it's going to return this.
Status for me.
OK, and as long as this is not equal to this status, I want to do that.
They will not print dots like that.
Now, let's assume that we are connected.
Then we will be skipping this part all along and we will be printing wi fi connected.
Otherwise, as long as I am not connected, I will be stuck in this loop because this while loop, it's
similar to the full, but the termination condition is written here.
As long as there is no termination condition, I will keep waiting and printing this until I am done.
The status is satisfied and then I will be able to print this out.
OK, now I'm going to be typing my own SS idea and password.
All right, so now I'm going to check that my boy disconnected.
For me it is eight.
For you it could be any other.
Com, so make sure you are connected to the right column and click on upload.
Save the sketch.
Now we are done uploading.
Let us check the serial monitor.
So as you can see now, we are trying to connect.
This is why I have attached all of these dots we are creating.
And we have Wi-Fi connected now, let's say if you press the very small button on your not MCU, you're
going to reset.
As you can see, I'm typing, connecting to this and connected.
So this is how we connect our not up to Wi-Fi.
We're going to do some applications about that in the upcoming Electra's.