How to configure device to connect to a Wifi Access Point¶
This tutorial shows how to use a web application to setup the ESP32 WiFi connection in Station mode to send data to a web server. It can be separated in to two steps.
- Design the web application in Aimagin Connect.
- Implement the Simulink model
Design the web application in Aimagin Connect¶
The designing of the web page is described step by step in Develop web application for ESP32 to setup WiFi Station mode.
Refer Webapp publishing and Exporting to ESP32 sections to get a better understanding about publishing a web application on Aimagin Connect and export those web apps to ESP32 Aimagin Connect server.
The final web page is as below
Implement the Simulink model¶
The procedure for this tutorial is as follows:
First the ESP32 should be initialized the WiFi in Access Point mode to initialize the Aimaigin Connect server. Then the user an be able to access the Aimagin connect server and configure the WiFi configuration using the created wep page in ESP32 for Station mode to connect to the internet to send the data to a server. After submitted the configuration data and logout from the Aimagin connect the ESP32 will get the WiFi configuration data from the database and switch the WiFi mode from Access Point mode to Station mode. Then the ESP32 connect to the internet and send the data to the target server.
Following figure shows how to setup the WiFi in AP mode
In the Subsystem the Aimagin Connect Server is setup and once the user is logged out from the server the output status from the Aimagin Connect server block goes to 0 and then the Aimagin Connect server stops. Then the SSID and Password data is acquired from the database which the user configured using the web page in the database subsystem as follows.
In sending data to the server subsystem some dummy data is sent to the target server as in the following figure.
The results of the sent data to the server is as follows
The Simulink model file can be found below