Cannot initialize ESP-AT Lib

Summary: Getting error “Cannot initialize ESP-AT Lib!” when using Wifi HTTP or HTTPS examples from the Wiki at https://wiki.seeedstudio.com/Wio-Terminal-Wi-Fi/ . An older version of the ESP-AT Library works but the current version on Github doesn’t.

Description:

I’ve been using the WIO Terminal with Wifi for some time and it always connects to the network and to the webserver just fine.

But today I installed Arduino on a different computer and downloaded all the libraries I needed from Github. Now when I run the WIFI example I get the error “Cannot initialize ESP-AT Lib”.

If I use a previous release of the ESP-AT Library it works fine. But the current release on Github doesn’t.

I would have posted this in the “issues” section on Github but it looks like it has been disabled.

Hi @Dennis_Mabrey

I just tested with the latest esp-at lib and seems to be working fine on my end

Which verison of esp-at lib you are using, let me recreate this

Hi. I have the same problem using the develop branch of the library. The WiFiScan example works (as you have shown here) but anything that actually connects to a network (e.g. SimpleWiFiServer) fails with the following sort of output in the serial monitor (I haven’t managed to find a version of the esp-at library that works for me):

09:41:41.739 -> Device reset detected!
09:41:45.414 -> Cannot initialize ESP-AT Lib!
09:41:52.539 -> [E][esp_event_loop.c:99] at_unified_cb(): at_unified evt: 4
09:41:52.539 -> 
09:41:53.044 -> Connecting to WiFi..
09:41:53.525 -> Connecting to WiFi..
09:41:54.035 -> Connecting to WiFi..
09:41:54.510 -> Connecting to WiFi..
09:41:55.017 -> Connecting to WiFi..
09:41:55.525 -> Connecting to WiFi..
09:41:56.027 -> Connecting to WiFi..
09:41:56.507 -> Connecting to WiFi..
09:41:57.016 -> Connecting to WiFi..
09:41:57.531 -> Connecting to WiFi..
09:41:58.010 -> Connecting to WiFi..
09:41:58.514 -> Connecting to WiFi..
09:41:59.017 -> Connecting to WiFi..
09:41:59.523 -> Connecting to WiFi..
09:42:00.030 -> Connecting to WiFi..
09:42:00.501 -> Connecting to WiFi..
09:42:00.838 -> [E][esp_event_loop.c:99] at_unified_cb(): at_unified evt: 4
09:42:00.838 -> 
09:42:01.008 -> Connecting to WiFi..
09:42:01.515 -> Connecting to WiFi..
09:42:02.021 -> Connecting to WiFi..
09:42:02.021 -> Connected to the WiFi network
09:42:02.021 -> IP Address: [E][esp_event_loop.c:99] at_unified_cb(): at_unified evt: 4
09:42:02.595 -> 
09:42:03.821 -> 68.3.0.32

This was generated by this sketch:

#include "AtWiFi.h"
 
const char* ssid = "xxxx";
const char* password =  "xxxx";
 
void setup() {
    Serial.begin(115200);
    while(!Serial); // Wait for Serial to be ready
    delay(1000);
 
    // Set WiFi to station mode and disconnect from an AP if it was previously connected
    WiFi.mode(WIFI_STA);
    WiFi.disconnect();
    delay(2000);
 
    WiFi.begin(ssid, password);
 
    while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.println("Connecting to WiFi..");
    }
    Serial.println("Connected to the WiFi network");
    Serial.print("IP Address: ");
    Serial.println (WiFi.localIP()); // prints out the device's IP address
    }
 
void loop() {
 
}

I was using the developer release from here https://github.com/Seeed-Studio/esp-at-lib. It was from commit 1bf13e4.

All the libraries I used were from the links from the wiki network page form here https://wiki.seeedstudio.com/Wio-Terminal-Network-Overview/

I used this library before and it just recently started having this problem. As a temporary solution try downloading from the last May 08,2020 commit. It should work ok as a temp solution.

So I rolled back esp-at to 8th May and that caused errors in atUnified and atWiFi. So I rolled those back to 8th May as well and finally it worked. Thanks @Dennis_Mabrey for the pointer in the right direction - I’m very pleased my brand new Wio Terminal can now connect to wifi.

