Chat freely about anything...

User avatar
By Tawhiz20
#52909 I am a huge fan of PlatformIO but I recently am strugling with a Wifi-connection-problem which does not occur when I use the Arduino IDE (with the EXACT same code)...

I used PlatformIO a lot but had some problems with Atom-updates so installed all of it new.
Revisiting some old code I got into a problem with my ESP-modules not connecting to my Wifi after updating the firmware.

When I write a super-simple program (just to connect to my Wifi) and burn it on my ESP with the Arduino-IDE it connects in 0,5 seconds.. when I use the EXACT same program in PlatformIO (copy-paste) it does not connect (only sometimes after a hardware reset).

All my platformio modules and boards are up to date (IDE 1.4.0).. is this SDK related? (maybe my arduino IDE 1.6.9 uses an older version?)

Does anyone recognise this problem? (or better solved it?)

THNX
User avatar
By Tawhiz20
#52990 [SOLVED] Found it!.. it was an improvement in the library..
my Arduino IDE used the old one.. PlatformIO the new one (and made a problem)
Because of the improved re-connect in the library my "WiFi.begin" was now in the wrong place...
first test if not already connected... if not THEN WiFi.begin...

Code: Select all      void setupWifi() {
        Serial.begin(115200);
        delay(2000);
        Serial.println("Booting...---");
        WiFi.mode(WIFI_STA);
        int teltje = 0;
        pinMode(pinLed, OUTPUT);     // Initialize the BUILTIN_LED pin as an output
        while (WiFi.status()!= WL_CONNECTED) {
          delay(250);
          digitalWrite(pinLed, HIGH);   
          delay(250);
          digitalWrite(pinLed, LOW);   
          if (teltje==0) {
            WiFi.begin(ssid, password); // only do WiFi.begin if not already connected
          }
          teltje++;
          Serial.print(".");
          if (teltje>20) {
            Serial.println("Connection Failed! Rebooting...");
            delay(500);
            ESP.restart();
          }
        }
        Serial.println("Ready");
        Serial.print("IP address: ");
        Serial.println(WiFi.localIP());
      }