Coder Social home page Coder Social logo

jandrassy / wifiespat Goto Github PK

View Code? Open in Web Editor NEW
268.0 8.0 43.0 296 KB

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

License: GNU Lesser General Public License v2.1

C++ 95.74% C 4.26%
arduino-library esp8266 arduino-wifi esp32 arduino-networking

wifiespat's Introduction

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.

The library is for all Arduino MCU architectures.

MKR Zero with esp-01S

Contents

Getting started

  • Put AT firmware 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 new passive receive mode implemented in AT firmware 1.7 (Non OS SDK 3) and AT firmware 2.4+ (RTOS SDK). 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 selected pin of Arduino to reset pin of the ESP and set the pin as second parameter in WiFi.init(Serial1, ESP_RESET_PIN);. No logic level conversion is required for this connection. The library only sets the pin LOW or floating.

You can use the SerialPassthrough sketch from WiFiEspAT/Tools in IDE Example menu to bridge the ESP to computer over Arduino with the above wiring. You can then send AT commands to the AT firmware from the Serial Monitor. It is even possible to upload AT firmware if the ESP is on hardware Serial. Only put the ESP in flashing mode and set the upload baud rate to 115200 baud.

Baud rate for communication with AT firmware

Over hardware Serial this library works reliably with AT firmware's default 115200 baud. With SoftwareSerial, 9600 baud should be used because of limitations of SoftwareSerial. You can try alternative software Serial libraries with their recommended baud rates. The ChangeBaudRate sketch in examples Tools section can change over SoftwareSerial the default baud rate of AT firmware from 115200 to 9600 baud.

For hardware serial high baud rates can be used. For Arduino Mega 500000 baud works good. The ChangeBaudRate sketch can be used to change the default baud rate of the AT firmware to a higher one for hardware Serial. For example a WebServer serving web files from SD card requires high baud rate to be able to serve multiple files one after other fast enough.

Persistent WiFi connection

The ESP can remember the WiFi network settings to connect automatically to WiFi network after power-up or reset. This library supports this with the SetupWiFiConnection example tool sketch. The sketch uses the WiFi.setPersistent() setting. After the connection is successful, it is remembered by the ESP and set for autoconnect at start. Other sketches don't need to call WiFi.begin(), only wait until WiFi.status() returns WL_CONNECTED.

Note: The ESP SDK remembers the SSID and password by default and uses them to autoconnect at start. Your ESP may have remembered setting from previous use with any firmware or Arduino sketch.

Using persistent connections has two benefits. The sketch size is smaller without WiFi.begin() and the connection to network is asynchronous, it happens while other devices are setup in setup(). (Synchronous WiFi.begin() with DHCP waits 5 seconds for the OK from AT firmware.)

WiFi.disconnect() in 'persistent mode' or WiFi.disconnect(true) clear the remembered connection and disables automatic connection to network. Don't use persistent WiFi.begin(ssid, pass) and persistent WiFi.disconnect() in the same sketch. The settings would be written to flash and then cleared repeatedly, which would lead to faster ESP flash memory wearing.

With WiFi.setAutoConnect(false) the remembered network settings are not used, but stay remembered. If ESP auto starts the connection, it can collide with WiFi.begin(). Clear the persistent connection with WiFi.disconnect() before using a temporary not persistent connection.

Persistent Access Point

This library supports ESP SoftAP control over AT firmware. With WiFi.beginAP() without parameters the SoftAP is started with default settings. Default settings are factory settings or remembered persistent settings. The SetupPeristentAP example tool can be used to setup SoftAP with custom SSID and optionally setup encryption/password and IP address for the SoftAP.

Use WiFi.endAP(true) to disable start of SoftAP at ESP startup. It will not clear the persistent AP settings.

Enhanced WiFi API

This library implements Arduino WiFi networking API. The last version of this API is defined by the Arduino WiFiNINA library. The WiFiEspAT library has some differences.

the WiFi object differences

  • init command to set the Serial interface used for communication
  • begin for AT 1.7 begin() without parameters (joining remembered WiFi) is not available
  • beginEnterprise AT 2 only. to connect to WPA2 Enterprise network (sorry, it is not tested)
  • setPersistent to set the remembering of the following WiFi connection (see the SetupPersistentWiFiConnection.ino tool example)
  • setAutoConnect to set the automatic connection to remembered WiFi AP
  • scanNetworks optionally can be called with array of type WiFiApData[] to fill
  • hostname to get the hostname. can be called with char array to fill (see PrintPersistentSettings.ino tool example)
  • SSID optionally can be called with char array to fill (see PrintPersistentSettings.ino tool example)
  • channel getter
  • dhcpIsEnabled to determine if DHCP or static IP is used (see PrintPersistentSettings.ino tool example)
  • beginAP can be called without parameters to start the persistent AP (see ConfigurationAP.ino example)
  • endAP - stops the AP. endAP(true) stops the AP and disables start of persistent AP at startup
  • configureAP - to configure AP. see the SetupPersistentAP.ino tool example
  • AP parameters getters - apMacAddress, apSSID, apPassphrase, apEncryptionType, apMaxConnections, apIsHidden, apDhcpIsEnabled, apIP, apGatewayIP, apSubnetMask (see PrintPersistentSettings.ino tool example)
  • startMDNS to execute AT+MDNS. refer to AT reference for parameters
  • sntp - to enable and configure SNTP servers. see SNTPTime.ino example
  • reset - to reset or wake-up the ESP. see DeepSleepAndHwReset.ino example
  • sleepMode- to set the level of automatic sleep mode. possible modes are WIFI_NONE_SLEEP, WIFI_LIGHT_SLEEP and WIFI_MODEM_SLEEP
  • deepSleep- to turn-off the ESP. see DeepSleepAndHwReset.ino example
  • ping doesn't have the ttl parameter and returns only true or false

the WiFiClient class differences

  • connectSSL is not supported with standard AT 1 firmware
  • write(file) variant of write function for efficient sending of SD card file. see SDWebServer.ino example
  • write(callback) variant of write function for efficient sending with a callback function. see SDWebServer.ino example
  • abort AT1 only. closes the TCP connection without waiting for the remote side

the WiFiServer class differences