16:40:41.143 -> Connecting to WiFi..
16:40:41.650 -> Connecting to WiFi..
16:40:42.158 -> Connecting to WiFi..
16:40:42.669 -> Connecting to WiFi..
16:40:42.669 -> Connected to the WiFi network
16:40:42.669 -> IP Address: 192.168.1.107

Huh that’s funny I had not rolled those back and they worked for me. Anyway glad it is working for you now. Hopefully they will resolve the esp-at library problem…

Hi. It look like I am having this issue.

Do you know if there is a specific fix for this…

I have followed the instructions as per https://wiki.seeedstudio.com/Wio-Terminal-Network-Overview/

I copied the Scanning Wi-Fi Network Example Code and this is the serial monitor:-

Device reset sequence finished!
Cannot initialize ESP-AT Lib!
[E][esp_event_loop.c:99] at_unified_cb(): at_unified evt: 4

[E][WiFiGeneric.cpp:477] mode(): Could not set mode! -1
[E][esp_event_loop.c:99] at_unified_cb(): at_unified evt: 4

Setup done
scan start
[E][esp_event_loop.c:99] at_unified_cb(): at_unified evt: 4

[E][esp_event_loop.c:99] at_unified_cb(): at_unified evt: 4

[E][esp_event_loop.c:99] at_unified_cb(): at_unified evt: 4

[E][WiFiGeneric.cpp:477] mode(): Could not set mode! -1
scan done
-2 networks found

scan start
scan done
-1 networks found

Arduino libraries:
Adafruit_BusIO/
Adafruit_Circuit_Playground/
Adafruit_DMA_neopixel_library/
Adafruit_GFX_Library/
Adafruit_NeoMatrix_ZeroDMA_library/
Adafruit_NeoPixel/
Adafruit_Zero_DMA_Library/
esp-at-lib-develop/
readme.txt
Seeed_Arduino_atUnified-master/
Seeed_Arduino_atWiFiClientSecure-master/
Seeed_Arduino_atWiFi-master/
Seeed_Arduino_FreeRTOS-master/
Seeed_Arduino_LCD-master/
Seeed_Arduino_mbedtls-master/
Seeed_Arduino_RTC-master/
Seeed_Arduino_SFUD-master/
Servo/

Regards

Stuart.
Had WIO Terminal for a Week… Looks really good :slight_smile:

I think you didn’t upgrade the wifi firmware

Hello, I’m having same issue.

Device reset sequence finished!
Cannot initialize ESP-AT Lib!

I follow both procedures to upgrade firmware (UF2 and ambd_flash_tool.py2) but firmware upgrade does not work…

Using the UF2 procedure show in screen the message " Burn RTL8720 fw" but don’t finish (at least I can’t see any message indicating that).

Using the ambd_flash_tool.py procedure it returns:
image

Do you have any suggest.

try it with the win powershell… worked for me

Thanks Borroz. I tryed and same result .

image

Take note, after erase allways receive Error! and you receive done!!

@pacocuervo you need to enter the UART Download mode before flashing . to enter the UART Download mode . you need to sliding the power switch twice quickly . For more reference, please also see here.

Many thanks… after many many tryes I got succes on programming firmware!!! really I don’t know what was the condition but from now I can update the firmware and if I repeat the procedure, no problem. I can update the firmware without problem…

But now If I program with the next skecth:

#include “AtWiFi.h”

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

// Set WiFi to station mode and disconnect from an AP if it was previously connected
WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(100);

Serial.println("Setup done");

}

… I continue having same result.

Device reset sequence finished!
Cannot initialize ESP-AT Lib!
[E][esp_event_loop.c:99] at_unified_cb(): at_unified evt: 4

[E][WiFiGeneric.cpp:477] mode(): Could not set mode! -1
[E][esp_event_loop.c:99] at_unified_cb(): at_unified evt: 4

Really, I’m very angry. :frowning_face: I was thinking to use wio in my projects (first purchase to start testing) and as I can see is not very reliable.

no need to get VERY angry :sunglasses:

read this topic