This sample code will show you how to 1) create an access point, 2) serve a web page, 3) updated just changed data, and 4) get user interactions such as button presses and slider actions sent back to the microcontroller.
You will need an ESP32 and some open source libraries that are delivered with the Arduino IDE such ase WiFi.h, and WebServer.h
WARNING
The ESP32 web libraries have a default max size of a String set to 64K. For small html pages this may be fine, however pages that exceed 64K will fail to load the entire page. Here are a few options in reducing HTML page size
- remove all indents (granted they make code readable, but each indent is a character)
- minimize variable name lenghts consider changing ColorForForeground to FColor for example
- remove blank lines
If your page still exceeds 64K, just increase the buffer size in the library. To see what size you need add a Serial.println(sizeof(PAGE_MAIN)) in SendWebsite() to see what you need. To increase the String size, edit the parameter in:
C:\Users\Administrator\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.2\cores\esp32\WString.h
around line 335 change
//CAPACITY_MAX = 65535
CAPACITY_MAX = 80000 (80K is just and example)