However I'm using similar code to do other things such as serial to tcp to tcp to serial bridges, several client's and server's are created in my main project. The following code is a cut down version of that same project, just to the web server part - and it uses up about 250 bytes per request, until of course it crashes.
#include <ESP8266WiFi.h>
String freeHeap;
WiFiServer webServer(80);
const char* html1 = "<!DOCTYPE html><html><head><meta name=\"viewport\" content=\"width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1\"/></head><body style=\"background-color:#EEE;font-family:Arial,Tahoma,Verdana;\"><h1>Title</h1>";
String html2 = "";
String req;
void setup() {
WiFi.mode(WIFI_STA);
WiFi.begin("wifiname","wifipass");
WiFi.config(IPAddress (192,168,1,201), IPAddress (192,168,1,1), IPAddress (255,255,255,0));
WiFi.softAPdisconnect(true);
webServer.begin();
}
void loop() {
WiFiClient webClient = webServer.available();
if (!webClient) {
delay(1);
return;
}
req = webClient.readStringUntil('\r');
// process request, incoming request looks fine
webClient.flush();
setHTML();
webClient.print(html1);
webClient.print(html2);
delay(1);
// webClient.stop();
}
void setHTML() {
long fh = ESP.getFreeHeap();
char fhc[20];
ltoa(fh, fhc, 10);
freeHeap = String(fhc);
html2 = "Heap " + freeHeap + "</body></html>";
}
Please help