ESP8266_AT_WebServer Library for Arduino, Teensy, SAMD, etc. boards using ESP8266 AT-command shields

Many people, me including, are using Arduino, Teensy, etc. boards with ESP8266 AT-Command shields. I haven’t seen a WebServer library, with similar features to ESP8266WebServer, to support this combination. That’s why we ,so far, still haven’t got a library similar to WiFiManager for Arduino, Teensy, etc.

This is the reason for me to finish this new ESP8266_AT_WebServer Library. The AT_WiFiManager will be in the to-do list.

This is simple yet complete WebServer library for AVR, Teensy, etc. boards running ESP8266 AT-command shields. The functions are similar and compatible to ESP8266/ESP32 WebServer libraries to make life much easier to port sketches from ESP8266/ESP32.

The library supports

  1. WiFi Client, STA and AP mode
  2. TCP Server and Client
  3. UDP Server and Client
  4. HTTP Server and Client
  5. HTTP GET and POST requests, provides argument parsing, handles one client at a time.

Library is based on and modified from:

  1. Ivan Grokhotkov’s ESP8266WebServer
  2. bportaluri’s WiFiEsp library

There currently are 14 examples:

  1. HelloServer
  2. HelloServer2
  3. AdvancedWebServer
  4. HttpBasicAuth
  5. PostServer
  6. SimpleAuthentication
  7. ConnectWPA
  8. ScanNetworks
  9. UdpNTPClient
  10. UdpSendReceive
  11. WebClient
  12. WebClientRepeating
  13. WebServer
  14. WebServerAP

This is the HelloServer

#include <ESP8266_AT_WebServer.h>

#ifdef CORE_TEENSY
  // For Teensy 4.0
  #define EspSerial Serial2   //Serial2, Pin RX2 : 7, TX2 : 8
  #if defined(__IMXRT1062__)
  #define BOARD_TYPE      "TEENSY 4.0"
  #elif ( defined(__MKL26Z64__) || defined(ARDUINO_ARCH_AVR) )
  #define BOARD_TYPE      "TEENSY LC or 2.0"
  #else
  #define BOARD_TYPE      "TEENSY 3.X"
  #endif

#else
// For Mega
#define EspSerial Serial3
#define BOARD_TYPE      "AVR Mega"
#endif

char ssid[] = "****";        // your network SSID (name)
char pass[] = "****";        // your network password

int status = WL_IDLE_STATUS;     // the Wifi radio's status
int reqCount = 0;                // number of requests received

ESP8266_AT_WebServer server(80);

const int led = 13;

void handleRoot() 
{
  server.send(200, "text/plain", "Hello from ESP8266_AT_WebServer!");
}

void handleNotFound()
{
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET)?"GET":"POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for (uint8_t i=0; i<server.args(); i++)
  {
    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
  }
  server.send(404, "text/plain", message);
  digitalWrite(led, 0);
}

void setup(void)
{
  // Open serial communications and wait for port to open:
  Serial.begin(115200);

  // initialize serial for ESP module
  EspSerial.begin(115200);
  // initialize ESP module
  WiFi.init(&EspSerial);

  Serial.println("\nStarting HelloServer on " + String(BOARD_TYPE));
  
  // check for the presence of the shield
  if (WiFi.status() == WL_NO_SHIELD) 
  {
    Serial.println(F("WiFi shield not present"));
    // don't continue
    while (true);
  }

  // attempt to connect to WiFi network
  while ( status != WL_CONNECTED) 
  {
    Serial.print(F("Connecting to WPA SSID: "));
    Serial.println(ssid);
    // Connect to WPA/WPA2 network
    status = WiFi.begin(ssid, pass);
  }
  
  server.begin();
  
  Serial.print("WebServer is @ ");
  Serial.println(WiFi.localIP());

  server.on("/", handleRoot);

  server.on("/inline", []()
  {
    server.send(200, "text/plain", "This works as well");
  });

  server.onNotFound(handleNotFound);

  server.begin();

  Serial.print(F("HTTP server started @ "));
  Serial.println(WiFi.localIP());
}

void loop(void)
{
  server.handleClient();
}

Update Feb 17th 2020

ESP8266_AT_WebServer libraries v1.0.0 just got included into Arduino Library Manager.
Now you can install this library directly from Arduino Library Manager.

Update Feb 17th 2020

Version v1.0.1

  1. Add support to server’s lambda function calls with dependency on Functional-VLPP library

Update Feb 22th 2020

New Version v1.0.2

  1. Add support to SAMD (DUE, ZERO, MKR, NANO_33_IOT, M0, M0 Pro, AdaFruit CIRCUITPLAYGROUND_EXPRESS, etc.) boards
2 Likes

Update July 4th 2020

New Version v1.0.9

  1. Fix bug.
  2. Add functions (ESP8266_AT_Drv::wifiDriverReInit and ESP8266_AT_Class::reInit).
  3. Restructure codes. Increase RingBuffer Size.
  4. Add support to WIS600-01S and W600 WiFi shields

New Version v1.0.8

  1. Fix bug.
  2. Add features to ESP32-AT.

New Version v1.0.7

  1. Add support to ESP32-AT-command shield.
  2. Update deprecated ESP8266-AT commands.
  3. Restructure examples to separate defines header files.

New Version v1.0.6

  1. Add support to nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B30_ublox, NINA_B112_ublox, etc.

New Version v1.0.5

  1. Add support to SAM51 (Itsy-Bitsy M4, Metro M4, Grand Central M4, Feather M4 Express, etc.) and SAM DUE.

New Version v1.0.4

  1. Sync with ESP8266WebServer library of ESP8266 core v2.6.3
  2. Fix bug.

New Version v1.0.3

  1. Add support to STM32 (STM32F0, F1, F2, F3, F4, F7, etc) boards