Controllerstech-Co
Controllerstech-Co
Controllerstech-Co
Although I will demonstrate a small use of it, but you can use it for a wide
range of purposes. For eg- sending the sensor values, or receiving some
form data, etc. This tutorial will use the Ringbuffer and you should take a
look at that article first.
ADVERTISEMENT
Those, who have errors in the Uart_isr function, eg- F7 series MCU,
replace the Uart_isr functon with the one provided in this file
https://controllerstech.com/wp-
content/uploads/2020/04/Uart_Isr_single.c
Connection
connection
The connection is simple. Just connect the Rx of the MCU to the Tx of the
ESP, and vice versa.
CubeMX SETUP
All we need to do is just enable a UART. Below is my Cubemx setup. I am
using baud rate of 115200 and make sure that the interrupt is enabled.
uart1 setup
Next, copy the required header files and source files in the inc and src
directories respectively. These files are located under /src and /inc folders
of the code attached below. You should also copy them to the same
locations in your project.
last we need to replace the default ISR with the one we have. So browse
down the file to the void USART1_IRQHandler(void) and replace the
default ISR just as shown in the picture below
This completes the setup part Now let’s take a look inside some functions
available.
ESP_Init
ESP Init
Ringbuf_init();
Uart_sendstring("AT+RST\r\n");
HAL_Delay(2000);
/********* AT **********/
Uart_flush();
Uart_sendstring("AT\r\n");
while(!(Wait_for("OK\r\n")));
Next, we will connect to this IP address, but make sure the device and the
ESP should be connected to the same network. The Webserver page will
look like as shown below
home page
Server_Start
Server start
Link_ID -= 48;
while (!(Copy_upto(" HTTP/1.1", buftostoreheader)));
if (Look_for("/page1", buftostoreheader) == 1)
{
GetDataFromBuffer("fname=", "&", buftostoreheader, user[
GetDataFromBuffer("lname=", "&", buftostoreheader, user[
GetDataFromBuffer("age=", " HTTP", buftostoreheader, use
usernumber++;
if (usernumber >9) usernumber = 0;
Server_Handle("/page1",Link_ID);
}
If the request is made for the page1 (submit), it will first store the data
entered into the structure (user), and then call the server_handle to
handle that request
if the request is about page2 (View Data) or home, then the server
handle is called directly to handle these requests
Server_Handle
Server Handle
In order to handle the request for page2 (View Data), it will first format
the data from the structure (user) along with some HTML table
syntax, and then send this data to the server
For any other request, it will simply send the respective HTML code
(defined in the beginning of ESP_DATA_HANDLER.c file) to the
server.
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
In the main function, we will simply initialize the ESP with the SSID,
PASSWORD, and the IP address that we need to set.
···
Result
Below are the pictures for all the three pages
HomePage
Submit page
View page
DOWNLOAD SECTION
···
Info
You can help with the development by DONATING
To download the code, click DOWNLOAD button and view the Ad. The project
will download after the Ad is finished.
DOWNLOAD DONATE
Related Posts:
GPS (Neo 6M) with STM32 TouchGFX #5. Data from UART to
UI
marco
September 22, 2023 10:40 PM
Reply
Safsoun
February 18, 2022 5:24 PM
Reply
trymybest
December 7, 2022 9:08 PM
Reply
La1234
February 15, 2022 2:04 PM
Good jobs
Reply
Samet Yazıcı
August 15, 2021 11:13 PM
Reply
Karl Simmons
May 3, 2021 4:40 PM
Great tutorial, it works for me!:)
I have an additional question: is it possible to create
web server this method, but with possibility to access
esp web-server anywhere the world? At the moment
I can connect from smartphone or PC but only if that
devices are connected the same wifi hotspot as ESP
module :c
Reply
Pushpam
October 14, 2020 12:36 PM
Reply
admin
October 14, 2020 1:45 PM
i am looking into it
Reply
mohammad
September 20, 2020 1:34 PM
Reply
Neil
August 29, 2020 4:51 AM
Nice.
A few of comments:
Reply
admin
August 29, 2020 10:21 AM
Reply
Leave a Reply
Comment *
Name *
Email *
Post Comment
ABOUT US
DONATE HERE
Search