The standard AT firmwares support only one TCP server. The ESP_ATMod firmware supports multiple servers (uncomment #define WIFIESPAT_MULTISERVER in src/utility/EspAtDrv.h).

  • begin has optional parameters maxConnCount (default 1) and serverTimeout in seconds (default 60)
  • beginSSL ESP32 only. starts the server for secure connections.
  • begin(port) and beginSSL(port) and constructor without parameters
  • end to stop the server and the clients managed by the server for available()
  • accept like in new Ethernet library. see the AdvancedChatServer

The WiFiServer class in this library doesn't derive from the Arduino Server class. It doesn't implement the never used 'send to all clients' functionality over Print class methods (print, write). For 'send to all clients' use the WiFiServerPrint class as the PagerServer example.

the UDP differences

The Arduino UDP API requires to start a listening port to send an UDP message. This library doesn't require udp.begin() before udp.beginPacket().

  • beginMulticast works only with AT2
  • availableForParse for AT2 only. returns the size of the available message. see the WiFiEspAT2UDP example
  • parsePacket(buffer, size, ip, port) for AT2 only. to read the message into provided buffer. see the WiFiEspAT2UDP example
  • write(callback) variant of write function for efficient sending with a callback function

You can use WiFiUdpSender class if you only send messages. See the UdpSender.ino example.

With AT2 You can use WiFiEspAtUDP class if you receive messages with the parsePacket(buffer, size, ip, port) function. WiFiEspAtUDP doesn't have internal buffer to receive the message with parsePacket() so it saves global memory. See the WiFiEspAT2UDP example.

Logging

The EspAtDrv in center of the library has four logging levels to troubleshoot communication with AT firmware or help with development of new functions. At default logging is off, set to SILENT level.

Logging level and logging Serial instance, can be changed in src/utils/EspAtDrvLogging.h. Level DEBUG will print all AT commands and responses from AT firmware. Level ERROR will print only errors in communication with AT firmware. Higher logging level result in larger sketch size.

Sketch size optimization

For small MCU like the ATmega328p on Uno, the sketch size matters. With modern compiler and linker almost all not used code is removed. So any additional function used in sketch results in larger sketch. Any function called to get information about the WiFi connection only to print a fancy welcome message adds to sketch size.

With persistent WiFi connection WiFi.begin() and underlying functions are not used, resulting in smaller sketch size.

Use WiFiUdpSender class if you only send UDP messages. You can use WiFiEspAtUDP with AT2. WiFiUDP always allocates the receive buffer required for AT1 UDP receive without passive mode and for AT2 to fulfill the Arduino UDP API.

Advanced use

Buffering and buffers

This library has small buffers in WiFiClient to achieve better performance over UART and over network. The size of the buffers is configured in WiFiEspAtConfig.h file in library's src folder. There is a special set of settings for AVR MCU with small SRAM. For small SRAM, the RX and TX buffer are 32 bytes, for all other it is 64 bytes.

For UDP to hold the composed message and the received message 64 bytes buffers are used for small AVR MCU and 256 bytes buffers for other MCU.

It is recommended to use WiFiClient.flush() after completing the output. WiFiClient.stop() and WiFiUdp.endPacket() both call flush(). The library calls flush() if TX buffer is not empty and available() is called.

The buffers size can be changed in WiFiEspAtConfig.h or set on build command line. The TCP TX buffer can be set to 0 and the RX buffer must be at least 1 (for peek()), but then please use buffers in sketch for example with StreamLib's wrapper class BufferedPrint.

The size of the UDP TX buffer can be set to zero in WiFiEspAtConfig.h if the complete message is sent with one print(msg), one write(msg, length) or with write(callback). Otherwise the size of the UDP buffers limits the size of the message. If the composed message is larger than the buffer it will be send as partial UDP messages. If the size of received message with AT1 is larger than the UDP TX buffer, the message will be dropped (with WiFi.getLastDriverError() set to EspAtDrvError::UDP_LARGE).

To set different custom sizes of buffers for different boards, you can create a file boards.local.txt next to boards.txt file in hardware package. Set build.extra_flags for individual boards. For example for Mega you can add to boards.local.txt a line with -D options to define the macros.

mega.build.extra_flags=-DWIFIESPAT_TCP_RX_BUFFER_SIZE=128 -DWIFIESPAT_TCP_TX_BUFFER_SIZE=128

With WiFiEspAT library the incoming data are buffered at two levels. First level is in the AT firmware. After it received all the data to buffer and closed the connection, the yet unread data are still available to read. Second buffering is in library's BuffStream. Here still can be data available even the firmware and EspAtDrv are done with the link and it can be used for a new connection.

the write(callback) function

While the internal buffering of the library and the use of Nagle's algorithm by AT firmware prevents sending client.prints in many very very small TCP packets, with the write(callback) function all prints executed in the callback function are send to AT firmware with one AT+CIPSENDEX command resulting in efficient TCP or UDP packet size. AT+CIPSENDEX is limited to 2 kbytes and \\0 terminates the command so it can't occur in data.

The SDWebServer example shows the use of the write(callback) function with C++ anonymous lambda functions as callbacks.

EspAtDrv Errors

The library functions with bool as return type return false in case of fail. The functions which return a value return 0 or - 1 in case of error, depending on the semantic of the function. To get the reason of the error the sketch can test the WiFi.getLastDriverError(). The error codes are enumerated in util/EspAtDrvTypes.h.

For some functions 0 or false as returned value can have a meaning of error or be a valid return value. For example if you call readBytes, which has unsigned return type, without previously testing if bytes are available, then returned 0 can have the meaning of no bytes available or error occurred.

UART Flow Control

The AT firmware sends notifications about different events without the host requesting them. Examples of these events are if data arrive for a connection or connection is closed. Without flow control of Serial interface some of these events can get lost in buffer overflow if they arrive in bulk. As compensation for lost events, the WiFiEspAT library polls the state of the connections. This adds to time spent in library functions.

If you can setup for the WiFiEspAT library a Serial connection with flow control, you can uncomment #define ESPATDRV_ASSUME_FLOW_CONTROL in EspAtDrv.cpp or define ESPATDRV_ASSUME_FLOW_CONTROL in boards.local.txt for the board. This will remove the polling of connections state.

The SerialPassthrough sketch from WiFiEspAT/Tools in IDE Example menu has optional configuration of SAMD SERCOM3 to create 'Serial' interface with flow control. The esp8266 CTS pin is pin 13. The example has pin 2 of MKRZERO as RTS pin. To activate flow control on the AT firmware side, use the AT+UART command with last parameter 2 or 3.

Create a copy for AT2

If you want to use the library in projects with AT1 and AT2, create for AT2 a copy of the library. Copy the folder of the library as WiFiEspAT2, rename the file WiFiEspAT.h to WiFiEspAT2.h and change in library.properties includes= to WiFiEspAT2.h.

wifiespat's People

Contributors

jandrassy avatar jiribilek avatar rsteenbu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wifiespat's Issues

timeout doesn't work for WiFiServer.begin(links, timeout)

default timeout for WiFiServer(linksCount) is 30 seconds

when i create a server with WiFiServer(linksCount, 120) or whatever timeout, it still fixes at 30 seconds

i had to directly send espSerial.println("AT+CIPSTO=120"); and busy-wait for response just after server creation

  • arduino uno r3
  • esp-01s (esp8266 1mb flash)
  • latest lobo firmware, with AT v1.7
  • arduino ide 1.8.13
  • wifiespat 1.3.1

error: 'WiFiEspAtUDP' does not name a type

I tried the example in examples/Advanced/WiFiEspAT2UDP, however it has an error when building.

error: 'WiFiEspAtUDP' does not name a type; did you mean 'WiFiUDP'?

I am using the latest version of this library.

Thanks a lot for providing this library!

DNS fail in WebClient example

Hello,
when I attempt to use the WebClient example during the connection to the server [line 54] if (client.connect(server, 80))
I receive DNS fail (from the debug) yet when I change the the "server" char pointer to an IP address, connection is made succesfully.

How to make REST API HTTPS POST Request in WiFiespAT library

I need to send data to the power bi dashboard using arduinomega+esp8266 inbuilt board. I successfully install AT firmware and test example codes. but still, I could not manage to make the post request to power bi streaming data set API.
Previously I used a nodemcu board to this task and it worked flawlessly. this is the code I used in nodemcu.

#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClientSecureBearSSL.h>


#define SERVER_IP "https://api.powerbi.com/beta/d1323671-cdbe-4417-b4d4-bdb24b51316b/datasets/ce600abb-0afd-47e1-bdaf-6491f91945bd/rows?noSignUpCheck=1&key=stAvYHSNB6lDf%2BEEXS%2BU%2BsA2Kbyd3%2Bx9NKnWyZj5Uz5YPp%2Bbu7zdPUxboto4aXhls8rObnfYQXFPoIeo9ALrAA%3D%3D"

#define WI_SSID "SLT_FIBRE"
#define WI_PW  "dehff"
WiFiClient client;
void sendData(int temp){
  std::unique_ptr<BearSSL::WiFiClientSecure>client(new BearSSL::WiFiClientSecure);
  client->setInsecure();
  HTTPClient https;

  Serial.print("[HTTP] begin...\n");
  // configure traged server and url
  https.begin(client, SERVER_IP); //HTTPS
  https.addHeader("Content-Type", "application/json");

  Serial.print("[HTTP] POST...\n");
  // start connection and send HTTP header and body
  int httpCode = https.POST("[{\"Value\": " + String(temp) + "}]");

  // httpCode will be negative on error
  if (httpCode > 0) {
    // HTTP header has been send and Server response header has been handled
    Serial.printf("[HTTP] POST... code: %d\n", httpCode);

    // file found at server
    if (httpCode == HTTP_CODE_OK) {
      const String& payload = https.getString();
      Serial.println("received payload:\n<<");
      Serial.println(payload);
      Serial.println(">>");
    }
  } else {
    Serial.printf("[HTTP] POST... failed, error: %s\n", https.errorToString(httpCode).c_str());
  }

  https.end();
 
}

void setup() {
  Serial.begin(115200);

  Serial.println();
  Serial.println();
  Serial.println();

  WiFi.begin(WI_SSID, WI_PW);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected! IP address: ");
  Serial.println(WiFi.localIP());

}

void loop() {
  // wait for WiFi connection
  int temp = analogRead(A0);
  Serial.println(temp);
  if ((WiFi.status() == WL_CONNECTED)) {
    sendData(temp);
  }

  
}

This the code I tried in Arduino mega +ESP8266 board but it didn't work.

/*
  Web client

 This sketch connects to https
 using the WiFi module.

 created 13 July 2010
 by dlf (Metodo2 srl)
 modified 31 May 2012
 by Tom Igoe
 modified in Jul 2019 for WiFiEspAT library
 by Juraj Andrassy https://github.com/jandrassy
 */

#include <WiFiEspAT.h>

const char* server = "api.powerbi.com/beta/d1323671-cdbe-4417-b4d4-bdb24b51316b/datasets/60dfb0df-9bf8-4c05-8505-69a32ec90a95/rows?tenant=&UPN=&key=H1wfQ3c5rxxmgrDqcZkARXK%2FCypXYyN77IDXoYA13z5%2FnXN9JRAXGehl15Tb0is43ikRShQauxuQH45p%2FJV8dg%3D%3D";
char ssid[] = "SLT_FIBRE";            
char pass[] = "kavsds";  
WiFiSSLClient client;

void setup() {
  Serial.begin(115200);
  while (!Serial);

  Serial1.begin(115200);
  WiFi.init(Serial3);
  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println();
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true);
  }
  
  WiFi.begin(ssid, pass);
  
  // waiting for connection to Wifi network set with the SetupWiFiConnection sketch
  Serial.println("Waiting for connection to WiFi");
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.print('.');
  }
  Serial.println();
  Serial.println("Connected to WiFi network.");

  Serial.println("Starting connection to server...");
  if (client.connect(server, 443)) { // port 443 is the default https port
    Serial.println("connected to server");
  int value=10;
  // send the HTTP POST request  
  client.println("POST  HTTP/1.1");
  client.println("Host: server");
  client.println("Content-Type: application/json");
  String content = "{\"temperature\":\""+String(value)+"\"}";
  client.println("Content-Length: 16"); //insert, well, your content length
  client.println(content);

}
else {
  // if you couldn't make a connection
  Serial.println("Connection failed");
}

    
  
}

void loop() {

  // if there are incoming bytes available
  // from the server, read them and print them
  while (client.available()) {
    char c = client.read();
    Serial.write(c);
  }

  // if the server's disconnected, stop the client
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting from server.");
    client.stop();

    // do nothing forevermore
    while (true);
  }
}

This is the dataset I tried to connect.
API = https://api.powerbi.com/beta/d1323671-cdbe-4417-b4d4-bdb24b51316b/datasets/60dfb0df-9bf8-4c05-8505-69a32ec90a95/rows?tenant=&UPN=&key=H1wfQ3c5rxxmgrDqcZkARXK%2FCypXYyN77IDXoYA13z5%2FnXN9JRAXGehl15Tb0is43ikRShQauxuQH45p%2FJV8dg%3D%3D
tss
[ { "temperature" :98.6 } ]

[question] [enhancement] "dynamic" print

hi... thanks for your library, seems very cool .. i am trying to learn how to use, is a little hard to me since i am not a programmer but a sysadmin

