logo elektroda
logo elektroda
X
logo elektroda

ESP07 Slow WiFi Connection After forceSleepBegin Usage

Dawidixxx 1686 21
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 18850432
    Dawidixxx
    Level 7  
    Hello

    After applying
    Code: C / C++
    Log in, to see the code
    .
    And
    Code: C / C++
    Log in, to see the code


    Esp 07 takes about 4 times as long to connect, after 3 seconds the printy slows down as if it is trying to connect and only then after 10-15 does the connection happen (or sometimes even longer). I did a delay(1000) after forceSleepWake to be sure, but it did nothing.
    Without using the function everything is ok, but I'd like to use this because the esp is battery powered and goes to sleep.
    Maybe I have forgotten something?
    Please help and best regards
  • ADVERTISEMENT
  • Helpful post
    #2 18850617
    Anonymous
    Level 1  
  • ADVERTISEMENT
  • #3 18850689
    Dawidixxx
    Level 7  
    Thank you for your reply
    I did a quick check and am writing back because I have to go somewhere and yes there is an improvement :)
    I still wanted to check

    void preinit() {
    ESP8266WiFiClass::preinitWiFiOff();
    }

    But on esp version 2.4.2 it was not detecting the function
    So I upgraded to the latest version 2.7 and the web server stopped working for me without a compile error,
    so I quickly backtracked to 2.5 to check, I need to read why I had a problem during handleRoot

    As for WIFI_OFF
    I would have to verify but I think it executes as a parameter of WiFi.disconnect(true);

    Thanks again and regards :) .
  • Helpful post
    #4 18850839
    Anonymous
    Level 1  
  • #5 18851121
    Dawidixxx
    Level 7  
    Thank you for such commitment :) It would be nice to improve the code to a higher version
    After decoding on version 2.7.3 I got this information, just don't know where to start here

    
    Exception 3: LoadStoreError: Processor internal physical address or data error during load or store
    PC: 0x4000bf64
    EXCVADDR: 0x40245bd9
    
    Decoding stack results
    0x4020cbdb: _malloc_r(_reent*, size_t) at C:\Users\dawid\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.3\cores\esp8266\heap.cpp line 125
    0x4020247e: std::function ::function    (SmartRegister*)>, void>(std::_Bind   (SmartRegister*)>) at c:\users\dawid\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506\xtensa-lx106-elf\include\c++\4.8.2/functional line 1987
    0x40100c67: umm_free_heap_size_lw() at C:\Users\dawid\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.3\cores\esp8266\umm_malloc/umm_local.c line 171
    0x40202038: SmartRegister::SmartRegister(int, String) at C:\Users\dawid\AppData\Local\Temp\arduino_build_753988\sketch\SmartRegister.cpp line 19
    0x4020c9fc: __pinMode(uint8_t, uint8_t) at C:\Users\dawid\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.3\cores\esp8266\core_esp8266_wiring_digital.cpp line 55
    0x40202a08: esp8266webserver::ESP8266WebServerTemplate ::responseCodeToString(int) at C:\Users\dawid\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.3\libraries\ESP8266WebServer\src/ESP8266WebServer-impl.h line 717
    0x40204932: SmartRegister::ssidFromWeb() at C:\Users\dawid\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.3\libraries\ESP8266WebServer\src/ESP8266WebServer.h line 134
    0x40202a08: esp8266webserver::ESP8266WebServerTemplate ::responseCodeToString(int) at C:\Users\dawid\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.3\libraries\ESP8266WebServer\src/ESP8266WebServer-impl.h line 717
    0x4020e9e4: Print::write(char) at C:\Users\dawid\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.3\cores\esp8266/Print.h line 75
    0x4020ea27: String::wbuffer() const at C:\Users\dawid\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.3\cores\esp8266/WString.h line 309
    0x401000e1: std::function ::operator()() const at c:\users\dawid\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506\xtensa-lx106-elf\include\c++\4.8.2/functional line 2465
    0x40202a40: esp8266webserver::ESP8266WebServerTemplate ::responseCodeToString(int) at C:\Users\dawid\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.3\libraries\ESP8266WebServer\src/ESP8266WebServer-impl.h line 717
    0x40204526: SmartRegister::begin() at C:\Users\dawid\AppData\Local\Temp\arduino_build_753988\sketch\SmartRegister.cpp line 36
    0x40100400: Twi::onTwipEvent(unsigned char) at C:\Users\dawid\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.3\cores\esp8266\core_esp8266_si2c.cpp line 572
    0x4020463f: SmartRegister::begin() at C:\Users\dawid\AppData\Local\Temp\arduino_build_753988\sketch\SmartRegister.cpp line 54
    0x40209ef6: Print::print(String const&) at C:\Users\dawid\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.3\cores\esp8266/Print.h line 65
    0x4020490e: SmartRegister::ssidFromWeb() at C:\Users\dawid\AppData\Local\Temp\arduino_build_753988\sketch\SmartRegister.cpp line 140
    0x4020f278: read_encoded_value_with_base at /workdir/repo/gcc/libgcc/unwind-pe.h line 207
    0x40201fb4: SmartRegister::SmartRegister(int, String) at C:\Users\dawid\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.3\libraries\ESP8266WebServer\src/ESP8266WebServer-impl.h line 85
    0x4020ea08: String::setLen(int) at C:\Users\dawid\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.3\cores\esp8266/WString.h line 304
    0x40204ee8: ESP8266WiFiAPClass::softAPConfig(IPAddress, IPAddress, IPAddress) at C:\Users\dawid\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.3\libraries\ESP8266WiFi\src\ESP8266WiFiAP.cpp line 263
    0x4020f1a8: frame_heapsort at /workdir/repo/gcc/libgcc/unwind-dw2-fde.c line 546
    0x40209fd0: Print::printNumber(unsigned long, unsigned char) at C:\Users\dawid\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.3\cores\esp8266\Print.cpp line 250
    0x40100f21: calloc(size_t, size_t) at C:\Users\dawid\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.3\cores\esp8266\umm_malloc\umm_malloc.cpp line 908
    

    https://imgur.com/6dW1uJF
  • #6 18851154
    Anonymous
    Level 1  
  • #7 18851174
    Dawidixxx
    Level 7  
    SmartRegister is a class responsible for starting a web server with a page that allows you to connect to your own WiFi network
    called when the device does not have a flag stored in EEPROM that it has been configured

    There must be something wrong here, because the /connect link and the method in which the server already provides the login and password is called
    while by default it should redirect to /, i.e. the home page
    I am adding images so that you can see the lines

    https://imgur.com/dvFycNg
    (host not in use, some leftover test code)

    the main handleRoot page calls this method

    https://imgur.com/eH5W97k

    The pages are saved in separate files as

    const char indexBegin[] PROGMEM = R"=====(
    <!DOCTYPE html>
    ...

    String s = constructHTMLpage();
    _server->send(200, "text/html", s);
    I read that there might be a problem here
    the error is triggered after connecting to the wifi of the device and typing/refreshing any page
  • Helpful post
    #8 18851541
    Anonymous
    Level 1  
  • #9 18852280
    Dawidixxx
    Level 7  
    I managed to improve the code, for future reference (in my case when moving from version 2.4.2 to 2.7.4) using
    Code: C / C++
    Log in, to see the code

    at
    Code: C / C++
    Log in, to see the code
    .
    conversion needed
    Code: C / C++
    Log in, to see the code

    than
    Code: VB.net
    Log in, to see the code
    .
    As for the code, I still need to optimise it as the constants need 36% of the memory, thank you for your advice :) .
  • #10 18852309
    Anonymous
    Level 1  
  • #11 18852341
    Dawidixxx
    Level 7  
    Hmm constexpr, heh until now I knew either #define or const, I need to read ;) .
    To be honest, I don't really know what could be eating up the memory here, the largest parts of the page are stored as PROGMEM
    It could be improved, for example, to send the page piece by piece rather than from one big String
  • ADVERTISEMENT
  • #12 18852348
    Anonymous
    Level 1  
  • ADVERTISEMENT
  • #14 18852461
    Anonymous
    Level 1  
  • #15 18852549
    Dawidixxx
    Level 7  
    Dynamic array depending on the number of detected WiFi networks :) .
    But there is probably a more efficient way with little memory, vectors are rather out of the question
  • #16 18852589
    Anonymous
    Level 1  
  • #17 18852756
    Dawidixxx
    Level 7  
    A silly error of non-thought indeed.

    As for the example in post #8 I don't think I can do that, I need some fixed array size even if inflated to be given in that form.
    I still have a question for ESP.getFreeHeap() which I need to start using and get interested in memory. Does this function return the remaining available memory for the stack and heap?
    From what I have read it is common - static elements, and here we have FreeHeap
  • #18 18852812
    Anonymous
    Level 1  
  • #19 18852986
    Dawidixxx
    Level 7  
    When returning 0 the loops do not execute but the page builds. Already on a static array.
    mate is impossible :D a veritable compiler

    I still have a question because I am now testing the connection on the AP from my laptop and the time is constant
    - with the WiFi module turned off at startup,
    - with on,
    - delay(100) and without,
    - Surprisingly forceSleepBegin without Wake

    with DHCP always comes out 6 seconds
    When I get a chance, I need to check the power consumption

    I am using an ESP07 module with a small antenna (on ali sometimes included) however I have not disconnected the ceramic antenna, can they interfere? (I also tested the connection on a clean project). The long wait time from the home AP was probably due to the router itself.
  • #20 18853246
    Anonymous
    Level 1  
  • #21 18854031
    Dawidixxx
    Level 7  
    I haven't yet tested the option with a fixed IP on both the AP and ESP side, I wanted to get a good feel for the dynamic connection :) first.
    I understand that I will get the best result by setting a fixed IP on both sides rather than just one?
  • #22 18854092
    Anonymous
    Level 1  

Topic summary

The discussion revolves around the slow WiFi connection issue experienced with the ESP07 module after using the `forceSleepBegin()` and `forceSleepWake()` functions. The user noted that the connection time increased significantly, taking up to 10-15 seconds to connect, compared to normal operation. Suggestions included adding delays after the sleep functions to improve connection times and clarifying the difference between `WiFi.mode(WIFI_OFF)` and `WiFi.disconnect()`. The user also encountered compilation issues when upgrading the ESP8266 library version, which were resolved by reverting to an earlier version. Further discussions included optimizing memory usage, handling heap overflow, and improving code efficiency. The importance of using fixed IP addresses and the potential interference from antennas were also mentioned.
Summary generated by the language model.
ADVERTISEMENT