Problems connecting to wifi ap

Posted on
  • I'm running the 1v99 release on an AI-Thinker ESP-12Q module (4MB flash), trying to connect to a Linksys EA7500 running firmware 2.0.6.190009.
    My problem is the Wifi.connect fails with 'bad password' 90% of the time. When I do connect, I don't remember the magic combination of resets, reconnects, and reloads I had to do to make it work (and it may not matter anyway). On a 1-year old thread someone posted that continual retries worked for them, I found that it would fail 9 times then hang on connect()
    Example program attached.
    Thanks in advance!


    1 Attachment

  • I'd always put retry invocations to and/or within self into a setTimeout() in order to 'loose' context... and let resources go... yes, it may be in a callback, but still, code-connected things/references keep things a-life and resources blocked...

  • Thanks, I'll give that a try

  • I had problems with one of my router so I did this feature:

      var boola;
      function lan() {
        wlan.connect(logon.ssid, {password: logon.pass}, function (s) {
          boola = true;
          if(s==='bad password') {
            if(debug)console.log('restart lan');
            lan();
          }
        });
    
        if(debug)console.log("Frida is my watchdog");
        if(debug)console.log(wlan.getIP().ip);
      } // end lan()
      setTimeout(lan,400);
    
    
      wlan.on('connected', function(s) {
        if(debug)console.log('Starter test', wlan.getIP().ip);
        if(boola) {
          boola = false;
          startTimeServer();
          if(debug)console.log('tilsluttet lan');
        }
      });
    
    
  • How are you loading code onto the board?

    You seem to adding modules at run time loadModule('MQTT');'

    If you use the web ide that is not necessary- and if connect with wifi and wifi.save() it will automatically reconnect when the board is powered up.

  • Yeah, I forgot that Javascript functions are closures, so even with the async callback it's still a recursive function :-/ @Frida's setTimeout, but as a setInterval, to keep retrying until boola gets set instead of invoking lan from the connect callback (same problem IIUC, please explain if I don't!), and also letting the webide load MQTT for me (I originally was using telnet directly).

  • There must be something with my router that doesn't get along with the ESP. I even tried putting E.reboot() in the failure path and that didn't work either :-(

  • Did you try with other routers, and or using a mobile phone in "Mobile Hotspot" mode? This way you could get a hint wether the problem was with the ESP module or the router.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Problems connecting to wifi ap

Posted by Avatar for rmd6502 @rmd6502

Actions