i have an iot project (a cheap automated irrigation system for poor farmers) with arduino, this library, esp8266 (esp-01s) and the LoBo firmware (because the official firmware didn't let me save configs), and my nginx/php/mariadb webserver

i am developing a small embedded http server, mostly for inputting wifi credentials through a local webpage to connect the module and the server through internet... for example i know with this library i can do something like this...

// after receive +IPD and process http request url
void sendHtmlDashboard(WiFiClient client)
{
  client.flush(); // pseudocode to catch the idea
  char userName[20] = getUsernameSomeWay();
  char newMessages[10] = getNumMessagesSomeWay();

  client.print( F(
    "HTTP 200 OK\r\n"
    "Server: arduino/esp\r\n"
    // ... 2KB of additional http headers...
  );

  client.print( F(
    "<html>..."
    "<head, title, meta, style, script, etc... />"
    // ... 2KB of additional html headers...
  );

  client.print( F("welcome ") );
  client.print( userName );
  client.print( F(", you have ") );
  client.print( newMessages );
  client.print( F(" unread messages...") );
  // ... 2kb of additional dynamic webpage responses...

  client.stop();
}

... but i know with this will have several AT+CIPSEND commands, slowing down the overall responsiveness and resources.... so instead we can do it with 1 single cipsend command like this...

// after receive +IPD and process http request url
void sendHtmlDashboard(WiFiClient client)
{
  client.flush(); // pseudocode to catch the idea
  char userName[20] = getUsernameSomeWay();
  char newMessages[10] = getNumMessagesSomeWay();

  char response[4096] = '\0'; // note currently this can't be done with just 2kb ram

  strcpy_P( response, (PGM_P) F(
    "HTTP 200 OK\r\n"
    "Server: arduino/esp\r\n"
    // ... 2KB of additional http headers...
  );

  strcpy_P( response, (PGM_P) F(
    "<html>..."
    "<head, title, meta, style, script, etc... />"
    // ... 2KB of additional html headers...
  );

  strcpy_P( response, (PGM_P) F("welcome ") );
  strcpy( response, username );
  strcpy_P( response, (PGM_P) F(", you have ") );
  strcpy( response, messages );
  strcpy_P( response, (PGM_P) F(" new messages...") );
  // ... 2kb of additional webpage content in response...

  client.print( response ); // the single response
  client.stop();
}

... but with this way you must build the char string response before send it, which could consume a lot of ram.... i thought an alternative aproach that i don't know how to implement with this library...

// after receive +IPD and process http request url
void sendHtmlDashboard(WiFiClient client)
{
  clientl.flush(); // pseudocode to catch the idea
  char userName[20] = getUsernameSomeWay();
  char newMessages[10] = getNumMessagesSomeWay();

  // no more need to declare a char string with this techique, continue reading for details

  const __FlashStringHelper * httpHeaders = F(
    "HTTP 200 OK\r\n"
    "Server: arduino/esp\r\n"
    // ... 2KB of additional http headers...
  );

  const __FlashStringHelper * htmlHeaders = F(
    "<html>..."
    "<head, title, meta, style, script, etc... />"
    // ... 2KB of additional html headers...
  );

  const __FlashStringHelper * welcome = F("welcome ");
  const __FlashStringHelper * youHave = F(", you have ");
  const __FlashStringHelper * unreadMessages = F(" unread messages...") );
  // ... 2kb of additional webpage content in response...

  // send total data length in first place
  client.sendDataLength(
      strlen_P( (PGM_P) httpHeaders )
    + strlen_P( (PGM_P) htmlHeaders )
    + strlen_P( (PGM_P) welcome )
    + strlen( username )
    + strlen_P( (PGM_P) youHave )
    + strlen( newMessages )
    + strlen( (PGM_P) unreadMessages )
    // add additional content length if any
  );

  // ... then send the raw data itself, all at once
  // the esp8266 is already waiting "length" data because of the previous command
  client.sendData( httpHeaders );
  client.sendData( htmlHeaders );
  client.sendData( welcome );
  client.sendData( username );
  client.sendData( youHave )
  client.sendData( newmessages );
  client.sendData( unreadMessages );
  // send additional webpage content if any

  // done, now just close the link
  client.stop();
}

... or maybe a multi parameter function/macro like "client.write( str1, str2, str3 ...) (with vararg, variadic, sentinel, array of pointers, idk)

.... now the questions...

  • can something like this currently be done with this library?
  • HOW can something like this be achieved currently with this library?
  • if not, when something like this will be implemented in this library?

thanks for your fantastic library, for your patience reading, and in advance for your possible response... i am hungry waiting your response :D

startMDNS stops after 5min (TTL 300)

Hi,
I notice that startMDNS stops after 5 minutes and after there's no way to status it again
did you know how to restart the mDNS responder ?

How to print esp client hostname?

I'm using a persistent WiFi connection with dhcp enabled in client mode.
How to print esp client hostname?

Goal:
I want to feed an mqtt_clientId with the default esp hostname

const char* mqtt_clientId = "WEMOSMega_A0FFFF";

Missing API methods

Hi,

sorry if the question is somehow dumb, I've just started playing around in the arduino world. What I'm trying to do is to use the https://github.com/skaarj1989/mWebSockets library using WiFiEsp. I would be willing to implement what is need in the mWebSocket side for it to work. But as I scanned the code, there are some missing API, like hasClient().

What would it be the equivalent of that method in WiFiEspAT? Is that even make any sense? Any guidance would welcome.

Thanks.

MQTT connection problem resoult to...failed, rc=-2 try again in 5 seconds

Hello,
I hope you can help me with these error.
All seems to run smooth for a random ammount of time, then MQTT loose connectivity and did not connect anymore.

I set debug level 4 in src/utils/EspAtDrvLogging.h having these message:

`Connecting to MY_SEED
Attempting to connect to WPA SSID: MY_SEED
esp INFO: join AP MY_SEED current

WiFi connected
IP address:
esp INFO: STA IP query
192.168.178.114
Attempting MQTT connection...esp INFO: free linkId is 4
esp INFO: start TCP to 192.168.178.175:1883 on link 4
esp INFO: BuffManager new buff.stream at 0 for linkId 4 rx 64 tx 64
esp INFO: sync
esp INFO: send data on link 4
esp INFO: sent 19 bytes on link 4
esp INFO: get data on link 4
esp INFO: got 4 bytes on link 4
MQTT connected
esp INFO: send data on link 4
esp INFO: sent 64 bytes on link 4
esp INFO: send data on link 4
esp INFO: closed linkId 4
esp ERROR: failed to send data
Attempting MQTT connection...esp INFO: free linkId is 3
esp INFO: start TCP to 192.168.178.175:1883 on link 3
esp ERROR: expected OK got ERROR
failed, rc=-2 try again in 5 seconds
Attempting MQTT connection...esp INFO: closed linkId 3
esp INFO: free linkId is 3
esp INFO: start TCP to 192.168.178.175:1883 on link 3
esp ERROR: expected OK got ERROR
failed, rc=-2 try again in 5 seconds
......
`

thank you for your help

WiFi Web Server with AT version 2.2.0.0-dev

Hello,
I try to use WiFi Web Server with AT version 2.2.0.0-dev
i comment //#define WIFIESPAT1 in EspAtDrvTypes.h
PrintPersistentSettings.ino works, i can connect to my wifi access point
But when i use WebServer.ino exemple after
the connection reset and the web page doesn't appairs
client.flush();
delay(1000);
i need to add delay afer flush to solve the problem

The AT version 1.7 works well , but need MQTT and HTML at commands too with version 2.2.0.0

Here is the serial outpout, i add a
Serial.println(line.length()); to see what's happend

Thanks and HNY
Anthony

Waiting for connection to WiFi


Connected to WiFi network.
To access the server, enter "http://192.168.1.32/" in web browser.
new client 192.168.1.13
GET / HTTP/1.1
14
Host: 192.168.1.32
18
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0
89
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
82
Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3
52
Accept-Encoding: gzip, deflate
30
Connection: keep-alive
22
Upgrade-Insecure-Requests: 1
28

0->send page
client disconnected

disable some functions to save flash space

hi... i am a fan of your plugin, i use it daily xD

is there any way to disable some unused functions to save space to other stuff in sketch?...

for example, i never use ssl or udp and my sketch sizes about 95% of flash, i would like that free space to put a couple more commands, manual or web pages (telnet or http server)... currently i feel somewhat forced to get and put some sdcard module and library that will complicate and grow my config and sketch anyway

HTTP 400 Bad Request when ussing https

Hello,
I'm using this library for posting some data to a url however I'm getting HTTP400 when using ssl port 443 but it is working correctly if using non-secure port 80.
Web server is nginx using Let's Encrypt SSL certificate and tested it to work on TSL 1.2
My module is a ESP01 just updated to JB AT 1.7 firmware

I've tried both
WiFiSSLClient client > client.connect(hostname, 443)
and
WiFiClient client > client.connectSSL(hostname, 443)

I'm currently posting data to the same server using WiFiNINA library in some other modules w/o issues.
Any suggestion on how to find out a solution?
Thank you!

Custom AT Command Processor with TLS 1.2

Hi Juraj,
I am testing your library with my custom AT command processor (https://github.com/JiriBilek/ESP_ATMod).
It's quite a new project still in WIP status but I tested your library with SSL connection and it runs.

The reasons I made the ESP_ATMod project are:

  • lack of state-of-the-art TLS ciphersuites in Espressif AT firmware and all its derivations (e.g. LoBo);
  • no checking of TLS certificate at all - a big security hole. I implemented fingerprint and/or certificate checking commands. I think that we should not use insecure connection where possible.
  • the big binary of the current AT firmware can't be used on ESP-01. And this tiny module is the one I think is the most suitable for AT firmware (quite limited GPIOs prevent to use it in native applications).

I implemented only station mode and only TCP/SSL mode. No AP nor UDP connections.

I'd be very glad if you tried the firmware. If you want to make a SSL connection, just substitute "TCP" keyword with "SSL".

MQTT Connection Skip a second or RC -2 or -3

Hi,

I have this issue of which I am unable to solve thus far. My ESP8266 paired with Arduino Mega and DS3231 RTC is setup to publish data every second to thingsboard IOT online through my home WiFi.

Most times per second works fine, but occasionally it would skip a second and after 12 hours or so (sometimes sooner) it would disconnect (but able to reconnect). I would like to eliminate the skip a second + the MQTT disconnect entirely to be able to say my system is stable and reliable.

Sample of sketch in Arduino,

#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <SoftwareSerial.h>
#include "RTClib.h"
#include <SPI.h>
#include "DHT.h"
#include <WiFiClient.h>
#include <WiFiEspAT.h>

#include <WiFiUdp.h>
#include <PubSubClient.h>
#include "SoftwareSerial.h"


#define WIFI_AP "HomeWifiSSID"
#define WIFI_PASSWORD "HomePassword"

#define TOKEN "ThingsboardAccessToken"

char thingsboardServer[] = "thingsboard.cloud";
WiFiClient espClient;
PubSubClient client(espClient);


int status = WL_IDLE_STATUS;
unsigned long lastSend;

unsigned long previousDT = 0;
int uptime;  
int status2;
int status3;
int status4;
int status5;
int status6;
int status7;
int status8;

void setup()
{
  Serial.begin(38400);
  Serial1.begin(38400);
  pinMode (sensor1, INPUT);
  pinMode (sensor2, INPUT);
  pinMode (sensor3, INPUT);
  pinMode (sensor4, INPUT);
  pinMode (sensor5, INPUT);
  pinMode (sensor6, INPUT);
  pinMode (sensor7, INPUT);
  pinMode (sensor8, INPUT);
  InitWiFi();
  client.setServer( thingsboardServer, 1883 );
  lastSend = 0;
  WiFi.sleepMode(WIFI_NONE_SLEEP);

  if ( client.connect ("ClientName", "James", "Password"))  {
    Serial.println( "[DONE]" );
  }
  boolean uptime = digitalRead(sensor1);
}

void loop()
{
  DateTime now = rtc.now();
  unsigned long currentMillis = now.unixtime();
  if (currentMillis - previousDT >= intervalDT) {
    previousDT = currentMillis;

 {
      if (WiFi.status() != WL_CONNECTED) {
        Serial.println("WiFi not OK");
      }
      else {
        Serial.println("WiFi OK");
      }
    }

    Serial.print (" WiFi state: ");
    Serial.print(client.state());

    long rssi = WiFi.RSSI();
    Serial.print("Signal strength (RSSI):");
    Serial.print(rssi);
    Serial.println(" dBm");

    if (WiFi.status() == WL_CONNECTED && uptime == 0 && client.state() == 0) {
      client.loop();
     getAndSendMachineStatus();
    }
}
}

void getAndSendMachineStatus()
{

  DateTime now = rtc.now();
  unsigned int minutes = (now.hour() * 60 + now.minute());
  unsigned int seconds = minutes * 60 + now.second();
  boolean uptime = digitalRead(sensor1);
  boolean status2 = digitalRead(sensor2);
  boolean status3 = digitalRead(sensor3);
  boolean status4 = digitalRead(sensor4);
  boolean status5 = digitalRead(sensor5);
  boolean status6 = digitalRead(sensor6);
  boolean status7 = digitalRead(sensor7);
  boolean status8 = digitalRead(sensor8);
  Serial.println("Machine Status..");

  Serial.print("Uptime: ");
  Serial.print(uptime);
  Serial.print(",");
  Serial.print(status2);
  Serial.print(",");
  Serial.print(status3);
  Serial.print(",");
  Serial.print(status4);
  Serial.print(",");
  Serial.print(status5);
  Serial.print(",");
  Serial.print(status6);
  Serial.print(",");
  Serial.print(status7);
  Serial.print(",");
  Serial.print(status8);
  Serial.print(",");

  {
    if (WiFi.status() != WL_CONNECTED) {
      Serial.print("WiFi not OK");
    }
    else {
      Serial.print("WiFi OK");
    }
  }


  Serial.print(" seconds: ");
  Serial.print(seconds);

  // Prepare a JSON payload string
  String payload = " {";
  payload += "\"uptime\":"; payload += uptime; payload += ",";
  payload += "\"status2\":"; payload += status2; payload += ",";
  payload += "\"status3\":"; payload += status3; payload += ",";
  payload += "\"status4\":"; payload += status4; payload += ",";
  payload += "\"status5\":"; payload += status5; payload += ",";
  payload += "\"status6\":"; payload += status6; payload += ",";
  payload += "\"status7\":"; payload += status7; payload += ",";
  payload += "\"status8\":"; payload += status8;
  payload += "}";



  // Send payload
  char attributes[100];
  payload.toCharArray( attributes, 100 );
  client.publish( "v1/devices/me/telemetry", attributes );
  Serial.println( attributes );
}



void InitWiFi()
{
  // initialize serial for ESP module
  // initialize ESP module
  WiFi.init(&Serial1);
  // check for the presence of the shield
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue
    while (true);
  }

  Serial.println("Connecting to AP ...");
  // attempt to connect to WiFi network
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    Serial.println(WIFI_AP);
    // Connect to WPA/WPA2 network
    status = WiFi.begin(WIFI_AP, WIFI_PASSWORD);
    delay(500);
  }
  Serial.println("Connected to AP");

}

void reconnect() {
  // Loop until we're reconnected
  while (!client.connected()) {
    Serial.print("Connecting to Thingsboard node ...");
    // Attempt to connect (clientId, username, password)
    if ( client.connect ("James1992SSM", "James", "920810abcde") ) {
      Serial.println( "[DONE]" );
    } else {
      Serial.print( "[FAILED] [ rc = " );
      Serial.print( client.state() );
      Serial.println( " : retrying...]" );
      // Wait 5 seconds before retrying
      delay( 5000 );
    }
  }
}


void WiFiLoop () {


  status = WiFi.status();
  if ( status != WL_CONNECTED) {
    while ( status != WL_CONNECTED) {
      Serial.print("Attempting to connect to WPA SSID: ");
      Serial.println(WIFI_AP);
      //Connect to WPA / WPA2 network
      status = WiFi.begin(WIFI_AP, WIFI_PASSWORD);
      delay(500);
    }
    Serial.println("Connected to AP");
  }

  if ( !client.connected() ) {
    reconnect();
    client.loop();
  }

}

In the loop I've disregarded for now to use WiFiLoop() as this would attempt to reconnect loss MQTT.

My ESP8266 is connected to stable WiFi connection so I'm trying to figure out why its disconnecting at random times and skipping seconds at random times. I want my connection to be stable and no loss first.

My ESP8266 is flashed to latest:

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
OK

Set to max RX and TX power.

A quick debug so far showing an example it skipped a second:

esp INFO: soft reset
esp> AT+RST ...sent
esp> AT+RST ...ignored
esp> OK ...ignored
esp> �2s⸮⸮⸮�Y}�=w⸮93q⸮``�⸮pp⸮⸮h⸮⸮S�⸮4�⸮⸮`p⸮8⸮b⸮2⸮S�`⸮;⸮s⸮x⸮q⸮`⸮2⸮S� ...ignored
esp> ⸮PY ⸮�⸮⸮2⸮pr⸮ᡢ�p⸮Sq:1ES⸮⸮⸮`K⸮K⸮⸮C⸮⸮⸮}@a⸮⸮}=8⸮⸮⸮⸮⸮r⸮⸮Ĥ/⸮ o$ ...ignored
esp> ⸮7=R#9⸮!$⸮⸮UA!⸮eE⸮)('⸮M?.i$⸮a⸮)`.⸮lnj+⸮Ɔ⸮⸮礊⸮⸮⸮㥂D⸮ܤ+h⸮⸮Ą ...ignored
esp> ⸮⸮⸮⸮DX⸮ ...ignored
esp> ready ...matched
esp> ATE0 ...sent
esp> ATE0 ...ignored
esp> OK ...matched
esp> AT+CIPMUX=1 ...sent
esp> OK ...matched
esp> AT+CIPRECVMODE=1 ...sent
esp> OK ...matched
esp> AT+CWMODE? ...sent
esp> +CWMODE:1 ...matched
esp> OK ...matched
esp INFO: wifi status
esp> AT+CIPSTATUS ...sent
esp> STATUS:5 ...matched
esp> OK ...matched
Connecting to AP ...
Attempting to connect to WPA SSID: HomeWifiSSID
esp INFO: join AP _HomeWifiSSID_ current
esp> AT+CWJAP_CUR="HomeWifiSSID","HomePassword" ...sent
esp> ?
esp> busy p... ...ignored
esp> ?
esp> busy p... ...ignored
esp> ?
esp> busy p... ...ignored
esp> WIFI CONNECTED ...ignored
esp> ?
esp> busy p... ...ignored
esp> ?
esp> busy p... ...ignored
esp> WIFI GOT IP ...ignored
esp> OK ...matched
Connected to AP
esp INFO: set sleep mode
esp> AT+SLEEP=0 ...sent
esp> OK ...matched
esp INFO: free linkId is 4
esp INFO: start TCP to thingsboard.cloud:1883 on link 4
esp> AT+CIPSTART=4,"TCP","thingsboard.cloud",1883 ...sent
esp> ?
esp> busy p... ...ignored
esp> 4,CONNECT ...ignored
esp> OK ...matched
esp INFO: BuffManager new buff.stream at 0 for linkId 4 rx 64 tx 64
esp INFO: sync
esp> AT+CIPSTATUS ...sent
esp> STATUS:3 ...matched
esp> +CIPSTATUS:4,"TCP","54.85.19.206",1883,12611,0 ...matched
esp> OK ...end of list
esp> AT+CIPRECVLEN? ...sent
esp> +CIPRECVLEN:0,0,0,0,0 ...matched
esp> OK ...matched
esp INFO: send data on link 4
esp> AT+CIPSEND=4,46 ...sent
esp> OK ...ignored
esp> > ...matched
esp> Recv 46 bytes ...matched
esp> SEND OK ...matched
esp INFO: 	sent 46 bytes on link 4
esp> +IPD,4,4 ...processed
esp INFO: get data on link 4
esp> AT+CIPRECVDATA=4,64 ...sent
esp> +CIPRECVDATA,4 ...matched
esp> OK ...matched
esp INFO: 	got 4 bytes on link 4
[DONE]
esp INFO: wifi status
esp> AT+CIPSTATUS ...sent
esp> STATUS:3 ...matched
esp> +CIPSTATUS:4,"TCP","54.85.19.206",1883,12611,0 ...ignored
esp> OK ...matched
WiFi OK
 

