ESP8266_AT_WebServer
ESP8266_AT_WebServer copied to clipboard
This is simple yet complete WebServer library for AVR, Teensy, SAM DUE, SAMD, STM32, nRF52, etc. boards running ESP8266 AT-command shields. The functions are similar and compatible to ESP8266/ESP32 We...
ESP8266_AT_WebServer
Table of Contents
- Important Note from v1.6.0
- Why do we need this ESP8266_AT_WebServer library
- Features
- Currently Supported Boards
- Currently Supported AT-command shields
- Changelog
- Prerequisites
- Important Notes about AT Firmwares
- 1. Tested OK with ESP8266-AT shields
- 2. Tested OK with ESP32-AT shields
- 3. Where to upload AT-Firmware
- 4. Important Notes
- Installation
- Use Arduino Library Manager
- Manual Install
- VS Code & PlatformIO
- Packages' Patches
- 1. For Adafruit nRF52840 and nRF52832 boards
- 2. For Teensy boards
- 3. For Arduino SAM DUE boards
- 4. For Arduino SAMD boards
- For core version v1.8.10+
- For core version v1.8.9-
- 5. For Adafruit SAMD boards
- 6. For Seeeduino SAMD boards
- 7. For STM32 boards
- 7.1. For STM32 boards to use LAN8720
- 7.2. For STM32 boards to use Serial1
- 8. For RP2040-based boards using Earle Philhower arduino-pico core
- 8.1. To use BOARD_NAME
- 8.2. To avoid compile error relating to microsecondsToClockCycles
- 9. For Portenta_H7 boards using Arduino IDE in Linux
- 10. For RTL8720DN boards using AmebaD core
- 11. For SAMD21 and SAMD51 boards using ArduinoCore-fab-sam core
- 12. For Seeeduino RP2040 boards
- 13. For Seeeduino nRF52840 boards
- Usage
- Class Constructor
- Basic Operations
- Advanced Options
- Other Function Calls
- Examples
- 1. AdvancedWebServer
- 2. AdvancedWebServer_STM32
- 3. ConnectWPA
- 4. HelloServer
- 5. HelloServer2
- 6. HttpBasicAuth
- 7. MQTTClient_Auth
- 8. MQTTClient_Basic
- 9. MQTT_ThingStream
- 10. PostServer
- 11. ScanNetworks
- 12. SimpleAuthentication
- 13. UdpNTPClient
- 14. UdpSendReceive
- 15. WebClient
- 16. WebClientRepeating
- 17. WebServer
- 18. WebServerAP
- 19. ATWebServer_BigData New
- Example AdvancedWebServer
- 1. File AdvancedWebServer.ino
- 2. File defines.h
- Debug Terminal Output Samples
- 1. AdvancedWebServer on Adafruit NRF52840_ITSYBITSY_EXPRESS using ESP8266-AT shield
- 2. MQTT_ThingStream on Adafruit SAMD51 ITSYBITSY_M4 using ESP8266-AT shield
- 3. MQTTClient_Auth on Adafruit SAMD51 ITSYBITSY_M4 using ESP8266-AT shield
- 4. MQTTClient_Basic on Adafruit SAMD51 ITSYBITSY_M4 using ESP8266-AT shield
- 5. WebClientRepeating on RASPBERRY_PI_PICO using ESP8266-AT shield
- 6. MQTTClient_Auth on RASPBERRY_PI_PICO using ESP8266-AT shield
- 7. UdpNTPClient on MBED RASPBERRY_PI_PICO using ESP8266-AT shield
- 8. AdvancedWebServer on NRF52840_ITSYBITSY
- 9. ATWebServer_BigData on NRF52840_ITSYBITSY
- 10. AdvancedWebServer on WIZNET_WIZFI360_EVB_PICO
- Screen Shots
- 1. SAMD51 Itsy-Bitsy M4
- 2. STM32 Nucleo-144 NUCLEO_F767ZI
- 3. nRF52 Itsy-Bitsy nRF52840
- 4. Seeeduino SEEED_XIAO_M0
- 5. RASPBERRY_PI_PICO
- 6. MBED RASPBERRY_PI_PICO
- 7. nRF52 Itsy-Bitsy nRF52840 BigData
- Debug
- Troubleshooting
- Issues
- TO DO
- DONE
- Contributions and Thanks
- Contributing
- License
- Copyright
Important Note from v1.6.0
The new ESP8266_AT_WebServer v1.7.1+ fixes severe limitation to permit sending much larger data than total than 2K buffer of ESP8266/ESP32 AT-command shield.
Why do we need this ESP8266_AT_WebServer library
Features
This ESP8266_AT_WebServer library is a simple yet complete WebServer library for AVR, Teensy, SAM DUE, Arduino SAMD21, Adafruit SAMD21/SAMD51, Adafruit nRF52, STM32F/L/H/G/WB/MP1, etc. boards, using ESP8266/ESP32 AT-command WiFi modules/shields.
The functions are similar and compatible to those of ESP32 WebServer and ESP8266WebServer libraries to make life much easier to port sketches from ESP8266/ESP32.
The library provides supports to:
- WiFi Client, STA and AP mode
- TCP Server and Client
- UDP Server and Client
- HTTP Server and Client
- HTTP GET and POST requests, provides argument parsing, handles one client at a time.
- UDP Multicast and Broadcast.
It is based on and modified from:
The ESP8266_AT_Web_Server class found in ESP8266_AT_Web_Server.h header, is a simple web server that knows how to handle HTTP requests such as GET and POST and can only support one simultaneous client.
Currently Supported Boards
-
nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox, etc.
-
SAM DUE
-
SAMD21
- Arduino SAMD21: ZERO, MKRs, NANO_33_IOT, etc.
- Adafruit SAMD21 (M0): ItsyBitsy M0, Feather M0, Feather M0 Express, Metro M0 Express, Circuit Playground Express, Trinket M0, PIRkey, Hallowing M0, Crickit M0, etc.
- Seeeduino: LoRaWAN, Zero, Femto M0, XIAO M0, Wio GPS Board, etc.
- SAMD51
- Adafruit SAMD51 (M4): Metro M4, Grand Central M4, ItsyBitsy M4, Feather M4 Express, Trellis M4, Metro M4 AirLift Lite, MONSTER M4SK Express, Hallowing M4, etc.
- Seeeduino: Wio Terminal, Grove UI Wireless
-
Teensy (4.1, 4.0, 3.6, 3.5, 3,2, 3.1, 3.0, LC)
-
STM32F/L/H/G/WB/MP1 boards (with 64+K Flash)
- Nucleo-144
- Nucleo-64
- Discovery
- Generic STM32F0, STM32F1, STM32F2, STM32F3, STM32F4, STM32F7 (with 64+K Flash): x8 and up
- STM32L0, STM32L1, STM32L4, STM32L5
- STM32G0, STM32G4
- STM32H7
- STM32WB
- STM32MP1
- LoRa boards
- 3-D printer boards
- Generic Flight Controllers
- Midatronics boards
-
SIPEED_MAIX_DUINO boards
-
RP2040-based boards, such as Nano RP2040 Connect, using Arduino mbed OS for Nano boards.
-
RP2040-based boards, such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, using Arduino-mbed RP2040 core or Earle Philhower's arduino-pico core.
-
WIZNET_WIZFI360_EVB_PICO using Earle Philhower's arduino-pico core
WIZNET_WIZFI360_EVB_PICO
Currently Supported AT-command shields
ESP8266-AT-commandshieldESP32-AT-commandshieldW600andWIS600-01SAT-command shieldWizFi360AT-command shield
WIZFI360
Prerequisites
Arduino IDE 1.8.19+for Arduino.Arduino AVR core 1.8.6+for Arduino (Use Arduino Board Manager) for AVR boards.Teensy core v1.57+for Teensy 4.1.Arduino SAM DUE core v1.6.12+for SAM DUE ARM Cortex-M3 boards.Arduino SAMD core 1.8.13+for SAMD ARM Cortex-M0+ boards.Adafruit SAMD core 1.7.11+for SAMD ARM Cortex-M0+ and M4 boards (Nano 33 IoT, etc.).Seeeduino SAMD core 1.8.3+for SAMD21/SAMD51 boards (XIAO M0, Wio Terminal, etc.).Adafruit nRF52 v1.3.0+for nRF52 boards such as Adafruit NRF52840_FEATHER, NRF52832_FEATHER, NRF52840_FEATHER_SENSE, NRF52840_ITSYBITSY, NRF52840_CIRCUITPLAY, NRF52840_CLUE, NRF52840_METRO, NRF52840_PCA10056, PARTICLE_XENON, NINA_B302_ublox, etc.. Please remember to use latest
Packages_Patchesor getting compiler errors.Arduino Core for STM32 v2.4.0+for STM32F/L/H/G/WB/MP1 boards.Arduino mbed_rp2040 core 3.5.4+for Arduino (Use Arduino Board Manager) RP2040-based boards, such as Arduino Nano RP2040 Connect, RASPBERRY_PI_PICO, etc..Earle Philhower's arduino-pico core v2.7.1+for RP2040-based boards such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, etc.Sipeed Maixduino core v0.3.11+for K210-RISC-V-based boards such as Maixduino AI Development Kit K210 RISC-V AI + IoT ESP32, Sipeed Maix Go, Sipeed Maix Bit, etc.Functional-Vlpp library v1.0.2+to use server's lambda function. To install. checkAi-Thinker AT Firmware v1.5.4orAT Firmware v1.7.4.0for ESP8266-AT shields.AT version_2.1.0.0_devfor ESP32-AT shields.AT version_1.1.4forWIS600-01SandW600-ATWiFi shieldsAT version 3.2.0forWizFi360WiFi shields
Important Notes about AT Firmwares
1. Tested OK with ESP8266-AT shields
-
AT version:1.1.0.0(May 11 2016 18:09:56) SDK version:1.5.4(baaeaebb) Ai-Thinker Technology Co. Ltd. Jun 13 2016 11:29:20 -
AT version:1.7.4.0(May 11 2020 19:13:04) SDK version:3.0.4(9532ceb) compile time:May 27 2020 10:12:17 Bin version(Wroom 02):1.7.4 -
WIS600-01SandW600using either ESP8266 or ESP32-AT commands and stock firmwareAT version:1.1.4(Dec 05 2018 11:06:45) SDK version:3.0.0 Dec 05 2018 11:06:45
2. Tested OK with ESP32-AT shields
-
AT version:2.1.0.0-dev(4f6b92c - Jun 10 2020 10:36:54) SDK version:v4.0.1-193-ge7ac221b4 compile time(b85a8df):Jun 18 2020 14:00:59 Bin version:2.0.0(WROOM-32)See instructions at AT Command Core and ESP_AT_Get_Started
3. Where to upload AT-Firmware
Upload AT Firmware v1.7.4.0 bin files to correct locations as follows:
# BOOT MODE
### Flash size 8Mbit: 512KB+512KB
boot_v1.2+.bin 0x00000
user1.1024.new.2.bin 0x01000
esp_init_data_default.bin 0xfc000
blank.bin 0x7e000 & 0xfe000
### Flash size 16Mbit-C1: 1024KB+1024KB
boot_v1.2+.bin 0x00000
user1.2048.new.5.bin 0x01000
esp_init_data_default.bin 0x1fc000
blank.bin 0xfe000 & 0x1fe000
4. Important Notes
-
Test before using different AT-Firmware Version at your own risks. Just use any simple example to verify if the AT-firmware is OK.
-
Compatible AT-Firmare version will be updated. Check for all supported AT Firmwares and download them from AT_Firmwares.
-
Support to ESP32-AT-command shields has been added to permit using new library ESP_AT_Lib to replace Blynk's BlynkESP8266_Lib. The same ESP_AT_Lib can also be use for ESP8266-AT shields.
Installation
Use Arduino Library Manager
The best and easiest way is to use Arduino Library Manager. Search for ESP8266_AT_Web_Server, then select / install the latest version.
You can also use this link for more detailed instructions.
Manual Install
- Navigate to ESP8266_AT_WebServer page.
- Download the latest release
ESP8266_AT_WebServer-master.zip. - Extract the zip file to
ESP8266_AT_WebServer-masterdirectory - Copy whole
ESP8266_AT_WebServer-masterfolder to Arduino libraries' directory such as~/Arduino/libraries/.
VS Code & PlatformIO:
- Install VS Code
- Install PlatformIO
- Install ESP8266_AT_WebServer library by using Library Manager. Search for ESP8266_AT_WebServer in Platform.io Author's Libraries
- Use included platformio.ini file from examples to ensure that all dependent libraries will installed automatically. Please visit documentation for the other options and examples at Project Configuration File
Packages' Patches
1. For Adafruit nRF52840 and nRF52832 boards
To be able to compile, run and automatically detect and display BOARD_NAME on nRF52840/nRF52832 boards, you have to copy the whole nRF52 Packages_Patches directory into Adafruit nRF52 directory (~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0).
Supposing the Adafruit nRF52 version is 1.3.0. These files must be copied into the directory:
~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/platform.txt~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/boards.txt~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Udp.h~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Print.h~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Print.cpp~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/variants/NINA_B302_ublox/variant.h~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/variants/NINA_B302_ublox/variant.cpp~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/variants/NINA_B112_ublox/variant.h~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/variants/NINA_B112_ublox/variant.cpp~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Udp.h
Whenever a new version is installed, remember to copy these files into the new version directory. For example, new version is x.yy.z These files must be copied into the directory:
~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/platform.txt~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/boards.txt~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/cores/nRF5/Udp.h~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/cores/nRF5/Print.h~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/cores/nRF5/Print.cpp~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B302_ublox/variant.h~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B302_ublox/variant.cpp~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B112_ublox/variant.h~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B112_ublox/variant.cpp~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/cores/nRF5/Udp.h
2. For Teensy boards
To be able to compile and run on Teensy boards, you have to copy the files in Packages_Patches for Teensy directory into Teensy hardware directory (./arduino-1.8.19/hardware/teensy/avr/boards.txt).
Supposing the Arduino version is 1.8.19. These files must be copied into the directory:
./arduino-1.8.19/hardware/teensy/avr/boards.txt./arduino-1.8.19/hardware/teensy/avr/cores/teensy/Stream.h./arduino-1.8.19/hardware/teensy/avr/cores/teensy3/Stream.h./arduino-1.8.19/hardware/teensy/avr/cores/teensy4/Stream.h
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz These files must be copied into the directory:
./arduino-x.yy.zz/hardware/teensy/avr/boards.txt./arduino-x.yy.zz/hardware/teensy/avr/cores/teensy/Stream.h./arduino-x.yy.zz/hardware/teensy/avr/cores/teensy3/Stream.h./arduino-x.yy.zz/hardware/teensy/avr/cores/teensy4/Stream.h
3. For Arduino SAM DUE boards
To be able to compile and run on SAM DUE boards, you have to copy the whole SAM DUE directory into Arduino sam directory (~/.arduino15/packages/arduino/hardware/sam/1.6.12).
Supposing the Arduino SAM core version is 1.6.12. This file must be copied into the directory:
~/.arduino15/packages/arduino/hardware/sam/1.6.12/platform.txt
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz This file must be copied into the directory:
~/.arduino15/packages/arduino/hardware/sam/x.yy.zz/platform.txt
4. For Arduino SAMD boards
To be able to compile, run and automatically detect and display BOARD_NAME on Arduino SAMD (Nano-33-IoT, etc) boards, you have to copy the whole Arduino SAMD Packages_Patches directory into Arduino SAMD directory (~/.arduino15/packages/arduino/hardware/samd/1.8.13).
For core version v1.8.10+
Supposing the Arduino SAMD version is 1.8.13. Now only one file must be copied into the directory:
~/.arduino15/packages/arduino/hardware/samd/1.8.13/platform.txt
Whenever a new version is installed, remember to copy this files into the new version directory. For example, new version is x.yy.zz
This file must be copied into the directory:
~/.arduino15/packages/arduino/hardware/samd/x.yy.zz/platform.txt
For core version v1.8.9-
Supposing the Arduino SAMD version is 1.8.9. These files must be copied into the directory:
~/.arduino15/packages/arduino/hardware/samd/1.8.9/platform.txt~/.arduino15/packages/arduino/hardware/samd/1.8.9/cores/arduino/Arduino.h
Whenever a new version is installed, remember to copy these files into the new version directory. For example, new version is x.yy.z
These files must be copied into the directory:
~/.arduino15/packages/arduino/hardware/samd/x.yy.z/platform.txt~/.arduino15/packages/arduino/hardware/samd/x.yy.z/cores/arduino/Arduino.h
This is mandatory to fix the notorious Arduino SAMD compiler error. See Improve Arduino compatibility with the STL (min and max macro)
...\arm-none-eabi\include\c++\7.2.1\bits\stl_algobase.h:243:56: error: macro "min" passed 3 arguments, but takes just 2
min(const _Tp& __a, const _Tp& __b, _Compare __comp)
Whenever the above-mentioned compiler error issue is fixed with the new Arduino SAMD release, you don't need to copy the Arduino.h file anymore.
5. For Adafruit SAMD boards
To be able to compile, run and automatically detect and display BOARD_NAME on Adafruit SAMD (Itsy-Bitsy M4, etc) boards, you have to copy the whole Adafruit SAMD Packages_Patches directory into Adafruit samd directory (~/.arduino15/packages/adafruit/hardware/samd/1.7.11).
Supposing the Adafruit SAMD core version is 1.7.11. These files must be copied into the directory:
~/.arduino15/packages/adafruit/hardware/samd/1.7.11/platform.txt~/.arduino15/packages/adafruit/hardware/samd/1.7.11/cores/arduino/Print.h~/.arduino15/packages/adafruit/hardware/samd/1.7.11/cores/arduino/Print.cpp
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz These files must be copied into the directory:
~/.arduino15/packages/adafruit/hardware/samd/x.yy.zz/platform.txt~/.arduino15/packages/adafruit/hardware/samd/x.yy.zz/cores/arduino/Print.h~/.arduino15/packages/adafruit/hardware/samd/x.yy.zz/cores/arduino/Print.cpp
6. For Seeeduino SAMD boards
To be able to compile, run and automatically detect and display BOARD_NAME on Seeeduino SAMD (XIAO M0, Wio Terminal, etc) boards, you have to copy the whole Seeeduino SAMD Packages_Patches directory into Seeeduino samd directory (~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3).
Supposing the Seeeduino SAMD core version is 1.8.3. These files must be copied into the directory:
~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3/platform.txt~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3/cores/arduino/Arduino.h~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3/cores/arduino/Print.h~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3/cores/arduino/Print.cpp
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz These files must be copied into the directory:
~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/platform.txt~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/cores/arduino/Arduino.h~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/cores/arduino/Print.h~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/cores/arduino/Print.cpp
7. For STM32 boards
7.1 For STM32 boards to use LAN8720
To use LAN8720 on some STM32 boards
- Nucleo-144 (F429ZI, NUCLEO_F746NG, NUCLEO_F746ZG, NUCLEO_F756ZG)
- Discovery (DISCO_F746NG)
- STM32F4 boards (BLACK_F407VE, BLACK_F407VG, BLACK_F407ZE, BLACK_F407ZG, BLACK_F407VE_Mini, DIYMORE_F407VGT, FK407M1)
you have to copy the files stm32f4xx_hal_conf_default.h and stm32f7xx_hal_conf_default.h into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/2.3.0/system) to overwrite the old files.
Supposing the STM32 stm32 core version is 2.3.0. These files must be copied into the directory:
~/.arduino15/packages/STM32/hardware/stm32/2.3.0/system/STM32F4xx/stm32f4xx_hal_conf_default.hfor STM32F4.~/.arduino15/packages/STM32/hardware/stm32/2.3.0/system/STM32F7xx/stm32f7xx_hal_conf_default.hfor Nucleo-144 STM32F7.
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz, these files must be copied into the corresponding directory:
~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/system/STM32F4xx/stm32f4xx_hal_conf_default.h- `~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/system/STM32F7xx/stm32f7xx_hal_conf_default.h
7.2 For STM32 boards to use Serial1
To use Serial1 on some STM32 boards without Serial1 definition (Nucleo-144 NUCLEO_F767ZI, Nucleo-64 NUCLEO_L053R8, etc.) boards, you have to copy the files STM32 variant.h into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/2.3.0). You have to modify the files corresponding to your boards, this is just an illustration how to do.
Supposing the STM32 stm32 core version is 2.3.0. These files must be copied into the directory:
~/.arduino15/packages/STM32/hardware/stm32/2.3.0/variants/STM32F7xx/F765Z(G-I)T_F767Z(G-I)T_F777ZIT/NUCLEO_F767ZI/variant.hfor Nucleo-144 NUCLEO_F767ZI.~/.arduino15/packages/STM32/hardware/stm32/2.3.0/variants/STM32L0xx/L052R(6-8)T_L053R(6-8)T_L063R8T/NUCLEO_L053R8/variant.hfor Nucleo-64 NUCLEO_L053R8.
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz, these files must be copied into the corresponding directory:
~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/variants/STM32F7xx/F765Z(G-I)T_F767Z(G-I)T_F777ZIT/NUCLEO_F767ZI/variant.h~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/variants/STM32L0xx/L052R(6-8)T_L053R(6-8)T_L063R8T/NUCLEO_L053R8/variant.h
8. For RP2040-based boards using Earle Philhower arduino-pico core
8.1 To use BOARD_NAME
To be able to automatically detect and display BOARD_NAME on RP2040-based boards (RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040, GENERIC_RP2040, etc) boards, you have to copy the file RP2040 platform.txt into rp2040 directory (~/.arduino15/packages/rp2040/hardware/rp2040/1.4.0).
Supposing the rp2040 core version is 1.4.0. This file must be copied into the directory:
~/.arduino15/packages/rp2040/hardware/rp2040/1.4.0/platform.txt
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz This file must be copied into the directory:
~/.arduino15/packages/rp2040/hardware/rp2040/x.yy.zz/platform.txt
With core after v1.5.0, this step is not necessary anymore thanks to the PR Add -DBOARD_NAME="{build.board}" #136.
8.2 To avoid compile error relating to microsecondsToClockCycles
Some libraries, such as Adafruit DHT-sensor-library, require the definition of microsecondsToClockCycles(). To be able to compile and run on RP2040-based boards, you have to copy the files in RP2040 Arduino.h into rp2040 directory (~/.arduino15/packages/rp2040/hardware/rp2040/1.4.0).
Supposing the rp2040 core version is 1.4.0. This file must be copied to replace:
~/.arduino15/packages/rp2040/hardware/rp2040/1.4.0/cores/rp2040/Arduino.h
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz This file must be copied to replace:
~/.arduino15/packages/rp2040/hardware/rp2040/x.yy.zz/cores/rp2040/Arduino.h
With core after v1.5.0, this step is not necessary anymore thanks to the PR Add defs for compatibility #142.
9. For Portenta_H7 boards using Arduino IDE in Linux
To be able to upload firmware to Portenta_H7 using Arduino IDE in Linux (Ubuntu, etc.), you have to copy the file portenta_post_install.sh into mbed_portenta directory (~/.arduino15/packages/arduino/hardware/mbed_portenta/3.4.1/portenta_post_install.sh).
Then run the following command using sudo
$ cd ~/.arduino15/packages/arduino/hardware/mbed_portenta/3.4.1
$ chmod 755 portenta_post_install.sh
$ sudo ./portenta_post_install.sh
This will create the file /etc/udev/rules.d/49-portenta_h7.rules as follows:
# Portenta H7 bootloader mode UDEV rules
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="035b", GROUP="plugdev", MODE="0666"
Supposing the ArduinoCore-mbed core version is 3.4.1. Now only one file must be copied into the directory:
~/.arduino15/packages/arduino/hardware/mbed_portenta/3.4.1/portenta_post_install.sh
Whenever a new version is installed, remember to copy this files into the new version directory. For example, new version is x.yy.zz
This file must be copied into the directory:
~/.arduino15/packages/arduino/hardware/mbed_portenta/x.yy.zz/portenta_post_install.sh
10. For RTL8720DN boards using AmebaD core
To avoid compile error relating to PROGMEM, you have to copy the file Realtek AmebaD core pgmspace.h into Realtek AmebaD directory (~/.arduino15/packages/realtek/hardware/AmebaD/3.1.4/cores/ambd/avr/pgmspace.h).
Supposing the Realtek AmebaD core version is 3.1.4. This file must be copied into the directory:
~/.arduino15/packages/realtek/hardware/AmebaD/3.1.4/cores/ambd/avr/pgmspace.h
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz This file must be copied into the directory:
~/.arduino15/packages/realtek/hardware/AmebaD/x.yy.zz/cores/ambd/avr/pgmspace.h
11. For SAMD21 and SAMD51 boards using ArduinoCore-fab-sam core
To avoid compile error relating to SAMD21/SAMD51, you have to copy the file ArduinoCore-fab-sam core pgmspace.h into ArduinoCore-fab-sam samd directory (~/.arduino15/packages/Fab_SAM_Arduino/hardware/samd/1.9.0/boards.txt).
Supposing the ArduinoCore-fab-sam samd core version is 1.9.0. This file must be copied into the directory:
~/.arduino15/packages/Fab_SAM_Arduino/hardware/samd/1.9.0/boards.txt
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz This file must be copied into the directory:
~/.arduino15/packages/Fab_SAM_Arduino/hardware/samd/x.yy.zz/boards.txt
12. For Seeeduino RP2040 boards
To be able to compile, run and automatically detect and display BOARD_NAME on Seeeduino RP2040 (XIAO RP2040, Wio RP2040 Mini) boards, you have to copy the whole Seeeduino RP2040 Packages_Patches directory into Seeeduino samd directory (~/.arduino15/packages/Seeeduino/hardware/rp2040/2.7.2).
Supposing the Seeeduino RP2040 core version is 2.7.2. These files must be copied into the directory:
~/.arduino15/packages/Seeeduino/hardware/rp2040/2.7.2/boards.txt~/.arduino15/packages/Seeeduino/hardware/rp2040/2.7.2/variants/Seeed_XIAO_RP2040/pins_arduino.h
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz These files must be copied into the directory:
~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/boards.txt~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/variants/Seeed_XIAO_RP2040/pins_arduino.h
13. For Seeeduino nRF52840 boards
To be able to compile and run on Xiao nRF52840 boards, you have to copy the whole nRF52 1.0.0 directory into Seeeduino nRF52 directory (~/.arduino15/packages/Seeeduino/hardware/nrf52/1.0.0).
Supposing the Seeeduino nRF52 version is 1.0.0. These files must be copied into the directory:
~/.arduino15/packages/Seeeduino/hardware/nrf52/1.0.0/platform.txt~/.arduino15/packages/Seeeduino/hardware/nrf52/1.0.0/cores/nRF5/Print.h~/.arduino15/packages/Seeeduino/hardware/nrf52/1.0.0/cores/nRF5/Print.cpp~/.arduino15/packages/Seeeduino/hardware/nrf52/1.0.0/cores/nRF5/Udp.h
Whenever a new version is installed, remember to copy these files into the new version directory. For example, new version is x.yy.z These files must be copied into the directory:
~/.arduino15/packages/Seeeduino/hardware/nrf52/x.yy.z/platform.txt~/.arduino15/packages/Seeeduino/hardware/nrf52/x.yy.z/cores/nRF5/Print.h~/.arduino15/packages/Seeeduino/hardware/nrf52/x.yy.z/cores/nRF5/Print.cpp~/.arduino15/packages/Seeeduino/hardware/nrf52/x.yy.z/cores/nRF5/Udp.h
Usage
Class Constructor
ESP8266_AT_WebServer server(80);
Creates the ESP8266_AT_WebServer class object.
Parameters:
host port number: int port (default is the standard HTTP port 80)
Basic Operations
Starting the server
void begin();
Handling incoming client requests
void handleClient();
Disabling the server
void close();
void stop();
Both methods function the same
Client request handlers
void on();
void addHandler();
void onNotFound();
void onFileUpload();
Example:
server.on("/", handlerFunction);
server.onNotFound(handlerFunction); // called when handler is not assigned
server.onFileUpload(handlerFunction); // handle file uploads
Sending responses to the client
void send();
void send_P();
Parameters:
code - HTTP response code, can be 200 or 404, etc.
content_type - HTTP content type, like "text/plain" or "image/png", etc.
content - actual content body
Advanced Options
Getting information about request arguments
const String & arg();
const String & argName();
int args();
bool hasArg();
Function usage:
arg - get request argument value, use arg("plain") to get POST body
argName - get request argument name
args - get arguments count
hasArg - check if argument exist
Getting information about request headers
const String & header();
const String & headerName();
const String & hostHeader();
int headers();
bool hasHeader();
Function usage:
header - get request header value
headerName - get request header name
hostHeader - get request host header if available, else empty string
headers - get header count
hasHeader - check if header exist
Authentication
bool authenticate();
void requestAuthentication();
Function usage:
authenticate - server authentication, returns true if client is authenticated else false
requestAuthentication - sends authentication failure response to the client
Example Usage:
if(!server.authenticate(username, password))
{
server.requestAuthentication();
}
Other Function Calls
const String & uri(); // get the current uri
HTTPMethod method(); // get the current method
WiFiClient client(); // get the current client
HTTPUpload & upload(); // get the current upload
void setContentLength(); // set content length
void sendHeader(); // send HTTP header
void sendContent(); // send content
void sendContent_P();
void collectHeaders(); // set the request headers to collect
void serveStatic();
size_t streamFile();
Examples
Also see examples:
- AdvancedWebServer
- AdvancedWebServer_STM32
- ConnectWPA
- HelloServer
- HelloServer2
- HttpBasicAuth
- MQTTClient_Auth
- MQTTClient_Basic
- MQTT_ThingStream
- PostServer
- ScanNetworks
- SimpleAuthentication
- UdpNTPClient
- UdpSendReceive
- WebClient
- WebClientRepeating
- WebServer
- WebServerAP
- ATWebServer_BigData New
Example AdvancedWebServer
Please take a look at other examples, as well.
1. File AdvancedWebServer.ino
https://github.com/khoih-prog/ESP8266_AT_WebServer/blob/1839e2f68d950c65bf397a882cd3a2914ec7c468/examples/AdvancedWebServer/AdvancedWebServer.ino#L60-L305
2. File defines.h
https://github.com/khoih-prog/ESP8266_AT_WebServer/blob/1839e2f68d950c65bf397a882cd3a2914ec7c468/examples/AdvancedWebServer/defines.h#L15-L433
Debug Terminal Output Samples
1. AdvancedWebServer on Adafruit NRF52840_ITSYBITSY_EXPRESS using ESP8266-AT shield
The following are debug terminal output when running example AdvancedWebServer on NRF52840_ITSYBITSY_EXPRESS and ESP8266-AT shield.
Starting AdvancedWebServer on NRF52840_ITSYBITSY_EXPRESS
ESP8266_AT_WebServer v1.7.1
[ESP_AT] Initializing ESP module
[ESP_AT] Use ES8266-AT Command
WiFi shield init done
Connecting to WPA SSID: HueNet1
Starting server
[ESP_AT] Server started on port 80
HTTP server started @ 192.168.2.44
[ESP_AT] New client 0
ESP8266_AT_WebServer::handleClient: New Client
method: GET
url: /
search:
headerName: Host
headerValue: 192.168.2.44
headerName: Connection
headerValue: keep-alive
headerName: Cache-Control
headerValue: max-age=0
headerName: Upgrade-Insecure-Requests
headerValue: 1
headerName: DNT
headerValue: 1
headerName: Accept
headerValue: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
headerName: Referer
headerValue: http://192.168.2.44/
headerName: Accept-Encoding
headerValue: gzip, deflate
[ESP_AT] TIMEOUT: 104
args:
args count: 0
args:
args count: 0
Request: /
Arguments:
Final list of key/value pairs:
ESP8266_AT_WebServer::_handleRequest handle
[ESP_AT] ReqHandler::handle
AT_WebServer::send1: len = 314
content = <html><head><meta http-equiv='refresh' content='5'/><title>ESP-AT NRF52840_ITSYBITSY_EXPRESS</title><style>body { background-color: #cccccc; font-family: Arial, Helvetica, Sans-Serif; Color: #000088; }</style></head><body><h1>Hello from ESP-AT</h1><h3>on NRF52840_ITSYBITSY_EXPRESS</h3><p>Uptime: 0 d 00:00:23</p><img src="/test.svg" /></body></html>
AT_WebServer::_prepareHeader sendHeader Conn close
AT_WebServer::send1: write header = HTTP/1.1 200 OK
Content-Type: text/html
Content-Length: 314
Connection: close
ESP8266_AT_WebServer::sendContent: Client.write content: <html><head><meta http-equiv='refresh' content='5'/><title>ESP-AT AVR Mega</title><style>body { background-color: #cccccc; font-family: Arial, Helvetica, Sans-Serif; Color: #000088; }</style></head><body><h1>Hello from ESP-AT</h1><h3>on NRF52840_ITSYBITSY_EXPRESS</h3><p>Uptime: 0 d 00:00:23</p><img src="/test.svg" /></body></html>
[ESP_AT] ReqHandler::handle done
ESP8266_AT_WebServer::_handleRequest OK
ESP8266_AT_WebServer::handleClient: Don't keepCurrentClient
ESP8266_AT_WebServer::handleClient: Client disconnected
[ESP_AT] New client 0
ESP8266_AT_WebServer::handleClient: New Client
method: GET
url: /test.svg
search:
headerName: Host
headerValue: 192.168.2.44
headerName: Connection
headerValue: keep-alive
headerName: User-Agent
headerValue: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 ike Gecko) Chrome/84.0.4147.89 Safari/537.36
headerName: DNT
headerValue: 1
headerName: Accept
headerValue: image/webp,image/apng,image/*,*/*;q=0.8
args:
args count: 0
args:
args count: 0
[ESP_AT] TIMEOUT: 81
Request: /test.svg
Arguments:
Final list of key/value pairs:
ESP8266_AT_WebServer::_handleRequest handle
[ESP_AT] ReqHandler::handle
AT_WebServer::send1: len = 1949
content = <svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="310" height="150">
<rect width="310" height="150" fill="rgb(250, 230, 210)" stroke-width="1" stroke="rgb(0, 0, 0)" />
<g stroke="blue">
<line x1="10" y1="103" x2="20" y2="131" stroke-width="1" />
<line x1="20" y1="131" x2="30" y2="99" stroke-width="1" />
<line x1="30" y1="99" x2="40" y2="16" stroke-width="1" />
<line x1="40" y1="16" x2="50" y2="100" stroke-width="1" />
<line x1="50" y1="100" x2="60" y2="40" stroke-width="1" />
<line x1="60" y1="40" x2="70" y2="110" stroke-width="1" />
<line x1="70" y1="110" x2="80" y2="52" stroke-width="1" />
<line x1="80" y1="52" x2="90" y2="131" stroke-width="1" />
<line x1="90" y1="131" x2="100" y2="79" stroke-width="1" />
<line x1="100" y1="79" x2="110" y2="84" stroke-width="1" />
<line x1="110" y1="84" x2="120" y2="35" stroke-width="1" />
<line x1="120" y1="35" x2="130" y2="72" stroke-width="1" />
<line x1="130" y1="72" x2="140" y2="18" stroke-width="1" />
<line x1="140" y1="18" x2="150" y2="37" stroke-width="1" />
<line x1="150" y1="37" x2="160" y2="29" stroke-width="1" />
<line x1="160" y1="29" x2="170" y2="85" stroke-width="1" />
<line x1="170" y1="85" x2="180" y2="123" stroke-width="1" />
<line x1="180" y1="123" x2="190" y2="126" stroke-width="1" />
<line x1="190" y1="126" x2="200" y2="88" stroke-width="1" />
<line x1="200" y1="88" x2="210" y2="17" stroke-width="1" />
<line x1="210" y1="17" x2="220" y2="35" stroke-width="1" />
<line x1="220" y1="35" x2="230" y2="53" stroke-width="1" />
<line x1="230" y1="53" x2="240" y2="49" stroke-width="1" />
<line x1="240" y1="49" x2="250" y2="122" stroke-width="1" />
<line x1="250" y1="122" x2="260" y2="43" stroke-width="1" />
<line x1="260" y1="43" x2="270" y2="37" stroke-width="1" />
<line x1="270" y1="37" x2="280" y2="42" stroke-width="1" />
<line x1="280" y1="42" x2="290" y2="90" stroke-width="1" />
<line x1="290" y1="90" x2="300" y2="119" stroke-width="1" />
</g>
</svg>
AT_WebServer::_prepareHeader sendHeader Conn close
AT_WebServer::send1: write header = HTTP/1.1 200 OK
Content-Type: image/svg+xml
Content-Length: 1949
Connection: close
2. MQTT_ThingStream on Adafruit SAMD51 ITSYBITSY_M4 using ESP8266-AT shield
The following are debug terminal output when running example MQTT_ThingStream on Adafruit SAMD51 ITSYBITSY_M4 and ESP8266-AT shield.
Start MQTT_ThingStream on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
ESP8266_AT_WebServer v1.7.1
[ESP_AT] Use ES8266-AT Command
WiFi shield init done
Connecting to SSID: HueNet1
You're connected to the network, IP = 192.168.2.62
SSID: HueNet1, Signal strength (RSSI): -43 dBm
***************************************
STM32_Pub
***************************************
Attempting MQTT connection to broker.emqx.io
...connected
Published connection message successfully!
Subscribed to: STM32_Sub
MQTT Message Send : STM32_Pub => Hello from MQTT_ThingStream on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
MQTT Message receive [STM32_Pub] Hello from MQTT_ThingStream on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
MQTT Message Send : STM32_Pub => Hello from MQTT_ThingStream on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
MQTT Message receive [STM32_Pub] Hello from MQTT_ThingStream on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
MQTT Message Send : STM32_Pub => Hello from MQTT_ThingStream on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
MQTT Message receive [STM32_Pub] Hello from MQTT_ThingStream on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
MQTT Message Send : STM32_Pub => Hello from MQTT_ThingStream on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
MQTT Message receive [STM32_Pub] Hello from MQTT_ThingStream on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
MQTT Message Send : STM32_Pub => Hello from MQTT_ThingStream on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
MQTT Message receive [STM32_Pub] Hello from MQTT_ThingStream on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
MQTT Message Send : STM32_Pub => Hello from MQTT_ThingStream on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
MQTT Message receive [STM32_Pub] Hello from MQTT_ThingStream on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
3. MQTTClient_Auth on Adafruit SAMD51 ITSYBITSY_M4 using ESP8266-AT shield
The following are debug terminal output when running example MQTTClient_Auth on Adafruit SAMD51 ITSYBITSY_M4 and ESP8266-AT shield.
Starting MQTTClient_Auth on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
ESP8266_AT_WebServer v1.7.1
[ESP_AT] Use ES8266-AT Command
WiFi shield init done
Connecting to SSID: HueNet1
You're connected to the network, IP = 192.168.2.62
SSID: HueNet1, Signal strength (RSSI): -43 dBm
Attempting MQTT connection to broker.emqx.io...connected
Message Send : MQTT_Pub => Hello from MQTTClient_Auth on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
Message arrived [MQTT_Pub] Hello from MQTTClient_Auth on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
Message Send : MQTT_Pub => Hello from MQTTClient_Auth on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
Message arrived [MQTT_Pub] Hello from MQTTClient_Auth on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
Message Send : MQTT_Pub => Hello from MQTTClient_Auth on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
Message arrived [MQTT_Pub] Hello from MQTTClient_Auth on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
Message Send : MQTT_Pub => Hello from MQTTClient_Auth on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
Message arrived [MQTT_Pub] Hello from MQTTClient_Auth on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
4. MQTTClient_Basic on Adafruit SAMD51 ITSYBITSY_M4 using ESP8266-AT shield
The following are debug terminal output when running example MQTTClient_Basic on Adafruit SAMD51 ITSYBITSY_M4 and ESP8266-AT shield.
MQTTClient_Basic on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
ESP8266_AT_WebServer v1.7.1
[ESP_AT] Use ES8266-AT Command
WiFi shield init done
Connecting to SSID: HueNet1
You're connected to the network, IP = 192.168.2.62
SSID: HueNet1, Signal strength (RSSI): -41 dBm
Attempting MQTT connection to broker.shiftr.io...connected
Message Send : MQTT_Pub => Hello from MQTTClient_Basic on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
Message arrived [MQTT_Pub] Hello from MQTTClient_Basic on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
Message Send : MQTT_Pub => Hello from MQTTClient_Basic on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
Message Send : MQTT_Pub => Hello from MQTTClient_Basic on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
Message Send : MQTT_Pub => Hello from MQTTClient_Basic on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
Message Send : MQTT_Pub => Hello from MQTTClient_Basic on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
Message Send : MQTT_Pub => Hello from MQTTClient_Basic on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
5. WebClientRepeating on RASPBERRY_PI_PICO using ESP8266-AT shield
The following are debug terminal output when running example WebClientRepeating on RP2040-based RASPBERRY_PI_PICO and ESP8266-AT shield.
Starting WebClientRepeating on RASPBERRY_PI_PICO with ESP8266-AT & ESP8266_AT_WebServer Library
ESP8266_AT_WebServer v1.7.1
[ESP_AT] Use ES8266-AT Command
WiFi shield init done
Connecting to SSID: HueNet1
You're connected to the network, IP = 192.168.2.185
SSID: HueNet1, Signal strength (RSSI): -37 dBm
Connecting...
HTTP/1.1 200 OK
Server: nginx/1.4.2
Date: Tue, 11 May 2021 06:21:15 GMT
Content-Type: text/plain
Content-Length: 2263
Last-Modified: Wed, 02 Oct 2013 13:46:47 GMT
Connection: close
Vary: Accept-Encoding
ETag: "524c23c7-8d7"
Accept-Ranges: bytes
`:;;;,` .:;;:.
.;;;;;;;;;;;` :;;;;;;;;;;: TM
`;;;;;;;;;;;;;;;` :;;;;;;;;;;;;;;;
:;;;;;;;;;;;;;;;;;; `;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;; .;;;;;;;;;;;;;;;;;;;;
;;;;;;;;:` `;;;;;;;;; ,;;;;;;;;.` .;;;;;;;;
.;;;;;;, :;;;;;;; .;;;;;;; ;;;;;;;
;;;;;; ;;;;;;; ;;;;;;, ;;;;;;.
,;;;;; ;;;;;;.;;;;;;` ;;;;;;
;;;;;. ;;;;;;;;;;;` ``` ;;;;;`
;;;;; ;;;;;;;;;, ;;; .;;;;;
`;;;;: `;;;;;;;; ;;; ;;;;;
,;;;;` `,,,,,,,, ;;;;;;; .,,;;;,,, ;;;;;
:;;;;` .;;;;;;;; ;;;;;, :;;;;;;;; ;;;;;
:;;;;` .;;;;;;;; `;;;;;; :;;;;;;;; ;;;;;
.;;;;. ;;;;;;;. ;;; ;;;;;
;;;;; ;;;;;;;;; ;;; ;;;;;
;;;;; .;;;;;;;;;; ;;; ;;;;;,
;;;;;; `;;;;;;;;;;;; ;;;;;
`;;;;;, .;;;;;; ;;;;;;; ;;;;;;
;;;;;;: :;;;;;;. ;;;; ;;;;;;;` .;;;;;;;, ;;;;;;;; ;;;;;;;:
;;;;;;;;;:,:;;;;;;;;;: ;;;;;;;;;;:,;;;;;;;;;;
`;;;;;;;;;;;;;;;;;;;. ;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;; :;;;;;;;;;;;;;;;;:
,;;;;;;;;;;;;;, ;;;;;;;;;;;;;;
.;;;;;;;;;` ,;;;;;;;;:
;;; ;;;;;` ;;;;: .;; ;; ,;;;;;, ;;. `;, ;;;;
;;; ;;:;;; ;;;;;; .;; ;; ,;;;;;: ;;; `;, ;;;:;;
,;:; ;; ;; ;; ;; .;; ;; ,;, ;;;,`;, ;; ;;
;; ;: ;; ;; ;; ;; .;; ;; ,;, ;;;;`;, ;; ;;.
;: ;; ;;;;;: ;; ;; .;; ;; ,;, ;;`;;;, ;; ;;`
,;;;;; ;;`;; ;; ;; .;; ;; ,;, ;; ;;;, ;; ;;
;; ,;, ;; .;; ;;;;;: ;;;;;: ,;;;;;: ;; ;;, ;;;;;;
;; ;; ;; ;;` ;;;;. `;;;: ,;;;;;, ;; ;;, ;;;;
3,CLOSED
6. MQTTClient_Auth on RASPBERRY_PI_PICO using ESP8266-AT shield
The following are debug terminal output when running example MQTTClient_Auth on RP2040-based RASPBERRY_PI_PICO and ESP8266-AT shield using Earle Philhower's arduino-pico core.
Starting MQTTClient_Auth on RASPBERRY_PI_PICO with ESP8266-AT & ESP8266_AT_WebServer Library
ESP8266_AT_WebServer v1.7.1
[ESP_AT] Use ES8266-AT Command
WiFi shield init done
Connecting to SSID: HueNet1
You're connected to the network, IP = 192.168.2.185
SSID: HueNet1, Signal strength (RSSI): -36 dBm
Attempting MQTT connection to broker.emqx.io...connected
Message Send : MQTT_Pub => Hello from MQTTClient_Auth on RASPBERRY_PI_PICO with ESP8266-AT & ESP8266_AT_WebServer Library
Message arrived [MQTT_Pub] Hello from MQTTClient_Auth on RASPBERRY_PI_PICO with ESP8266-AT & ESP8266_AT_WebServer Library
Message Send : MQTT_Pub => Hello from MQTTClient_Auth on RASPBERRY_PI_PICO with ESP8266-AT & ESP8266_AT_WebServer Library
Message arrived [MQTT_Pub] Hello from MQTTClient_Auth on RASPBERRY_PI_PICO with ESP8266-AT & ESP8266_AT_WebServer Library
Message Send : MQTT_Pub => Hello from MQTTClient_Auth on RASPBERRY_PI_PICO with ESP8266-AT & ESP8266_AT_WebServer Library
Message arrived [MQTT_Pub] Hello from MQTTClient_Auth on RASPBERRY_PI_PICO with ESP8266-AT & ESP8266_AT_WebServer Library
Message Send : MQTT_Pub => Hello from MQTTClient_Auth on RASPBERRY_PI_PICO with ESP8266-AT & ESP8266_AT_WebServer Library
Message arrived [MQTT_Pub] Hello from MQTTClient_Auth on RASPBERRY_PI_PICO with ESP8266-AT & ESP8266_AT_WebServer Library
7. UdpNTPClient on MBED RASPBERRY_PI_PICO using ESP8266-AT shield
The following are debug terminal output when running example UdpNTPClient on RP2040-based MBED RASPBERRY_PI_PICO and ESP8266-AT shield using Arduino-mbed RP2040 core.
Starting UdpNTPClient on MBED RASPBERRY_PI_PICO with ESP8266-AT & ESP8266_AT_WebServer Library
ESP8266_AT_WebServer v1.7.1
[ESP_AT] Use ES8266-AT Command
WiFi shield init done
Connecting to WPA SSID: HueNet1
You're connected to the network, IP = 192.168.2.76
UDP Packet received, size 48
From 132.163.96.1, port 123
Seconds since Jan 1 1900 = 3831340334
Unix time = 1622351534
The UTC time is 5:12:14
UDP Packet received, size 48
From 132.163.96.1, port 123
Seconds since Jan 1 1900 = 3831340344
Unix time = 1622351544
The UTC time is 5:12:24
8. AdvancedWebServer on NRF52840_ITSYBITSY
The following is debug terminal output when running example AdvancedServer on NRF52840_ITSYBITSY board, to demo how to send much larger data than total 2K of ESP8266/ESP32 AT-command shields
MULTIPLY_FACTOR = 4.0f
Starting AdvancedServer on NRF52840_ITSYBITSY with ESP8266-AT & ESP8266_AT_WebServer Library
ESP8266_AT_WebServer v1.7.1
[ESP_AT] Initializing ESP module
[ESP_AT] Use ES8266-AT Command
WiFi shield init done
Connecting to WPA SSID: HueNet1
[ESP_AT] Server started on port 80
HTTP server started @ 192.168.2.142, Port = 80
.[ESP_AT] New client 0
[ESP_AT] ESP8266_AT_Client::write: size = 84 , MAX_SIZE = 2048
[ESP_AT] ESP8266_AT_Client::write: written = 84 , totalBytesSent = 84
[ESP_AT] ESP8266_AT_Client::write: Done, written = 84 , totalBytesSent = 84
[ESP_AT] ESP8266_AT_Client::write: size = 396 , MAX_SIZE = 2048
[ESP_AT] ESP8266_AT_Client::write: written = 396 , totalBytesSent = 396
[ESP_AT] ESP8266_AT_Client::write: Done, written = 396 , totalBytesSent = 396
[ESP_AT] handleClient: Client disconnected
[ESP_AT] New client 0
[ESP_AT] String Len = 11219
[ESP_AT] ESP8266_AT_Client::write: size = 90 , MAX_SIZE = 2048
[ESP_AT] ESP8266_AT_Client::write: written = 90 , totalBytesSent = 90
[ESP_AT] ESP8266_AT_Client::write: Done, written = 90 , totalBytesSent = 90
[ESP_AT] ESP8266_AT_Client::write: size = 11219 , MAX_SIZE = 2048
[ESP_AT] ESP8266_AT_Client::write: written = 2048 , totalBytesSent = 2048
[ESP_AT] ESP8266_AT_Client::write: Partially Done, written = 2048 , bytesRemaining = 9171
[ESP_AT] ESP8266_AT_Client::write: written = 2048 , totalBytesSent = 4096
[ESP_AT] ESP8266_AT_Client::write: Partially Done, written = 2048 , bytesRemaining = 7123
[ESP_AT] ESP8266_AT_Client::write: written = 2048 , totalBytesSent = 6144
[ESP_AT] ESP8266_AT_Client::write: Partially Done, written = 2048 , bytesRemaining = 5075
[ESP_AT] ESP8266_AT_Client::write: written = 2048 , totalBytesSent = 8192
[ESP_AT] ESP8266_AT_Client::write: Partially Done, written = 2048 , bytesRemaining = 3027
[ESP_AT] ESP8266_AT_Client::write: written = 2048 , totalBytesSent = 10240
[ESP_AT] ESP8266_AT_Client::write: Partially Done, written = 2048 , bytesRemaining = 979
[ESP_AT] ESP8266_AT_Client::write: written = 979 , totalBytesSent = 11219
[ESP_AT] ESP8266_AT_Client::write: Done, written = 979 , totalBytesSent = 11219
[ESP_AT] handleClient: Client disconnected
[ESP_AT] New client 0
[ESP_AT] ESP8266_AT_Client::write: size = 84 , MAX_SIZE = 2048
[ESP_AT] ESP8266_AT_Client::write: written = 84 , totalBytesSent = 84
[ESP_AT] ESP8266_AT_Client::write: Done, written = 84 , totalBytesSent = 84
[ESP_AT] ESP8266_AT_Client::write: size = 396 , MAX_SIZE = 2048
[ESP_AT] ESP8266_AT_Client::write: written = 396 , totalBytesSent = 396
[ESP_AT] ESP8266_AT_Client::write: Done, written = 396 , totalBytesSent = 396
[ESP_AT] handleClient: Client disconnected
[ESP_AT] New client 0
[ESP_AT] String Len = 11209
[ESP_AT] ESP8266_AT_Client::write: size = 90 , MAX_SIZE = 2048
[ESP_AT] ESP8266_AT_Client::write: written = 90 , totalBytesSent = 90
[ESP_AT] ESP8266_AT_Client::write: Done, written = 90 , totalBytesSent = 90
[ESP_AT] ESP8266_AT_Client::write: size = 11209 , MAX_SIZE = 2048
[ESP_AT] ESP8266_AT_Client::write: written = 2048 , totalBytesSent = 2048
[ESP_AT] ESP8266_AT_Client::write: Partially Done, written = 2048 , bytesRemaining = 9161
[ESP_AT] ESP8266_AT_Client::write: written = 2048 , totalBytesSent = 4096
[ESP_AT] ESP8266_AT_Client::write: Partially Done, written = 2048 , bytesRemaining = 7113
[ESP_AT] ESP8266_AT_Client::write: written = 2048 , totalBytesSent = 6144
[ESP_AT] ESP8266_AT_Client::write: Partially Done, written = 2048 , bytesRemaining = 5065
[ESP_AT] ESP8266_AT_Client::write: written = 2048 , totalBytesSent = 8192
[ESP_AT] ESP8266_AT_Client::write: Partially Done, written = 2048 , bytesRemaining = 3017
[ESP_AT] ESP8266_AT_Client::write: written = 2048 , totalBytesSent = 10240
[ESP_AT] ESP8266_AT_Client::write: Partially Done, written = 2048 , bytesRemaining = 969
[ESP_AT] ESP8266_AT_Client::write: written = 969 , totalBytesSent = 11209
[ESP_AT] ESP8266_AT_Client::write: Done, written = 969 , totalBytesSent = 11209
[ESP_AT] handleClient: Client disconnected
9. ATWebServer_BigData on NRF52840_ITSYBITSY
The following is debug terminal output when running example ATWebServer_BigData on NRF52840_ITSYBITSY board, to demo how to send much larger data than total 2K of ESP8266/ESP32 AT-command shields
MULTIPLY_FACTOR = 3.0f
Start ATWebServer_BigData on NRF52840_ITSYBITSY with ESP8266-AT & ESP8266_AT_WebServer Library
ESP8266_AT_WebServer v1.7.1
[ESP_AT] Initializing ESP module
[ESP_AT] Use ES8266-AT Command
WiFi shield init done
Connecting to WPA SSID: HueNet1
[ESP_AT] Server started on port 80
HTTP server started @ 192.168.2.142, Port = 80
[ESP_AT] New client 0
String Len = 23106
[ESP_AT] ESP8266_AT_Client::write: size = 86 , MAX_SIZE = 2048
[ESP_AT] ESP8266_AT_Client::write: written = 86 , totalBytesSent = 86
[ESP_AT] ESP8266_AT_Client::write: Done, written = 86 , totalBytesSent = 86
[ESP_AT] ESP8266_AT_Client::write: size = 23106 , MAX_SIZE = 2048
[ESP_AT] ESP8266_AT_Client::write: written = 2048 , totalBytesSent = 2048
[ESP_AT] ESP8266_AT_Client::write: Partially Done, written = 2048 , bytesRemaining = 21058
[ESP_AT] ESP8266_AT_Client::write: written = 2048 , totalBytesSent = 4096
[ESP_AT] ESP8266_AT_Client::write: Partially Done, written = 2048 , bytesRemaining = 19010
[ESP_AT] ESP8266_AT_Client::write: written = 2048 , totalBytesSent = 6144
[ESP_AT] ESP8266_AT_Client::write: Partially Done, written = 2048 , bytesRemaining = 16962
[ESP_AT] ESP8266_AT_Client::write: written = 2048 , totalBytesSent = 8192
[ESP_AT] ESP8266_AT_Client::write: Partially Done, written = 2048 , bytesRemaining = 14914
[ESP_AT] ESP8266_AT_Client::write: written = 2048 , totalBytesSent = 10240
[ESP_AT] ESP8266_AT_Client::write: Partially Done, written = 2048 , bytesRemaining = 12866
[ESP_AT] ESP8266_AT_Client::write: written = 2048 , totalBytesSent = 12288
[ESP_AT] ESP8266_AT_Client::write: Partially Done, written = 2048 , bytesRemaining = 10818
[ESP_AT] ESP8266_AT_Client::write: written = 2048 , totalBytesSent = 14336
[ESP_AT] ESP8266_AT_Client::write: Partially Done, written = 2048 , bytesRemaining = 8770
[ESP_AT] ESP8266_AT_Client::write: written = 2048 , totalBytesSent = 16384
[ESP_AT] ESP8266_AT_Client::write: Partially Done, written = 2048 , bytesRemaining = 6722
[ESP_AT] ESP8266_AT_Client::write: written = 2048 , totalBytesSent = 18432
[ESP_AT] ESP8266_AT_Client::write: Partially Done, written = 2048 , bytesRemaining = 4674
[ESP_AT] ESP8266_AT_Client::write: written = 2048 , totalBytesSent = 20480
[ESP_AT] ESP8266_AT_Client::write: Partially Done, written = 2048 , bytesRemaining = 2626
[ESP_AT] ESP8266_AT_Client::write: written = 2048 , totalBytesSent = 22528
[ESP_AT] ESP8266_AT_Client::write: Partially Done, written = 2048 , bytesRemaining = 578
[ESP_AT] ESP8266_AT_Client::write: written = 578 , totalBytesSent = 23106
[ESP_AT] ESP8266_AT_Client::write: Done, written = 578 , totalBytesSent = 23106
[ESP_AT] handleClient: Client disconnected
10. AdvancedWebServer on WIZNET_WIZFI360_EVB_PICO
The following is debug terminal output when running example AdvancedServer on WIZNET_WIZFI360_EVB_PICO board, using arduino-pico core
Starting AdvancedWebServer on WIZNET_WIZFI360_EVB_PICO with ESP32-AT & ESP8266_AT_WebServer Library
ESP8266_AT_WebServer v1.7.1
[ESP_AT] Using ESP32-AT Command
WiFi shield init done
Connecting to WPA SSID: HueNet
HTTP server started @ 192.168.2.124, Port = 80
.......... .......... .
Screen Shots
1. SAMD51 Itsy-Bitsy M4
This is the screen shot when running example AdvancedWebServer on Adafruit SAMD51 Itsy-Bitsy M4 board using this ESP8266_AT_WebServer Library
2. STM32 Nucleo-144 NUCLEO_F767ZI
This is the screen shot when running example AdvancedWebServer_STM32 on STM32 Nucleo-144 NUCLEO_F767ZI board using this ESP8266_AT_WebServer Library
3. nRF52 Itsy-Bitsy nRF52840
This is the screen shot when running example AdvancedWebServer on Adadruit nRF52840 Itsy-Bitsy board using this ESP8266_AT_WebServer Library
4. Seeeduino SEEED_XIAO_M0
This is the screen shot when running an example using UDP Multicast on Seeeduino SEEED_XIAO_M0 board using this ESP8266_AT_WebServer Library. The UDP MUlticast is used to manage Internet Gateway's Port Forwarding so that we can access from WAN, port 5990, the WebServer running in LAN, port 5990.
5. RASPBERRY_PI_PICO
This is the screen shot when running example AdvancedWebServer on RASPBERRY_PI_PICO board using this ESP8266_AT_WebServer Library
6. MBED RASPBERRY_PI_PICO
This is the screen shot when running example AdvancedWebServer on MBED RASPBERRY_PI_PICO board using this ESP8266_AT_WebServer Library
7. nRF52 Itsy-Bitsy nRF52840 BigData
This is the screen shot when running example AdvancedWebServer on Adadruit nRF52840 Itsy-Bitsy board using this ESP8266_AT_WebServer Library sending BigData
Debug
Debug is enabled by default on Serial. Debug Level from 0 to 4. To disable, change the WIFI_LOGLEVEL and WIFININA_LOGLEVEL to 0
// Use this to output debug msgs to Serial
#define DEBUG_ESP8266_AT_WEBSERVER_PORT Serial
// Debug Level from 0 to 4
#define _ESP_AT_LOGLEVEL_ 1
Troubleshooting
If you get compilation errors, more often than not, you may need to install a newer version of the board's core, applying Libraries' Patches, Packages' Patches or this library latest version.
Issues
Submit issues to: ESP8266_AT_WebServer issues
TO DO
- Bug Searching and Killing
- Add SSL/TLS Client and Server support
- Support more types of boards using ESP8266 AT-command shields.
- Add mDNS features.
DONE
- Add support to Arduino SAMD21 (ZERO, MKR, NANO_33_IOT, etc.)
- Add support to Adafruit SAMD21 (Itsy-Bitsy M0, Metro M0, Feather M0 Express, etc.).
- Add support to Adafruit SAMD51 (Itsy-Bitsy M4, Metro M4, Grand Central M4, Feather M4 Express, etc.).
- Add support to Adafruit nRF52 ( Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox, etc.).
- Add support to SAM DUE.
- Add support to ESP32-AT
- Add support to W600 and WIS600-01S
- Add support to all STM32F/L/H/G/WB/MP1
- Add support to Seeeduino SAMD21/SAMD51 boards (SEEED_WIO_TERMINAL, SEEED_FEMTO_M0, SEEED_XIAO_M0, Wio_Lite_MG126, WIO_GPS_BOARD, SEEEDUINO_ZERO, SEEEDUINO_LORAWAN, SEEED_GROVE_UI_WIRELESS, etc.)
- Add UDP Multicast feature.
- Add PROGMEM and FlashString related commands such as sendContent_P() and send_P(), and use in examples.
- Clean-up all compiler warnings possible.
- Add Version String
- Add Table of Contents
- Add support to SIPEED_MAIX_DUINO
- Add support to Arduino Nano RP2040 Connect using Arduino mbed OS for Nano boards.
- Add support to RP2040-based boards, such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, using Earle Philhower's arduino-pico core.
- Add support to RP2040-based boards, such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, using Arduino-mbed RP2040 core
- Reduce usage of Arduino String with std::string
- Optimize library code and examples by using reference-passing instead of value-passing.
- Fix severe limitation to permit sending larger data than 2K buffer of ESP8266/ESP32 AT-command shields
- Add example ATWebServer_BigData to demo how to send larger data than 2K buffer
- Modify example AdvancedWebServer to demo how to send larger data than 2K buffer
- Add support to WizNet
WizFi360, such asWIZNET_WIZFI360_EVB_PICOusingarduino-picocore
Contributions and Thanks
- Based on and modified Ivan Grokhotkov's ESP8266WebServer
- Based on and modified from bportaluri's WiFiEsp library
- Thanks to good work of Miguel Alexandre Wisintainer for initiating, inspriring, working with, developing, debugging and testing. Without that, support to nRF52, especially U-Blox B302 running as nRF52840 and U-Blox B112 running as nRF52832, has never been started and finished. Also see U-BLOX NINA B302/ENC28J60 with Alexa/SinricPro.
- Thanks to reltkaine to report the compile error issue with Sipeed Maixduino core, leading to v1.4.1 to introduce
Packages_Patchesfor Sipeed Maixduino core
![]() ⭐️⭐️ Ivan Grokhotkov |
![]() ⭐️ Bruno |
![]() ⭐️ Miguel Wisintainer |
![]() reltkaine |
Contributing
If you want to contribute to this project:
- Report bugs and errors
- Ask for enhancements
- Create issues and pull requests
- Tell other people about this library
License
- The library is licensed under MIT
Copyright
Copyright (C) 2020- Khoi Hoang




