0:18
everyone welcome to controllers tech
0:22
i have already covered how to create web
0:25
server using esp8266 and sdm32
0:30
in that tutorial we were able to blink
0:39
this is another tutorial which uses web
0:42
but this time we will actually transfer
0:46
this data transfer will be in both the
0:50
let's start by creating the project in
1:00
give some name to the project and click
1:09
in the cube mx first of all i am
1:11
selecting the external hse crystal for
1:19
now the esp is connected to the uart one
1:23
so we need to enable it i am leaving the
1:27
5 200. also make sure that you have
1:32
enabled the interrupt
1:39
now the clock setup i have eight
1:43
and i want to run the system at maximum
1:52
click save to generate this project
1:57
regarding the connection just connect
1:59
the rx of esp to the tx of the mcu
2:02
and vice versa also connect the chpd pin
2:08
as shown in the picture
2:15
here is our project let's first copy the
2:26
you can find these files in the source
2:30
after downloading the code these
2:32
libraries are basically for the ring
2:35
and some esp related functions
2:45
let's take a look at the esp data
2:50
but before that the uart ring buffer
2:57
here you need to define the uart that
3:01
now we need to copy this function and
3:04
put it in the interrupt file
3:12
also we need to change the default
3:16
with the one that we have in ring buffer
3:35
these are functions present in the ring
3:39
these all are all the old functions
3:44
this is the new one i have added
3:53
get data from buffer let's
4:06
this function copies the data from the
4:09
the data that we want to copy lies
4:12
between the start string
4:13
and the end string buffer to copy from
4:17
and buffer to copy into are
4:21
that's the only addition in ring buffer
4:24
now let's see the esp data handler
4:40
here also we need to define the uart
4:43
which is connected to the esp the
4:46
maximum number of user data
4:49
that you want to store
4:53
user detail is basically a structure
4:56
which contains first name
4:58
last name and the age of the user
5:01
you can add more elements here or change
5:04
the structure to something useful for
5:17
this is just a function to find how many
5:20
users data is collected so far
5:23
here i have defined the string from the
5:28
i have included the html file also
5:31
in case you want to see the details
5:43
this part here covers the home page
5:50
this is for page 1 which will be called
5:52
after we submit the data
5:58
and this is for viewing the data
6:04
this at the bottom is the table syntax
6:06
that i have used to format the data
6:09
so that it looks organized
6:15
basically this is how the home page
6:18
looks this is page 1.
6:25
and this is page 2 which looks a little
6:29
but it will be fine once we load the
6:32
now let's see the function esp in it
6:36
these are some a-t commands that we need
6:40
in order to set it for the web server
6:43
first of all initialize the ring buffer
6:50
a t is sent to confirm that it's working
6:53
and sending the response back cw mode
6:56
equals 1 will set the esp to station
7:01
now we will set a static ip address
7:05
at plus sip sta is used to do that
7:10
the ip address is the part of the
7:12
parameter of esp init
7:15
cw will make the esp to join the
7:21
we don't need to query for the ip
7:23
address since we are already using
7:31
turn on the multiple connections and
7:34
start the server at port 80.
7:36
this is all for the initialization part
7:40
now let's see the server start
7:43
here first we will get the link number
7:45
of the request made by the browser
7:48
this is because we will have to send the
7:51
data to the same link number
7:54
if the browser made the request about
7:55
page 1 that means the data needs to be
7:59
this function will copy the data from
8:01
the browser and store it into the
8:04
and then call the server handle to
8:09
this is basically this page right here
8:12
in case of any other request it will
8:14
simply call the server handle to handle
8:24
let's see the server handle now
8:27
if the request is made about page 2 that
8:30
is the view data page
8:32
then it will first calculate how many of
8:34
the users data has been collected
8:37
it will then copy that data from the
8:39
structure format it in html code
8:42
along with the table syntax and send it
8:46
in case the request is made about any
8:49
the respective html code will be sent to
8:58
that's all regarding the esp data
9:00
handler now let's write the program
9:10
first of all include the esp data
9:14
file now in the main function
9:17
we will initialize the esp
9:20
here the parameters are ssid password
9:24
and the ip address that you want to set
9:34
in the while loop call the server start
9:38
do not give any delay here build the
9:43
we don't have any errors let's debug it
10:12
you can see the rx buffer here our last
10:15
command got executed it will take around
10:18
four to five seconds for the
10:22
let's open the browser and go to the ip
10:27
so we got our home page
10:30
before entering any data let's view the
10:34
as expected there is nothing here
10:38
i will enter information for some users
10:58
let's view the data now here we have all
11:16
let's enter one more time
11:20
and the new one is also added
11:23
i have set the maximum number of users
11:26
so the 11th user's data will override
11:35
so as you saw we can receive and send
11:38
data to the web server using sdm32
11:42
you can use the same logic for sending
11:46
or some temperature values or receiving
11:48
some pwm values to control the fan etc
11:53
this is it for this video i hope you
11:56
understood the procedure
11:59
you can download the code from the link
12:03
keep watching and have a nice day