資料很少。可能是國外網站的。html
百度搜基本出來的是這個網站https://www.dfrobot.com/blog-922.htmlgit
出來的代碼是:github
#include <WiFi.h>
#include <FS.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
const char* ssid = "yourNetworkName";
const char* password = "yourNetworkPassword";
AsyncWebServer server(80);
void setup(){
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi..");
}
Serial.println(WiFi.localIP());
server.on("/html", HTTP_GET, [](AsyncWebServerRequest *request){
request->send(200, "text/html", "<p>This is HTML!</p>");
});
server.begin();
}
void loop(){
}ide
發愁:這個庫在哪裏?我怎麼運行?因而我找到了這裏:oop
https://github.com/me-no-dev/ESPAsyncWebServer網站
裏面使用ESPAsyncWebServer的步驟ui
以下:spa
1 安裝:PlatformIO IDE.net
這裏有詳細教材:https://blog.csdn.net/baimei4833953/article/details/78771611/code
2 建立新的工程:"PlatformIO Home > New Project"
http://docs.platformio.org/en/latest/ide/vscode.html
3 修改配置文件
Add "ESP Async WebServer" to project using Project Configuration File platformio.ini
and lib_deps option:
#include <WiFi.h> #include <FS.h> #include <AsyncTCP.h> #include <ESPAsyncWebServer.h> const char *ssid = "MyESP32AP"; const char *password = "testpassword"; AsyncWebServer server(80); void setup(){ Serial.begin(115200); WiFi.softAP(ssid, password); Serial.println(); Serial.print("IP address: "); Serial.println(WiFi.softAPIP()); server.on("/hello", HTTP_GET, [](AsyncWebServerRequest *request){ request->send(200, "text/plain", "Hello World"); }); server.begin(); } void loop(){}
編譯運行下載,搞定。。。。