WiFi state: 0esp INFO: AP query
esp> AT+CWJAP? ...sent
esp> +CWJAP:"HomeWifiSSID","7c:8b:ca:3e:d7:5b",11,-57,0 ...matched
esp> OK ...matched
Signal strength (RSSI):-57 dBm
esp INFO: wifi status
esp> AT+CIPSTATUS ...sent
esp> STATUS:3 ...matched
esp> +CIPSTATUS:4,"TCP","54.85.19.206",1883,12611,0 ...ignored
esp> OK ...matched
esp INFO: sync
esp> AT+CIPSTATUS ...sent
esp> STATUS:3 ...matched
esp> +CIPSTATUS:4,"TCP","54.85.19.206",1883,12611,0 ...matched
esp> OK ...end of list
esp> AT+CIPRECVLEN? ...sent
esp> +CIPRECVLEN:0,0,0,0,0 ...matched
esp> OK ...matched
Machine Status..
Uptime: 1,1,1,1,1,1,1,1,esp INFO: wifi status
esp> AT+CIPSTATUS ...sent
esp> STATUS:3 ...matched
esp> +CIPSTATUS:4,"TCP","54.85.19.206",1883,12611,0 ...ignored
esp> OK ...matched
WiFi OK **seconds: 81057**esp INFO: send data on link 4                         <<<<<<<<<<<<<<Here for seconds
esp> AT+CIPSEND=4,124 ...sent
esp> OK ...ignored
esp> > ...matched
esp> Recv 124 bytes ...matched
esp> ?
esp> busy s... ...ignored
esp> SEND OK ...matched
esp INFO: 	sent 124 bytes on link 4
 {"uptime":1,"status2":1,"status3":1,"status4":1,"status5":1,"status6":1,"status7":1,"status8":1}
esp INFO: wifi status
esp> AT+CIPSTATUS ...sent
esp> STATUS:3 ...matched
esp> +CIPSTATUS:4,"TCP","54.85.19.206",1883,12611,0 ...ignored
esp> OK ...matched
WiFi OK
 WiFi state: 0esp INFO: AP query
esp> AT+CWJAP? ...sent
esp> +CWJAP:"HomeWifiSSID","7c:8b:ca:3e:d7:5b",11,-58,0 ...matched
esp> OK ...matched
Signal strength (RSSI):-58 dBm
esp INFO: wifi status
esp> AT+CIPSTATUS ...sent
esp> STATUS:3 ...matched
esp> +CIPSTATUS:4,"TCP","54.85.19.206",1883,12611,0 ...ignored
esp> OK ...matched
esp INFO: sync
esp> AT+CIPSTATUS ...sent
esp> STATUS:3 ...matched
esp> +CIPSTATUS:4,"TCP","54.85.19.206",1883,12611,0 ...matched
esp> OK ...end of list
esp> AT+CIPRECVLEN? ...sent
esp> +CIPRECVLEN:0,0,0,0,0 ...matched
esp> OK ...matched
Machine Status..
Uptime: 1,1,1,1,1,1,1,1,esp INFO: wifi status
esp> AT+CIPSTATUS ...sent
esp> STATUS:3 ...matched
esp> +CIPSTATUS:4,"TCP","54.85.19.206",1883,12611,0 ...ignored
esp> OK ...matched
WiFi OK **seconds: 81059**esp INFO: send data on link 4                           <<<<<<<<<<<<<<Here for seconds
esp> AT+CIPSEND=4,124 ...sent
esp> OK ...ignored
esp> > ...matched
esp> Recv 124 bytes ...matched
esp> SEND OK ...matched
esp INFO: 	sent 124 bytes on link 4
 {"uptime":1,"status2":1,"status3":1,"status4":1,"status5":1,"status6":1,"status7":1,"status8":1}
esp INFO: wifi status
esp> AT+CIPSTATUS ...sent
esp> STATUS:3 ...matched
esp> +CIPSTATUS:4,"TCP","54.85.19.206",1883,12611,0 ...ignored
esp> OK ...matched
WiFi OK

As you can see above bolded seconds can see a 1 second skip. I really don't know why is this happening.

