Both ESP32 and ESP8266 are supported Web Server use me-no-dev/ESPAsyncWebServer Platform.io will check dependecy and download dependency libraries automatically. Tool bar at bottom , click Switch env icon to select Project and env
*env:esp32dev (01_esp32_Hello) folder*
*env:nodemcuv3 (01_esp32_Hello) folder*
Select esp32 and nodemcu environment You also can compiler both, platform.io will select right code and Serial to download, it takes longer.
[platformio]
default_envs = esp32dev
; default_envs = nodemcuv3
[platformio]
; default_envs = esp32dev
default_envs = nodemcuv3
We also define lib_extra_dirs in platform.ini , then platform.io will search this path. It is located in 00_esp32_littlefs/lib folder
lib_extra_dirs = ../00_esp32_littlefs/lib
#include <Arduino.h>
#include "debuglog.h" // log print
#include "ledpwm.h" // esp32 pin 2 can use pwm mode, ESP8266 cannot.
#include "WebServer.h" // i.e. ESPAsyncWebServer include...
config WIFI MODE in winit.cpp if STA modified SSID PASS in WiFiInit, the Server dispatchs some HTTP_GET and respones.
// 1. *** modified your SSID, PASSWORD pair
if (!WiFiInit(WIFI_STA_AUTO_MODE,"****", "********")) {
Serial.println("Error:Wifi fail");
return ;
}
// 2, start up Web Server
WebServerHello();
Click the pio tool bar upload icon, for clean build, you can delete .pio sub folder in explorer Window at first.
It will upload data folder to partition SPIFFS, it is OK. Click the pio tool bar terminal icon, then cli terminal will display, make sure path with your data then run command in terminal.
01_ESP32_Http_Hello % pio run -t uploadfs [enter]
Web Hello World
WiFiSTA()
WiFiSTAStatic(ssid SSID,pwd PASSWORD,ip, gw )
Config as auto IP
Connecting to WiFi...
..192.168.1.149
Server Starting...