SkillAgentSearch skills...

WiFiEspAT

Arduino networking library. Standard Arduino WiFi networking API over ESP8266 or ESP32 AT commands.

Install / Use

/learn @JAndrassy/WiFiEspAT
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

<details> <summary>**Version 2 Upgrade Notes** (click to expand)</summary>

Version 2 has major improvements for WiFiClient:

  • it closes the connection as soon as no WiFiClient object references it (when last copy is cleared or goes out of scope)
  • it detects that connection was closed by peer and releases the link. As soon as all data are read by the sketch it makes the internal buffer available for next connection. It is not necessary to call stop() on connection disconnected by the remote side.
  • in version 1 an old WiFiClient copy could interfere on a new connection on the same AT link. This is very unlikely to happen in version 2.

Version 2 has some breaking changes:

  • Version 1 returned MAC address and BSSID in reversed ordering because 5 years ago all Arduino WiFi libraries had it that way. Version 2 returns MAC address and BSSID in normal ordering.

  • Version 2 removes server.available() function from the library. The functions is still there but only as alias for server.accept(). It will work for most use cases. For proper server.available()with help of the NetApiHelpers library see the PagerServer example.

  • Version 1 had optimized UDP classes WiFiUdpSender and WiFiEspAtUDP. These are removed in version 2. WiFiUDP has the functionality of both of them.

  • In version 1 WiFi.disconnect() cleared the static IP configuration. In version 2 the static IP configuration is preserved for next WiFi.begin(). To return to DHCP clear the static IP configuration with WiFi.config(INADDR_NONE). All Arduino WiFi libraries have it this way.

</details>

WiFiEspAT library

This library creates standard Arduino WiFi networking API over ESP8266 or ESP32 AT commands. The Arduino WiFi networking API was established by Arduino WiFi library and enhanced by Arduino WiFi101 and Arduino WiFiNINA library.

This library is fast and reliable. It can communicate with AT firmware at high baud rates without flow control, limited only by reliability of UART at chosen speed.

WiFiEspAT supports wired Ethernet with esp8266 or esp32 with an Ethernet module, AT firmware with Ethernet support and the EthernetEspAT library.

The library is for all Arduino MCU architectures.

MKR Zero with esp-01S

Contents

Getting started

  • Put a supported version of the AT firmware into the ESP you want to use with the WiFiEspAT library. Make sure the firmware is working and returning OK to test command "AT".

  • Wire the ESP module to Serial1 of your Arduino. Wire RX to TX. If your Arduino doesn't have Serial1, wire the ESP module to pins 6 as RX and 7 as TX for SoftwareSerial.

  • For AT firmware version 2.4.0 or higher open in the folder of the library the file src/utility/EspAtDrvTypes.h in a text editor and comment out the line #define WIFIESPAT1 like this //#define WIFIESPAT1

  • If you use SoftwareSerial run the ChangeATBaudRate sketch from WiFiEspAT/Tools section in IDE Examples menu. If the sketch ends with "Communication with WiFi module failed!" check the wiring.

  • Run the CheckFirmware sketch from WiFiEspAT/Tools section in IDE Examples menu. If the sketch ends with "Communication with WiFi module failed!" check the wiring.

  • Open the SetupPersistentWiFiConnection sketch from WiFiEspAT/Tools section in IDE Examples menu. Set the SSID and password on arduino_secrets tab. Run the sketch to make a persistent connection to your WiFi network.

  • Try the Basic examples. Warning: The example sketches are designed to present library functions in a simplest way. They are not examples of a good sketch structure and efficiency. Don't use delays and String in your projects.

Why a new WiFiEsp library?

This library uses the passive receive mode implemented in AT firmware 1.7 (Non OS SDK 3) and AT firmware 2.4+ (IDF). The older WiFiEsp library can't do much with larger data received. Without the passive receive mode, the AT firmware sends all the data at once and the serial RX buffer overflows. It is hard to receive more data over network with AT firmware without UART hardware flow control and Arduino AVR boards don't have flow control and simple esp8266 modules don't have the flow control pins exposed.

Note: The older WiFiEsp library referenced the AT firmware version by SDK version. This library reports AT commands version.

Limitations

The official AT firmwares are limited to one TCP server.

