Hello, and welcome to this new lesson in which you are going to program SPF 32 using Arduino IDE.
You must have the Arduino I.D. installed and the SPF 30 to add on installed, as we explained in the
download and install section.
Now, after installing the necessary bold add ons, Kobe.
The add on file to our I.D., just as explained, then you can simply open Arduino to start coding.
Now, the first step that we are going to do is.
Create a new file on your sketch.
Now we need to include some libraries, so let's include the Wi-Fi Library.
And we also need to include.
They're TB Client Library.
And we need to include.
Any other labor that we might need for our project for now?
I will just stick with these two.
Now, if you did verify your code, it would ask you to save the code that sustained location.
So here we will save it.
Let's call it USP code.
And sale for here.
Done combining.
Now what you need to do is create a few variables.
We need to create variables for our wireless network credential.
So create a constant character and call it already.
And here you need to enter your network name and by network name is call.
I think I should have TV.
You know the semicolon.
Add another line consistent
character for the password.
And I think my password is this.
Something like that, anyway.
I'll change it later.
Now, let's move on to the ServerName.
Create a constant character.
For the server name and in the server name.
Well, I've got a place I call the domain name, and they are Alberth, all of the IP address with the
birth, depending on your hosting and our case, we need to copy this.
We need the post data filing, which is basically this one.
Okay, let me check this one out of domain name and post that BHP.
So go back here.
Best here tier depending on your domain name, this might be different, but this is what you need to
do.
Now, the next step is creating that API key value.
And we already mentioned that key on the BHP lesson,
and it must be identical to the one you used in your PSP.
And to do so, we will have to open up our PSP code.
And look for the.
API key value.
OK, here it is.
If I value to this one go back copy and based API key value.
Now you can create any other variable that you want.
You can create a variable for the Cinsault name.
Let's call it touch sensor and sense of location.
Let's call it Home Office since we are at home now.
What you need to do is go to the void setup methods and start the serial module at a specific rate.
Let's make it one hundred fifty.
Fifteen thousand two hundred.
Now we need to start the Wi-Fi connection.
Why if I just began using the SSA ID on the password that we used?
After that, we need to plant the serum on a line stating that we are connecting so right connecting
to the Wi-Fi network.
OK, now to make sure that we don't have any errors, we need to check and to print the local IP address
that we get from our I find it work.
So let's add this one statement.
By the way, you can copy the lifecycle from the examples if you want here examples and if you want
the ISP.
You can't simply.
Look for the wife I.
And as you can see here, why fi, if you check the Wi-Fi scan, you can see.
Called for wifey.
And as you can see, if I disconnect white flight mode, you can edit the code or use it.
And now it's checking and printing, that's a.
You can use this code or you can copy our code.
They both work the same.
Now regarding Wi-Fi, but you have to edit them all the codes to allow us to TBE Post and BHP Connection.
Anyway, let's proceed now, though.
I find when you check that the Wi-Fi status.
Wi-Fi connected.
To make sure that we are connected and then we cannot talk, kill the parentheses.
Now between these two kind of emphases, this at some delay
to make sure that we are giving all these people enough time to connect and let's sprint adopt to indicate
that we did reach this point.
OK, now after the wild statement, we can print an empty string.
Then we can't print another line stating that we are connected to the Wi-Fi with a certain IP address
to make sure that we have an IP address.
OK, now why fi is connected
using this IP address
and now to print the IP address and Wi-Fi network, we can use Siri on that trend line and inside it
we need to call wi fi
dot local IP.
So it will print the IP that RSP received.
From the life hereafter now, after doing all of this, we can.
Starred that TB process now to start review process, you need to go to the Void Globe and write a simple
statement inside that if we need to make sure that our Wi-Fi is connected correctly, so we will use
Wi-Fi status equal wireless connected.
Now disconnected what we need right here.
Is first, create an STB.
Client, object and name, it should be now your domain name, who they are, path or IP address must
be passed to the CTP object code using this line.
Look how I began.
And inside it you collect server name, which is basically the server name that we did type here.
Make sure to write it correctly.
We have in capital.
OK.
After that, we need to specify content type header to make sure that we are passing the right values
to our web page, the essential values and other reading, not CTP, dot and header.
This method is the one that you are going to use to send data.
Not one sided.
You need to write content type, then add a column.
And drive this line, fight application slash x w w w form on you are all.
And codes now this line can be found online.
It's easy, and you have to send it before you start fighting that.
Now, the next step is to prepare our FTB request data and the data that we would send in that TV request
is basically the key Typekit iki the sensor location on the sensor name and the value number one value,
number three, two and three.
And these all of these that are will be sent in a string.
So we have to prepare that strings, create a new string quartet TB, request data and start passing
the values.
The first value will be API underscored key and need to a plus sign right API key value.
Which is basically the key value that we did assign at the beginning of our.
Codes here.
Now you need to try the same variables now, plus sign, what we are doing now is we are concatenating
a string with the values that we need to send.
So after that, we need to send the sensor data so we will right and sensor.
Data.
Equal and you are the plus sign and send the.
The variable we've called since your name.
After that, we will send the sense of location you can add on and sign and drive that location
equal.
And we will add since of location.
Here they add another plus sign and start adding different values and value on equal.
And we will add a string.
Let's call it value one.
We can add any other variable here, but since we haven't assigned any variable, we can't seem to right
the value one.
And you can't keep doing this for the other two.
OK.
Now, the value of three for this one value, two for this one.
So it will send value on value to one value three, we can assign variables for this one.
But let's leave them this at this point.
Now after we prepared this request.
As you can see, we need to add a semicolon here,
and we need to add cereal, dot, print
and.
We are going to print, is this story request data?
So let's try it again.
So it will plant the requested that now.
That's it for this lesson, and the next that's not going to proceed with the.
Well, I think our code and making sure that it works for the U.S. people and that it will send data
to our website.
Thanks for watching this lesson.
If you have any question about any line of code, I'm here to help you.
See you next.
This is Ashraf from educational engineering team.