Is it because of the baud rate? or a delay in a sketch? I tried many possible solutions but to no avail :(

Please help thank you.

send a message to the client on connection

i want to send a welcome/status/notifications/motd message when client connects without client have to send anything...

with server.available() i got the client object but just when it sends something... so i cannot send "pushes" but just responses

Implementation of SNTP based on ESP8266 AT Firmware, officially launched by Espressif

I have modified EspAtDrv.cpp with the command sets by ESP8266 AT Firmware, officially launched by Espressif.

But I#m runnig into below issue:

// Initialize NTP client
WiFi.sntp(ntpTimeZone, ntpServer);

15:23:49.265 -> esp INFO: SNTP config
15:23:49.265 -> esp> AT+CIPSNTPCFG=1,1,"192.168.178.1" ...sent
15:23:49.265 -> esp> OK ...matched

for (int i = 0; i < 5; i++) {
setTime(WiFi.getTime());
}

15:23:49.265 -> esp INFO: SNTP time
15:23:49.265 -> esp> AT+CIPSNTPTIME? ...sent
15:23:49.265 -> esp> +CIPSNTPTIME:Thu Jan 01 00:00:00 1970 ...matched
15:23:49.265 -> esp> OK ...matched
15:23:49.265 -> esp INFO: SNTP time
15:23:49.265 -> esp> AT+CIPSNTPTIME? ...sent
15:23:49.299 -> esp> +CIPSNTPTIME:Thu Jan 01 00:00:00 1970 ...matched
15:23:49.299 -> esp> OK ...matched
15:23:49.299 -> esp INFO: SNTP time
15:23:49.299 -> esp> AT+CIPSNTPTIME? ...sent
15:23:49.299 -> esp> +CIPSNTPTIME:Thu Feb 06 15:23:50 2020 ...matched
15:23:49.299 -> esp> OK ...matched
15:23:49.299 -> esp INFO: SNTP time
15:23:49.299 -> esp> AT+CIPSNTPTIME? ...sent
15:23:49.299 -> esp> +CIPSNTPTIME:Thu Feb 06 15:23:50 2020 ...matched
15:23:49.335 -> esp> OK ...matched

Serial.println(WiFi.getTime());
Serial.println(now());

char buff[20];
sprintf(buff, "%02d-%02d-%02d %02d:%02d:%02d", year(), month(), day(), hour(), minute(), second());
Serial.println(buff);

15:32:05.210 -> 0
15:32:05.210 -> 0
15:32:05.210 -> 1970-00-00 00:00:00

Can you please adapt SNTP functions to the official commands?
ESP8266 NonOS AT Bin V1.7.1

Current UART Configuration - AT+UART_CUR?

I wants to automate my AT_BAUD_RATE configuration to ensure that the sketch is using the same baud rate as the actual configuration on ESP.

// Baud rate for communication with AT firmware
#define AT_BAUD_RATE 500000 // For Arduino Mega over Hardware Serial "500000" baud works good

Can you please implement?

Modem Sleep function

Hi,
i can use a modem sleep function with your library?
how is the command? i can't use deep sleep with esp01 beacuse don't have a wakeup reset pin

MQTT

Hi,
Your post in Arduino Forum helped me flash firmware of ESP8266 on my ATMega Wifi with ESP8266.

I tried using WiFiEsp.h but I am facing issues with new firmware and your library helps solve that.

Can you help me with Example file for Mqtt connection, I tried with PubSubClient but I get PubSubClient error rc=-1, connection works with WiFiEsp.h.

Thank you,

Regards,
Abhay

My Code is

#include <WiFiEspAT.h>
#include <PubSubClient.h> 
IPAddress server(192, 168, 10, 3); 
WiFiClient espClient;
PubSubClient client(espClient); 
int status = WL_IDLE_STATUS;

#include "arduino_secrets.h"
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
const char ssid[] = SECRET_SSID;    // your network SSID (name)
const char pass[] = SECRET_PASS;    // your network password (use for WPA, or use as key for WEP)

// Emulate Serial1 on pins 6/7 if not present
//#if defined(ARDUINO_ARCH_AVR) && !defined(HAVE_HWSERIAL1)
//#include "SoftwareSerial.h"
//SoftwareSerial Serial1(6, 7); // RX, TX
//#define AT_BAUD_RATE 9600
//#else
//#define AT_BAUD_RATE 115200
//#endif

void setup() {
Serial.begin(9600);
Serial3.begin(115200);
  //while (!Serial);

  //Serial3.begin(AT_BAUD_RATE);
WiFi.init(Serial3);

 if (WiFi.status() == WL_NO_MODULE) {
    Serial.println();
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true);
  }

  WiFi.disconnect(); // to clear the way. not persistent

  WiFi.setPersistent(); // set the following WiFi connection as persistent

  WiFi.endAP(); // to disable default automatic start of persistent AP at startup

//  uncomment this lines for persistent static IP. set addresses valid for your network
//  IPAddress ip(192, 168, 1, 9);
//  IPAddress gw(192, 168, 1, 1);
//  IPAddress nm(255, 255, 255, 0);
//  WiFi.config(ip, gw, gw, nm);

  Serial.println();
  Serial.print("Attempting to connect to SSID: ");
  Serial.println(ssid);

//  use following lines if you want to connect with bssid
//  const byte bssid[] = {0x8A, 0x2F, 0xC3, 0xE9, 0x25, 0xC0};
//  int status = WiFi.begin(ssid, pass, bssid);

  int status = WiFi.begin(ssid, pass);

  if (status == WL_CONNECTED) {
    Serial.println();
    Serial.println("Connected to WiFi network.");
    printWifiStatus();
  } else {
    WiFi.disconnect(); // remove the WiFi connection
    Serial.println();
    Serial.println("Connection to WiFi network failed.");
  }
  //connect to MQTT server 
client.setServer(server, 1883); 
client.setCallback(callback); 
client.subscribe("home/led1");
}

//print any message received for subscribed topic
void callback(char* topic, byte* payload, unsigned int length) { 
Serial.print("Message arrived ["); 
Serial.print(topic); 
Serial.print("] ");
 for (int i=0;i<length;i++) { 
Serial.print((char)payload[i]); 
} 
Serial.println(); 
} 




void loop() {
   // put your main code here, to run repeatedly:
 if (!client.connected()) { 
reconnect();
 }
 client.loop(); 
}


void printWifiStatus() {

  // print the SSID of the network you're attached to:
  char ssid[33];
  WiFi.SSID(ssid);
  Serial.print("SSID: ");
  Serial.println(ssid);

  // print the BSSID of the network you're attached to:
  uint8_t bssid[6];
  WiFi.BSSID(bssid);
  Serial.print("BSSID: ");
  printMacAddress(bssid);

  uint8_t mac[6];
  WiFi.macAddress(mac);
  Serial.print("MAC: ");
  printMacAddress(mac);

  // print your board's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

void printMacAddress(byte mac[]) {
  for (int i = 5; i >= 0; i--) {
    if (mac[i] < 16) {
      Serial.print("0");
    }
    Serial.print(mac[i], HEX);
    if (i > 0) {
      Serial.print(":");
    }
  }
  Serial.println();
}


void reconnect() { 
// Loop until we're reconnected
 while (!client.connected()) {
 Serial.print("Attempting MQTT connection..."); 
 Serial.print(server);
// Attempt to connect, just a name to identify the client
 if (client.connect("arduinoClient")) {
 Serial.println("connected"); // Once connected, publish an announcement... 
client.publish("home/led1","1"); // ... and resubscribe 
client.subscribe("home");
client.subscribe("home/led1");
 } else {
 Serial.print("failed, rc=");
 Serial.print(client.state());
 Serial.println(" try again in 5 seconds");
 // Wait 5 seconds before retrying
 delay(5000);
 }
 }
 }

Newer connect to WiFi

Waiting for connection to WiFi
.......................................................................

SSID informations correct but Can't connect to WiFi

Timeout when parsing UDP packet in a one-shot fashion

For an application that runs at a predefined sampling rate, I encountered the following problem: In most cases, when I try to parse a UDP packet, I run into timeout errors, even though the debug output shows all the right sizes. The expected package length is 64 bytes (which is confirmed by wireshark) and the library tries to read 64 bytes, but something seems to go wrong. Even more confusing is the fact that in rare cases everything seems to work, see the debug output below. This seems to depend on the rate at which the packages are coming in...

To reproduce, an Arduino sketch as a minimal working example:

#include <WiFiEspAT.h>

#define NETWORK_SSID "mynetwork"
#define NETWORK_PASS "mypassword"
#define IP IPAddress(192, 168, 0, 200)
#define PORT 10002
#define ESP8266_SERIAL Serial1
#define ESP8266_BAUD 115200

char buffer[255];
WiFiUDP udp;
unsigned long starttime;

void setup() {
  Serial.begin(115200);
  ESP8266_SERIAL.begin(ESP8266_BAUD);

  WiFi.init(&ESP8266_SERIAL);

  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println("WiFi shield not present");
    while (true);
  }
  
  WiFi.config(IP);

  while (WiFi.status() != WL_CONNECTED)
    WiFi.begin(NETWORK_SSID, NETWORK_PASS);
  
  udp.begin(PORT);
}

void loop() {
  starttime = millis();

  int packetSize = udp.parsePacket();
  if (packetSize) {
    // read the packet into packetBufffer
    int len = udp.read(buffer, 255);
    
    Serial.print("Read ");
    Serial.print(len);
    Serial.print(" bytes in ");
    Serial.print(millis() - starttime);
    Serial.println(" milliseconds.");
  }

  delay(100);
}

Without the delay(100); line everything seems to work as expected. However, with this line, the debug output reads

...

08:56:13.953 -> esp> WIFI CONNECTED ...ignored
08:56:13.953 -> esp> WIFI GOT IP ...ignored
08:56:14.898 -> esp> OK ...matched
08:56:14.898 -> esp INFO: wifi status
08:56:14.898 -> esp> AT+CIPSTATUS ...sent
08:56:14.898 -> esp> STATUS:2 ...matched
08:56:14.898 -> esp> OK ...matched
08:56:14.898 -> esp INFO: free linkId is 4
08:56:14.898 -> esp INFO: start UDP to 0.0.0.0:10002 on link 4
08:56:14.898 -> esp> AT+CIPSTART=4,"UDP","0.0.0.0",10002,10002,2 ...sent
08:56:14.898 -> esp> 4,CONNECT ...ignored
08:56:14.898 -> esp> OK ...matched
08:56:23.223 -> esp> +IPD,4,64:<DATA> ...error
08:56:24.233 -> esp ERROR: UDP message on link 4 size 64 error 3
08:56:26.512 -> esp> +IPD,4,64:<DATA> ...error
08:56:27.526 -> esp ERROR: UDP message on link 4 size 64 error 3
08:56:28.829 -> esp> +IPD,4,64:<DATA> ...error
08:56:29.813 -> esp ERROR: UDP message on link 4 size 64 error 3
08:56:30.615 -> esp> +IPD,4,64:<DATA> ...processed
08:56:30.649 -> Read 64 bytes in 5 milliseconds.
08:56:32.426 -> esp> +IPD,4,64:<DATA> ...error
08:56:33.433 -> esp ERROR: UDP message on link 4 size 64 error 3
08:56:34.350 -> esp> +IPD,4,64:<DATA> ...error
08:56:35.329 -> esp ERROR: UDP message on link 4 size 64 error 3
08:56:36.036 -> esp> +IPD,4,64:<DATA> ...error
08:56:37.041 -> esp ERROR: UDP message on link 4 size 64 error 3
08:56:37.562 -> esp> +IPD,4,64:<DATA> ...processed
08:56:37.562 -> Read 64 bytes in 4 milliseconds.
08:56:39.156 -> esp> +IPD,4,64:<DATA> ...error
08:56:40.148 -> esp ERROR: UDP message on link 4 size 64 error 3
08:56:40.947 -> esp> +IPD,4,64:<DATA> ...error
08:56:41.952 -> esp ERROR: UDP message on link 4 size 64 error 3

I hope someone has a little hint as to what I am missing or doing wrong here 😅

the sample code doesn't run

My device is esp-01,
and Firmware version is 1.3.0.0

run the chanserver.ino demo code , the message shows 「Communication with WiFi module failed!」

WiFi.macAddress() not supported in JB 1.7 firmware

Just noticed WiFi.macAddress() is not working with Jiri Bilek firmware 1.7 as AT command AT+CIPSTAMAC? is not supported.

As command AT+CIFSR is still working, I have done a quick temporary fix to function staMacQuery() in utility/EspAtDrv.cpp.

bool EspAtDrvClass::staMacQuery(uint8_t* mac) {
  maintain();

  LOG_INFO_PRINT_PREFIX();
  LOG_INFO_PRINTLN(F("STA MAC query "));

  cmd->print(F("AT+CIFSR"));
  if (!sendCommand(PSTR("+CIFSR")))
    return false;
  const char* delims = ":\"";
  char* tok = strtok(buffer, delims); //+CIFSR:STAMAC,"
  for (int i = 6; i >= 0; i--) {
    tok = strtok(NULL, delims); // <mac>[i]
    mac[i] = strtol(tok, NULL, 16);
  }
  return readOK();
}

client.connect stop working after some hours

