So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By Peter1234
#62547 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
User avatar
By Affix
#62640 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.");
  }
}