AT 1.7

AT 1.7 is only for esp8266.

The passive receive mode of the AT firmware is not supported for UDP and secure connection (SSL). For this reason UDP received message size is limited to configured buffer size and secure connection (SSL, https) is not supported.

AT 2

The AT 2 has a small problem with UDP messages in passive receive mode. The received message must be read at once so received message size is limited to configured buffer size with this library.

AT 2 is for esp32. Use at least version 2.4. Versions 2.1 and 2.2 were for esp8266 too, but are not reliable.

Note to 2.0.0 versions: ESP8266 version can't be used with this library. It doesn't support passive receive mode. In ESP32 AT 2.0.0 version UDP doesn't work in passive receive mode.

Capabilities comparison

The table focuses on limits of AT firmwares in passive receive mode.

|Feature|AT 1.7|AT 2.4+|ESP_ATMod(1)| |---| :---: | :---: | :---: | |more than one TCP server|✗|✗|✓(2)| |SSL server|✗|✓|✗| |TCP client|✓|✓|✓| |SSL client|✗|✓|✓| |SSL client TLS 1.2|✗(3)|✓|✓| |UDP (4)|✓|✓|✗| |UDP backlog|✗|✓|n/a| |UDP multicast|✗|✓|n/a| |SoftAP|✓|✓|✓| |WPA2 Enterprise|✗|✓|✗| |epoch time|Lobo|✓|✓|

  • (1) Jiri Bilek's firmware
  • (2) uncomment #define WIFIESPAT_MULTISERVER in src/utility/EspAtDrv.h
  • (3) it is possible to use the SSLClient library for TLS 1.2 on 32bit MCU
  • (4) it is not possible to receive UDP message larger than the configured buffer

AT firmware versions

You can use the CheckFirmware sketch from examples Tools to check the version of the AT firmware.

AT 1.7

AT firmware 1.7.x is build on Espressif NonOS SDK 3.

The Espressif AT binary is built for 2MB-c1 flash partitioning. Flash Download Tool corrects it for 4 MB flash, but for esptool you should use the --flash_size 2MB-c1 option and the corresponding addresses.

esptool.py write_flash --flash_size 2MB-c1 0x0 boot_v1.7.bin 0x01000 at/1024+1024/user1.2048.new.5.bin 0x1fb000 blank.bin 0x1fc000 esp_init_data_default_v08.bin 0xfe000 blank.bin 0x1fe000 blank.bin

The AT 1.7.4 version has bin file for flashing to 1 MB flash.

esptool.py write_flash --flash_size 1MB 0x0 boot_v1.7.bin 0x01000 at/512+512/user1.1024.new.2.bin 0xfb000 blank.bin 0xfc000 esp_init_data_default_v08.bin 0xfe000 blank.bin 0x7e000 blank.bin

For some esp8266 modules you will have to add --flash_mode dout before --flash_size.

GitHub user loboris (Boris Lovosevic) builds customized versions of AT firmware with SDK 3 for all flash sizes. You can download the files from his ESP8266_AT_LoBo GitHub repository. Run his flash.sh utility to flash the correct binary.

Jiri Bilek created an alternative AT 1.7 firmware implementation over esp8266 Arduino core and WiFi library. This supports SSL TLS1.2 connection in passive mode with this library. This firmware doesn't yet support UDP.

Resources:

AT 2

This library can work with AT firmware version 2.4 or higher. AT firmware 2 is for ESP32 and is build on Espressif's IDF framework.

The flashing command of AT2 with esptool is esptool.py write_flash @download.config. I recommend to change in download.config file flash_mode to qio if your ESP module supports it and flash frequency to 40MHz if your module doesn't support 80MHz.

Resources:

Flashing tools

Wiring of the ESP module

The examples of this library expect the AT firmware's RX/TX wired to hardware Serial1 for boards with Serial1. For AVR boards without Serial1 the examples setup SoftwareSerial on pins 6 (RX) and 7 (TX). Wire RX to TX.

To use hardware reset instead of software reset, wire sele

Related Skills

View on GitHub
GitHub Stars343
CategoryDevelopment
Updated16d ago
Forks49

Languages

C++

Security Score

100/100

Audited on Mar 21, 2026

No findings