Open rudi48 opened 7 years ago
Looks promising. Going to combine it with a pir sensor (hc-sr501) on GPIO0. My first calculations suggest that this should work without any extra components: PIR has 1k resistance in series with output, ESP8266 can drive 12 mA.
@rudi48 thank you for this sketch, it seems there is still no example in the repo. Could you please test with latest git, and make a PR? I think it would be appropriate to add it next to the WiFiTelnetToSerial example.
@devyte It is my pleasure that you like it. Unfortunately at the moment I have to do other things. You are invited to do that.
@rudi48 I can't test it, no WPS. Also, right now I'm focusing on a major cleanup effort of all open issues. No need to do it right now. I'll keep the issue open for the time being, but I would appreciate it if you could retest and make a PR when you get some free time.
Another example to test, from #1958 .
#include <ESP8266WiFi.h>
void setup() {
Serial.begin(115200);
Serial.println("\nPress WPS button on your router ...");
delay(5000);
startWPSPBC();
}
bool startWPSPBC() {
Serial.println("WPS config start");
// WPS works in STA (Station mode) only -> not working in WIFI_AP_STA !!!
WiFi.mode(WIFI_STA);
delay(1000);
WiFi.begin("foobar",""); // make a failed connection
while (WiFi.status() == WL_DISCONNECTED) {
delay(500);
Serial.print(".");
}
bool wpsSuccess = WiFi.beginWPSConfig();
if(wpsSuccess) {
// Well this means not always success :-/ in case of a timeout we have an empty ssid
String newSSID = WiFi.SSID();
if(newSSID.length() > 0) {
// WPSConfig has already connected in STA mode successfully to the new station.
Serial.printf("WPS finished. Connected successfull to SSID '%s'", newSSID.c_str());
// save to config and use next time or just use - WiFi.begin(WiFi.SSID().c_str(),WiFi.psk().c_str());
//qConfig.wifiSSID = newSSID;
//qConfig.wifiPWD = WiFi.psk();
//saveConfig();
} else {
wpsSuccess = false;
}
}
return wpsSuccess;
}
void loop() {
// put your main code here, to run repeatedly:
}
a doubt if I click to connect on the esp8266 and the router, or (on the router and esp8266) if the power goes out. when does the power return the esp and the router will connect automatically or will it have to click the two again ??
If I can help, I will be very pleased.
@ diegoss3337 Do NOT power down the router. Just push the WLAN/WPS button. First the router, then the ESP8266. Regards, Rudolf
holy shit this is cool
I did'nt get this to work with core 2.5. On 2.4.1 it works without problems. Does anybody else have problems with wps on 2.5?
Basic Infos
Hardware
Hardware: ESP-01 Core Version: ?2.1.0-rc2?
Description
I did not found any working example for WPS (WiFi Protected Setup) via push button switch. So I put some pieces together, with the example WiFiTelnetToSerial.
The software is hosted at WiFiTelnetToSerialWPS
Usage
If you power up the ESP8266 module, and the red LED (WPS indicator) lits (ON), it signals, that the WiFi module has lost the connection to the known Access Point, or the credentials of the Access Point had changed.
In case of changed credentials, it is possible to connect to the Access Point via WPS. The procedure is:
Settings in IDE
Module: Generic ESP8266 Module Flash Size: 512K CPU Frequency: 80Mhz Flash Mode: DIO Flash Frequency: 40Mhz Upload Using: SERIAL Reset Method: ck
Sketch