I'm facing a very similar problem than described here: #1
With the required changes, I ported a code which uses WiFiEsp library, to your WiFiEspAT library.
The code sends data to four different servers at different time intervals. Everything works well, but after some hours (usually between 12H to 18H in my case) client.connect stops working, and every attempt to connect will fail, even to a server on the local network.
When this happens, I can ping the device running the code, and even access the web server which serves me a little web page. So WiFi is working.
I don't think this problem is caused by an AT 1.7.4 firmware error, because it not happens with the "old" WiFiEsp library, even running with AT 1.7.4
Your library is a very interesting and useful library, maybe you would like to check and / or try to reproduce the reported issue, because it really happens.
My next step will be add a counter to every client.connect event to try to verify, if the error happens after client.connect is called 255 times, as reported by bialabs, here #1

Just in case it worths, my WiFi module (ESP8266 12F) is connected to an Arduino DUE, using UART1 at 115200 bauds.

[question] getting client link id

hi ... i would like to get the client link id, to write dynamic content directly to esp someway like this...

how can i get client link id? (the example below is the simpler solution i thought, is a little difficult to me since i am not so skilled in programming)

// setup
SoftwareSerial Serial1(6, 7); // RX, TX
Serial1.begin(9600);
WiFi.init(Serial1);
//...
WiFiServer server(80);
server.begin();

// loop
WiFiClient client = server.available();
if (!client)
  return;

byte linkId = client.getLinkId(); // SOMETHING LIKE THIS

// example: print dynamic web page with client ip address
char header1[] = "HTTP/1.1 200 OK\r\n";
char header2[] ="Server: arduino/esp\r\n\r\n";
char dynamicPage[] = "your ip address is: ";

char clientIp[20];
strcpy(clientIp, client.remoteIp()); // don't know if this will work, but you got the idea

// AT+CIPSEND=(linkId),(length)\r\n
// >(data)

Serial1.write("AT+CIPSEND=")
Serial1.write(linkId); // PASSING LINK ID HERE
Serial1.write(",");
Serial1.writeln(
  strlen(header1) + // sum lengths
  strlen(header2) +
  strlen(dynamicPage) +
  strlen(clientIp)
);

client.find(">");
Serial1.write(header1); // writing composite response
Serial1.write(header2);
Serial1.write(dynamicPage);
Serial1.write(clientIp);

Issues with receiving status on sending the "AT" command

Hi,

This is Akshay again. You have been helping me on Arduino forum. I've looked at these libraries and they are very well structured. I am glad to find these libraries.

As you mentioned if we want to use Hardware Serial, we can use example "Serialpassthrough". I made a few changes in this example according to the pin out in my board (having ublox NINA W152 and SAMD51 MCU). As per your instructions, I try to send AT on the Serial monitor and it should receive "OK", but its not doing that.

RX and TX - Pins 19 and 20--------SERCOM0

I am still facing issues with a proper communication with the WiFi module. I cannot figure out what's been going wrong. Is it a coding issue or hardware issue?

Here is my code:

/*
SerialPassthrough sketch
with SoftwareSeral option

created in August 2019 for WiFiEspAT library
by Juraj Andrassy https://github.com/jandrassy
*/

//#define SAMD_FLOW_CONTROL

// Emulate Serial1 on pins 6/7 if not present
#if defined(ARDUINO_ARCH_AVR) && !defined(HAVE_HWSERIAL1)
#include "SoftwareSerial.h"
SoftwareSerial SerialAT(19, 20); // RX, TX
#define AT_BAUD_RATE 9600
#elif defined(ARDUINO_ARCH_SAMD) && defined(SAMD_FLOW_CONTROL)
#include "wiring_private.h"
Uart SerialAT(&sercom0, 19, 20, SERCOM_RX_PAD_1, UART_TX_PAD_0, 2, 255);
#define AT_BAUD_RATE 115200
#else
#define SerialAT Serial1
#define AT_BAUD_RATE 9600
#endif

void setup() {

Serial.begin(115200);
while (!Serial);

pinMode(PIN_LORA_PWREN, OUTPUT);
pinMode(PIN_WIFI_PWREN, OUTPUT);
digitalWrite(PIN_LORA_PWREN, LOW); //turn off the power to LoRa Module...
digitalWrite(PIN_WIFI_PWREN, HIGH); //turn onn the power to WiFi module...

SerialAT.begin(AT_BAUD_RATE);
#if defined(ARDUINO_ARCH_SAMD) && defined(SAMD_FLOW_CONTROL)
pinPeripheral(19, PIO_SERCOM_ALT);
pinPeripheral(20, PIO_SERCOM_ALT);
#endif
}

void loop() {
while (Serial.available()) {
SerialAT.write(Serial.read());
}
while (SerialAT.available()) {
Serial.write(SerialAT.read());
}
}

#if defined(ARDUINO_ARCH_SAMD) && defined(SAMD_FLOW_CONTROL)
void SERCOM0_Handler() {
SerialAT.IrqHandler();
}
#endif

Thanks,
Akshay

Question about extending the command set

Hi Juraj,
I started to use your library and I like it, it's quite stable. I run it for couple of weeks in 24/7 mode.
But I use my AT firmware for ESP with extended command set (https://github.com/JiriBilek/ESP_ATMod).
And the question is: what's the best way to extend the command set of your library? My first choice was the EspAtDrvClass object but several important functions are private. When functions as sendData are public, why sendCommand and simpleCommand are kept private?

ConfigurationAP example not working

Hello I am using this library with Arduino Due and it works great I have UDP connection and also webserver running but recently I started to experiment with the ConfigurationAP example and this example is not working for me also without any code change the programm stops exactly after "Connection successful. Ending AP." and programm is never restarted and wifi module never connects again to the received SSID and Password from the webserver page

Thanks

WiFiSSLClient example problem

I tried the WiFiSSLClient example from Arduino (almost unchanged, only changed Serial1 to Serial3).
My problem is that the HTTP response is not received:

Waiting for connection to WiFi
......
Connected to WiFi network.
Starting connection to server...
connected to server

disconnecting from server.

The firmware seems to be OK based on the CheckFirmware example:

AT firmware version 1.7.4.0
AT firmware is OK for the WiFiEspAT library.

Is there any additional configuration I'm missing? Thanks.

HTTP 400 Bad Request when using HTTPS

Hello,
I'm using this library for posting some data to a url however I'm getting HTTP400 when using ssl port 443 but it is working correctly if using non-secure port 80.
Web server is nginx using Let's Encrypt SSL certificate.
My module is a ESP01 just updated to JB AT 1.7 firmware

I've tried both
WiFiSSLClient client > client.connect(hostname, 443)
and
WiFiClient client > client.connectSSL(hostname, 443)

I'm currently posting data to the same server using WiFiNINA library in some other modules w/o issues.
Any suggestion on how to find out a solution?
Thank you!

Disable AP mode

Hi, I'm using this library to connect over a wifi network and send data to an API, everything works fine.

The question is that I realized that ESP is active as if it were a router too, that is, if I look at the available wireless networks the ESP appears, I would like to disable it, is there how?

'Stream' has not been declared

Hi,
I'm getting following error when trying to compile ScanNetworksAdvanced example for Arduino nano 33
/home/.../Arduino/libraries/WiFiEspAT/src/utility/EspAtDrvTypes.h:61:30: error: 'Stream' has not been declared
virtual uint8_t readRxData(Stream* serial, size_t len) = 0;

Where is the problem? How to get it?
Thank you

Problems with SNTPTime example

Hello, I'm having this problem with the SNTPTime example:

Waiting for connection to WiFi
.
Waiting for SNTP
............................................................................................................................................................................................................................

A liitle problem

Hi sir
Does your library support the ( client.setNoDelay(true); ) command?
Because when compiling it gave the following error!
Error :
'class WiFiClient' has no member named 'setNoDelay'

[request] please re enable getLinkId() function again

as requested in #5 ...

is helpful for me, and for many people will and would be also, everytime the lib gets updated i have to patch it manually

i understand your argument about overwriting a link object with still unread data could lead to data loss and break sync

but C and C++ language philosophy is about give all tools, flexibility and freedom to programmers to do anything we want with the system at any level (hardware level, low level, user level, etc), together with the most complete documentation possible, so we could develop whatever tool we want/need, and if we commit a mistake we could assume our responsibility, fix it, learn about it, avoid mistakes in the future, write better programs, and grow as a developer

think in commands like memcpy() that don't check for cstring terminators '\0', it still exists and can be used to greatly improve some things, but warns strongly about buffer overflows... if memcpy() wouldn't exist because of buffer overflow risks, a lot of great things couldn't be done also

and about data loss, it could be just prevented by checking old client before overwriting new

WiFiClient newClient = server.accept();
if ( newClient )
{
  for ( byte i=0; i < MAX_CLIENTS; ++i )
  {
    if ( !clients[i] )
    {
      // ...
      // check if old client has still unread data before replacing it
      // anyway is already disconnected so it won't send any more data
      if ( clients[i].available() )
        consumeRemainingDataSomeWay(clients[i]);
      clients[i] = newClient;
      break;
    }
  }
}

the unlikely data loss risk done by uncareful programmers doesn't worth all the benefits we will gain with getLinkId(), if done in right way with the correct documentation... the use we give to the library is up to us, you will give more usefulness to the library and freedom to us

please reconsider, document the risks and re enable it

No stable tcp connections - Disable ESP deep sleep mode

I was running into a nightmare - no stable tcp connections to my MQTT server ...

The following has fixed my painful issue:

// Disable ESP deep sleep mode
Serial.println("Sending AT deep sleep change (disable deep sleep) ...");
SerialAT.println("AT+SLEEP=0");

Can you please document and implement?

Arduino MEGA + ESP8266 WIFI Inbuilt Board

I recently started a project to read analog values from arduino mega and send those values to the REST API endpoint using POST.
To do this I brought an Arduino MEGA + ESP8266 WIFI Inbuilt Board board. I think I really messed up with firmware. I can upload sketches to mega but I can't connect to the ESP module. (I have tried with the DIP switch). Could you help me to find the right firmware and fix this? That would a huge help.
Thank You!

AT firmware not responding - MQTT TCP

Hi Juraj,

For starter... ESP8266 firmware 👍

20:40:40.958 -> AT+GMR
20:40:40.958 -> AT version:1.7.4.0(May 11 2020 19:13:04)
20:40:40.992 -> SDK version:3.0.4(9532ceb)
20:40:41.025 -> compile time:May 27 2020 10:12:17
20:40:41.059 -> Bin version(Wroom 02):1.7.4
20:40:41.092 -> OK

PLATFORM: Arduino Uno/Mega + ESP8266 (UART)

ESP connects to the WiFi network correctly:

20:32:12.297 -> esp> AT+CIPMUX=1 ...sent
20:32:12.414 -> esp> OK ...matched
20:32:14.513 -> esp> AT+CIPSTATUS ...sent
20:32:14.513 -> esp> STATUS:5 ...matched
20:32:14.513 -> esp> OK ...matched
20:32:15.525 -> esp> WIFI GOT IP ...ignored
20:32:15.525 -> esp INFO: wifi status
20:32:15.525 -> esp> AT+CIPSTATUS ...sent
20:32:15.562 -> esp> STATUS:2 ...matched
20:32:15.562 -> esp> OK ...matched
20:32:15.562 -> 
20:32:15.562 -> Connected to WiFi
20:32:15.562 -> 
20:32:15.562 -> IPv4 Address: esp INFO: STA IP query
20:32:15.612 -> esp> AT+CIPSTA? ...sent
20:32:15.612 -> esp> +CIPSTA:ip:"192.168.1.229" ...matched
20:32:15.645 -> esp> +CIPSTA:gateway:"192.168.1.1" ...matched
20:32:15.680 -> esp> +CIPSTA:netmask:"255.255.255.0" ...matched

PROBLEM:

20:32:17.772 -> esp INFO: free linkId is 4
20:32:17.772 -> esp INFO: start TCP to hairdresser.cloudmqtt.com:16068 on link 4
20:32:17.812 -> esp> AT+CIPSTART=4,"TCP","hairdresser.cloudmqtt.com",16068 ...sent
20:32:18.840 -> esp> ?
20:32:19.839 -> esp> ?
20:32:20.858 -> esp> ?
20:32:21.845 -> esp ERROR: AT firmware not responding
20:32:21.895 -> 
20:32:21.895 -> MQTT: -2
20:32:24.976 -> esp>  ...ignored

I can't connect to the MQTT cloud broker... I have no idea why it's happening because I have tested it few times without your library - just Arduino console. Here's the example of what I did:

20:39:10.139 -> AT
20:39:10.139 -> 
20:39:10.139 -> OK

// AT+CIPMUX=0

20:39:28.255 -> AT+CIPSTART=4,"TCP","hairdresser.cloudmqtt.com",16068
20:39:28.304 -> Link type ERROR
20:39:28.304 -> 
20:39:28.304 -> ERROR

// AT+CIPMUX=1

20:39:44.003 -> AT+CIPMUX=1
20:39:44.003 -> 
20:39:44.003 -> OK
20:39:54.825 -> AT+CIPSTART=4,"TCP","hairdresser.cloudmqtt.com",16068
20:39:54.908 -> 4,CONNECT
20:39:54.908 -> 
20:39:54.908 -> OK

However I saw that WiFiEspAT sets up the AT+CIPMUX=1 in the beginning.

20:32:12.297 -> esp> AT+CIPMUX=1 ...sent
20:32:12.414 -> esp> OK ...matched

What can cause such a stupid... bug? I use PubSubClient library by knolleary.

I would be very thankful for your help. :)

