-->
Page 1 of 1

Connection to WiFi network without password

PostPosted: Tue Feb 14, 2017 4:13 am
by Peter1234
In the code always the network ID and password is required. If this changes all hardware projects have to updated.
Is it possible to connect ESP via pressing the access point button instead of using a password in the code?

Thanks
Peter

Re: Connection to WiFi network without password

PostPosted: Thu Feb 16, 2017 9:18 am
by Affix
Hey Peter,

You could make use of the Native SDK WPS Features (Arduino also Has WiFi.WPS)


NativeSDK

Enable WPS Push Button Connect with

Code: Select allwifi_wps_enable(WPS_TYPE_PBC);


WPS Register Callback
Code: Select allwifi_set_wps_cb(wps_callback());


Start WPS

Code: Select allwifi_wps_start();


Make sure you write a callback function to do what you need

Arduino

Code: Select all#include <ESP8266WiFi.h>

void setup() {
  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  WiFi.begin("","");
  // Check if WiFi is already connected and if not, begin the WPS process.
  if (WiFi.status() != WL_CONNECTED) {
      Serial.println("\nAttempting connection ...");
      WiFi.beginWPSConfig();

      do {
        Serial.print(".");
      } while (WiFi.status != WL_CONNECTED)

      if (WiFi.status() == WL_CONNECTED) {
        Serial.println("Connected!");
        Serial.println(WiFi.localIP());
        Serial.println(WiFi.SSID());
        Serial.println(WiFi.macAddress());
      }
  }
  else {
    Serial.println("\nConnection already established.");
  }
}

Re: Connection to WiFi network without password

PostPosted: Tue Apr 25, 2017 1:25 am
by Peter1234
Thank you, it works.
Only needed to correct two typos:

Code: Select alldo {
      Serial.print(".");
    } while (WiFi.status() != WL_CONNECTED);