~ Daniel

[idea] queue multiple things and print all with one at+cipsend

imagine an object like BatchPrinter or something, that accumulates pointers to strings, fstrings, numbers, etc, and then prints all at once in one at+cipsend command

i mean formalize something like what i tried to do in #5 (comment) and #5 (comment)

imagine you make a compound http response with elements of many types taken from everywhere (pointers, no buffer), so you can queue, sum the lengths and print all in sequence at once

#define S const __FlashStringHelper *

WiFiClient myClient = httpClientWaitingResponse;

S welcome = F("<h1>Welcome ");
char user[] = "John Doe";
S notif = F(
  " <h1>"
  "<h2>you have "
);
int unread = getUnreadMessages();
S foot = F(" unread messages</h2>");

StackPrinter printerContents = myClient.newMassPrinter();
printerContents.add(welcome);
printeContentsr.add(user);
printeContentsr.add(notif);
printerContents.add(unread);
printerContents.add(foot);

StackPrinter printerHeaders = myClient.newMassPrinter();
printerHeaders.add(F(
  "HTTP/1.1 200 OK\r\n"
  "Content-Length: "
);
printerHeaders.add(printerContents.length());
printerHeaders.add("\r\n\r\n");

printerHeaders.printAll(myClient);
printerHeaders.destroy();
printerContents.printAll(myClient);
printerContents.destroy();

internally could work something like this (pseudocode java style, i am not so skilled in c[++]?)...

class BurstPrinter
{
  private int length = 0;
  private Object *jobs[] = new *Object[](); // some way to store different type pointers?, or with many arrays?
  
  public void add(Object obj) // overloaded method, or at least for char, char*, Fstr, byte, int, long, float, double ([un]signed)
  {
    length += obj.length();
    jobs.put(&obj);
  }

  public int length()
  {
    return this.length;
  }

  public void printAll(WiFiClient client)
  {
    client.print(F("AT+CIPSEND=");
    client.print(client.linkId);
    client.print(F(","));
    client.print(length);
    client.println();
    client.find('>');

    for (byte i = 0; i < jobs.size(); ++i) // <--- here the magic happens
      client.print(&jobs[i]);
  }

  public void destroy()
  {
    this.length = 0;
    this.jobs = null;
    this = null; // dont laugh ok?
  }
}

did you catch the idea ???

RE: DNS fail

Hello, truly sorry to be a bother.
I found a solution to my issue with the dns fail, it seems that the "SetupPersistentWiFiConnection" sketch
did not save the DNS addresses received by the router I had to add

IPAddress DNS = WiFi.dnsServer1();
IPAddress DNS2 = WiFi.dnsServer2();
WiFi.setDNS(DNS,DNS2);

for it to work, I do not know if this is an issue with my ESP8266 model / firmware but I thought it would interest you to know.

Now everything works fine, thank you for the great library and your time.

Ip address error in Wifi Client mode

Hi,
my esp8266, with At 1.7 command release,it's set in client mode (temporary o super persistent connection) received ip address isn't correct.
My WiFi network dchp server have ip range 192.168.0.2 to 255 but ip recived in serial monitor from esp8266 is 65.38.83.95. This received address will not ping from cmd. Work only whith fixed ip address, gatway and subnetmask.
can you help me?

Ignored AT commands during WiFi setup

AT version:1.7.1.0(Jul 15 2019 16:58:04)
SDK version:3.0.1(78a3e33)
compile time:Jul 15 2019 18:12:41

My WiFi configuration:

//=======================================================================
// Setup Wifi
//=======================================================================
IPAddress wifiIP;
uint8_t wifiMac[6];
char wifiMacStr[18];
char wifiHostname[11];
long wifiRssi;

unsigned long wifiErrorCounter = 0;

void setup_wifi() {
// Initialize Serial port for communication with the WiFi module
SerialAT.begin(AT_BAUD_RATE);
WiFi.init(SerialAT);

// Check if Serial port for communication with the WiFi module is working
if (WiFi.status() == WL_NO_MODULE) {
Serial.println();
Serial.println("Communication with WiFi module failed!");
// don't continue
while (true) {
blink(100);
}
}

// Disable ESP deep sleep mode
Serial.println("Sending AT deep sleep change (disable deep sleep) ...");
SerialAT.println("AT+SLEEP=0");
blink(500);

// Disable default automatic start of persistent AP
WiFi.endAP(true);

// Waiting for connection to Wifi network set with the SetupWiFiConnection sketch
Serial.println("Waiting for connection to WiFi");
while (WiFi.status() != WL_CONNECTED) {
blink(500);
Serial.print('.');
}
Serial.println();
Serial.println("Connected to WiFi network.");

// SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());

// Your WiFi shield's IP address:
wifiIP = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(wifiIP);

// Your WiFi shield's MAC address
WiFi.macAddress(wifiMac);
snprintf(wifiMacStr, sizeof(wifiMacStr), "%02X:%02X:%02X:%02X:%02X:%02X", wifiMac[5], wifiMac[4], wifiMac[3], wifiMac[2], wifiMac[1], wifiMac[0]);
Serial.print("MAC Address: ");
Serial.println(wifiMacStr);

// Your WiFi shield's hostname:
snprintf(wifiHostname, sizeof(wifiHostname), "ESP-%02X%02X%02X", wifiMac[2], wifiMac[1], wifiMac[0]);
Serial.print("Hostname: ");
Serial.println(wifiHostname);

// The received WiFi signal strength:
wifiRssi = WiFi.RSSI();
Serial.print("Signal Strength (RSSI): ");
Serial.print(wifiRssi);
Serial.println(" dBm");
}

16:27:03.665 -> esp INFO: soft reset
16:27:03.665 -> esp> AT+RST ...sent
16:27:03.665 -> esp> ...ignored
16:27:03.665 -> esp> ⸮ ...ignored
16:27:03.665 -> esp> ...ignored
16:27:03.698 -> esp> ⸮ ...ignored
16:27:03.698 -> esp> ⸮ ...ignored
16:27:03.766 -> esp> ...ignored
16:27:03.800 -> esp> ⸮⸮⸮⸮⸮ ...ignored
16:27:03.800 -> esp> ...ignored
16:27:03.800 -> esp> ⸮ ...ignored
16:27:03.800 -> esp> ...ignored
16:27:03.800 -> esp> ...ignored
16:27:03.800 -> esp> ⸮ ...ignored
16:27:03.800 -> esp> ⸮ ...ignored
16:27:03.800 -> esp> ⸮⸮⸮⸮ ...ignored
16:27:03.800 -> esp> ready ...matched
16:27:03.800 -> esp> ATE0 ...sent
16:27:03.800 -> esp> ATE0 ...ignored
16:27:03.800 -> esp> OK ...matched
16:27:03.800 -> esp> AT+CIPMUX=1 ...sent
16:27:03.800 -> esp> OK ...matched
16:27:03.800 -> esp> AT+CIPRECVMODE=1 ...sent
16:27:03.834 -> esp> OK ...matched
16:27:03.834 -> esp> AT+CWMODE? ...sent
16:27:03.834 -> esp> +CWMODE:1 ...matched
16:27:03.834 -> esp> OK ...matched
16:27:03.834 -> esp INFO: wifi status
16:27:03.834 -> esp> AT+CIPSTATUS ...sent
16:27:03.834 -> esp> STATUS:5 ...matched
16:27:03.834 -> esp> OK ...matched
16:27:03.834 -> Sending AT deep sleep change (disable deep sleep) ...
16:27:04.833 -> esp> OK ...ignored
16:27:04.833 -> esp> WIFI CONNECTED ...ignored
16:27:04.833 -> esp> WIFI GOT IP ...ignored
16:27:04.833 -> esp INFO: end SoftAP persistent
16:27:04.833 -> Waiting for connection to WiFi
16:27:04.833 -> esp INFO: wifi status
16:27:04.833 -> esp> AT+CIPSTATUS ...sent
16:27:04.867 -> esp> STATUS:2 ...matched
16:27:04.867 -> esp> OK ...matched
16:27:04.867 ->
16:27:04.867 -> Connected to WiFi network.
16:27:04.867 -> SSID: esp INFO: AP query
16:27:04.867 -> esp> AT+CWJAP? ...sent
16:27:04.867 -> esp> +CWJAP:"area053","e0:28:6d:cf:f1:e1",11,-73,0 ...matched
16:27:04.867 -> esp> OK ...matched
16:27:04.867 -> area053
16:27:04.867 -> esp INFO: STA IP query
16:27:04.867 -> esp> AT+CIPSTA? ...sent
16:27:04.867 -> esp> +CIPSTA:ip:"192.168.178.35" ...matched
16:27:04.867 -> esp> +CIPSTA:gateway:"192.168.178.1" ...matched
16:27:05.883 -> esp> +CIPSTA:netmask:"255.255.255.0 ...matched
16:27:06.864 -> esp> ?
16:27:06.864 -> esp> ERROR ...error
16:27:06.864 -> esp ERROR: expected OK got ERROR
16:27:06.864 -> IP Address: 192.168.178.35
16:27:06.898 -> esp INFO: STA MAC query
16:27:06.898 -> esp> AT+CIPSTAMAC? ...sent
16:27:06.898 -> esp> +CIPSTAMAC:"a4:cf:12:c6:06:50" ...matched
16:27:06.898 -> esp> OK ...matched
16:27:06.898 -> MAC Address: A4:CF:12:C6:06:50
16:27:06.898 -> Hostname: ESP-C60650
16:27:06.898 -> esp INFO: AP query
16:27:06.898 -> esp> AT+CWJAP? ...sent
16:27:06.898 -> esp> +CWJAP:"area053","e0:28:6d:cf:f1:e1",11,-72,0 ...matched
16:27:06.898 -> esp> OK ...matched
16:27:06.898 -> Signal Strength (RSSI): -72 dBm

problem using WIFIESPAT library

Hi Mr. JANDRASSY
I want to upload a wave file, that is stored in my sd card to a web server with ESP12-F module which connected to Arduino mega 2560 with serial (UART) port, and I using of your library's (WiFiEspAt.h)
but my problem is for uploading files with size Biggers than 32k to the webserver (WampServer I using), because I don't have problem with files less than 32kb for uploading
I attached my sketch and php code below
If you can help me
thanks ...

my sketch

#include <WiFiEspAT.h>
#include <SD.h>
#include <SPI.h>
//#include <StreamLib.h>

File myFile;

String post_host = "192.168.1.103";
const int  post_port  = 80;
String  url = "/upload_file.php";
char server[] = "192.168.1.103";

// Emulate Serial1 on pins 6/7 if not present
#if defined(ARDUINO_ARCH_AVR) && !defined(HAVE_HWSERIAL1)
//#include <SoftwareSerial.h>
//SoftwareSerial Serial1(6, 7); // RX, TX
#define AT_BAUD_RATE 9600
#else
#define AT_BAUD_RATE 115200
#endif

//const char* server = "arduino.cc";

WiFiClient client;


//format bytes
String formatBytes(unsigned int bytes) {
  if (bytes < 1024) {
    return String(bytes) + "B";
  } else if (bytes < (1024 * 1024)) {
    return String(bytes / 1024.0) + "KB";
  } else if (bytes < (1024 * 1024 * 1024)) {
    return String(bytes / 1024.0 / 1024.0) + "MB";
  }
}

void setup() {
  Serial.begin(115200);
  while (!Serial);

  Serial1.begin(AT_BAUD_RATE);
  WiFi.init(Serial1);

  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println();
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true);
  }

  // waiting for connection to Wifi network set with the SetupWiFiConnection sketch
  Serial.println("Waiting for connection to WiFi");
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.print('.');
  }
  Serial.println();
  Serial.println("Connected to WiFi network.");

   //test connect to sd
  Serial.print("Initializing SD card...");
  if (!SD.begin(53))
  {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");

  //read file from SD
  //define file
  myFile = SD.open("data.wav", FILE_READ);


  String fileName = myFile.name();
  String fileSize = formatBytes(myFile.size());

  Serial.println();
  Serial.println("file exists");


  if (myFile)
  {
    Serial.println("test file:ok");
    // print content length and host
    Serial.print("contentLength : ");
    Serial.println(fileSize);
    Serial.print("connecting to ");
    Serial.println(post_host);

    // We now create a URI for the request
    Serial.println("Connected to server");
    Serial.print("Requesting URL: ");
    Serial.println(url);

    // Make a HTTP request and add HTTP headers
    //String boundary = "CustomizBoundarye----";
    //change with your content type
    String contentType = "audio/x-wav";
    String portString = String(post_port);
    String hostString = String(post_host);


    String requestHead = "--RandomNerdTutorials\r\nContent-Disposition: form-data; name=\"data\"; filename=\"data.wav\"\r\nContent-Type: audio/x-wav\r\n\r\n";

    String tail = "\r\n--RandomNerdTutorials--\r\n";


    int contentLength =  requestHead.length() + myFile.size() + tail.length();

    client.connect(server, 80);

    client.println("POST " + url + " HTTP/1.1");
    client.println("Host: " + post_host);
    client.println("Content-Length: " + String(contentLength, DEC));
    client.println("Content-Type: multipart/form-data; boundary=RandomNerdTutorials");
    client.println();
    client.print(requestHead );

    // send myFile:
    //this method is for upload data very fast
    //and only work in ESP software version after 2.3.0
    //if your version is lower than please update
    //esp software to last version or use bellow comment code
    client.write(myFile);
    // create file buffer
    const int bufSize = 2048;
    byte clientBuf[bufSize];
    int clientCount = 0;

    while (myFile.available())
    {
      clientBuf [clientCount] = myFile.read ();
      clientCount++;
      if (clientCount > (bufSize - 1))
      {
        client.write((const uint8_t *)clientBuf, bufSize);
        clientCount = 0;
      }

    }

    if (clientCount > 0)
    {
      client.write((const uint8_t *)clientBuf, clientCount);

    }

    // send tail
    //      char charBuf3[tail.length() + 1];
    //      tail.toCharArray(charBuf3, tail.length() + 1);
    client.print(tail);


    //Serial.print(charBuf3);
  }
  else
  {
    // if the file didn't open, print an error:
    Serial.println("error opening test.WAV");
    Serial.println("Post Failure");
  }



  // Read all the lines of the reply from server and print them to Serial


  Serial.println("request sent");
  String responseHeaders = "";

  while (client.connected() ) {
    //      Serial.println("while client connected");
    String line = client.readStringUntil('\n');
    Serial.println(line);
    responseHeaders += line;
    if (line == "\r") {
      Serial.println("headers received");
      break;
    }
  }

  String line = client.readStringUntil('\n');

  Serial.println("reply was:");
  Serial.println("==========");
  Serial.println(line);
  Serial.println("==========");
  Serial.println("closing connection");

  //close file
  myFile.close();

}
//}
void loop()
{}

the php code

<?PHP

    $path = "data/";
    $path = $path . basename( $_FILES['data']['name']);
    if(move_uploaded_file($_FILES['data']['tmp_name'], $path)) {
      echo "The file ".  basename( $_FILES['data']['name']).
      " has been uploaded";
    } else{
        echo "There was an error uploading the file, please try again!";
   
  }
?>

problem with multiple connections

i am testing this library (1.0.1 and Espressif's AT firmware 1.7.1) with the following sketch:

#include "WiFiEspAT.h"

char ssid[] = "Wifi";            // your network SSID (name)
char pass[] = "pass";        // your network password
int status = WL_IDLE_STATUS;     // the Wifi radio's status

char server[] = "arduino.cc";

unsigned long lastConnectionTime = 0;         // last time you connected to the server, in milliseconds
const unsigned long postingInterval = 10000L; // delay between updates, in milliseconds

// Initialize the Ethernet client object
WiFiClient client;

void setup()
{
  // initialize serial for debugging
  Serial.begin(115200);
  // initialize serial for ESP module
  Serial3.begin(9600);
  // initialize ESP module
  WiFi.init(&Serial3);

  // check for the presence of the shield
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue
    while (true);
  }

  // attempt to connect to WiFi network
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network
    status = WiFi.begin(ssid, pass);
  }

  Serial.println("You're connected to the network");
  
  printWifiStatus();
}

void loop()
{
  // if there's incoming data from the net connection send it out the serial port
  // this is for debugging purposes only
  while (client.available()) {
    char c = client.read();
    Serial.write(c);
  }

  // if 10 seconds have passed since your last connection,
  // then connect again and send data
  if (millis() - lastConnectionTime > postingInterval) {
    httpRequest();
  }
}

// this method makes a HTTP connection to the server
void httpRequest()
{
  Serial.println();
    
  // close any connection before send a new request
  // this will free the socket on the WiFi shield
  client.stop();

  // if there's a successful connection
  if (client.connect(server, 80)) {
    Serial.println("Connecting...");
    
    // send the HTTP PUT request
    client.println(F("GET /asciilogo.txt HTTP/1.1"));
    client.println(F("Host: arduino.cc"));
    client.println("Connection: close");
    client.println();

    // note the time that the connection was made
    lastConnectionTime = millis();
  }
  else {
    // if you couldn't make a connection
    Serial.println("Connection failed");
  }
}


void printWifiStatus()
{
  // print the SSID of the network you're attached to
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength
  long rssi = WiFi.RSSI();
  Serial.print("Signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

i have two problems

  • sometimes (3 times on 10) i get "Connection failed"
    debug output:
esp> AT+CIPSTART=4,"TCP","www.mysite.com",80 ...sent
esp> ?
esp> busy p... ...ignored

esp> ?
esp> busy p... ...ignored

esp> ?
esp> busy p... ...ignored

esp> ?
esp> busy p... ...ignored

esp> ?
esp> busy p... ...ignored

esp> ?
esp> busy p... ...ignored

esp> ?
esp> busy p... ...ignored

esp> ?
esp> busy p... ...ignored

esp> ?
esp> busy p... ...ignored

esp> ?
esp> busy p... ...ignored

esp> ?
esp> busy p... ...ignored

esp> ?
esp> busy p... ...ignored

esp> ?
esp> busy p... ...ignored

esp> DNS Fail ...ignored

esp> ERROR ...error
esp ERROR: expected OK got ERROR
Connection failed
  • sometimes (1 times on 10) Serial.write(c) doesn't write anything (connect works in this case because i get "Connecting...")
    debug output:
esp> AT+CIPSTART=4,"TCP","www.mysite.com",80 ...sent
esp> 4,CONNECT ...ignored
esp> OK ...matched
Connecting...
esp INFO: send data on link 4
esp> AT+CIPSEND=4,64 ...sent
esp> OK ...ignored

esp> > ...matched
esp> Recv 64 bytes ...matched
esp> ?
esp> busy s... ...ignored

esp> ?
esp> busy s... ...ignored

esp> ?
esp> busy s... ...ignored

esp> ?
esp> busy s... ...ignored

esp> ?
esp> busy s... ...ignored

esp> ?
esp> busy s... ...ignored

esp> ?
esp> busy s... ...ignored

esp> 4,CLOSED ...processed
esp INFO: closed linkId 4
esp> SEND FAIL ...matched
esp ERROR: failed to send data
esp INFO: send data on link 4
esp ERROR: link is not connected.

esp INFO: close link 4
esp WARN: link is not active
esp INFO: free linkId 4
esp INFO: start TCP to www.mysite.com:80 on link 4
esp> AT+CIPSTART=4,"TCP","www.mysite.com",80 ...sent
esp> ?
esp> busy p... ...ignored

esp> ?
esp> busy p... ...ignored

esp> ?
esp> busy p... ...ignored

esp> ?
esp> busy p... ...ignored

esp> ?
esp> busy p... ...ignored

esp> ?
esp> busy p... ...ignored

esp> ?
esp> busy p... ...ignored

esp> ?
esp> busy p... ...ignored

esp> ?
esp> busy p... ...ignored

esp> ?
esp> busy p... ...ignored

esp> 4,CONNECT ...ignored
esp> OK ...matched
Connecting...

what i have tried

  • connect to my hosting instead arduino.cc
  • higher baudrate (115200, 250000)

but nothing changes

how can improve my sketch?
or is related to the library?

Time_Zone is not working function WiFi.sntp(TIME_ZONE, "us.pool.ntp.org");

Changed nothing to SNTPtime.ino
Get Always the UTC time, no matter what number I put in const int8_t TIME_ZONE = 2; // UTC + 2
-14 or 13 always UTC time

Waiting for SNTP
.
2021-05-01 09:15:57
2021-05-01 09:15:58
2021-05-01 09:15:59
2021-05-01 09:16:00
2021-05-01 09:16:01
2021-05-01 09:16:02
2021-05-01 09:16:03
2021-05-01 09:16:04
2021-05-01 09:16:05
2021-05-01 09:16:06
2021-05-01 09:16:07
2021-05-01 09:16:08
ESP 01 8bit
OK
AT+GMR
AT version:2.2.0.0-dev(ecf20b7 - Jul 24 2020 08:05:55)
SDK version:v3.3-2-gb6e861a
compile time(7650c83):Aug 1 2020 20:15:06
Bin version:2.0.0(Unknown)

OK

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.