Moin Ich hatte mal ein Skript (Arduino IDE) gesehen, welches es zunächst den ESP einen AP zu öffnen, auf dessen Webseite dann SSID und Passwort für ein bestehendes WLAN eingetragen werden konnten und anschließend sich mit eben diesem Netzwerk verbindet. Leider finde ich es weder in meinen Bookmarks noch über Google. Wonach genau muss ich suchen?
Hier ein Beispiel aus dem ESP32-Webradio von Ed Smallenburg
1 | //************************************************************************************************** |
2 | // C O N N E C T W I F I * |
3 | //************************************************************************************************** |
4 | // Connect to WiFi using the SSID's available in wifiMulti. * |
5 | // If only one AP if found in preferences (i.e. wifi_00) the connection is made without * |
6 | // using wifiMulti. * |
7 | // If connection fails, an AP is created and the function returns false. * |
8 | //************************************************************************************************** |
9 | bool connectwifi() |
10 | { |
11 | char* pfs ; // Pointer to formatted string |
12 | char* pfs2 ; // Pointer to formatted string |
13 | bool localAP = false ; // True if only local AP is left |
14 | |
15 | WifiInfo_t winfo ; // Entry from wifilist |
16 | |
17 | WiFi.disconnect() ; // After restart the router could |
18 | WiFi.softAPdisconnect(true) ; // still keep the old connection |
19 | if ( wifilist.size() ) // Any AP defined? |
20 | { |
21 | if ( wifilist.size() == 1 ) // Just one AP defined in preferences? |
22 | { |
23 | winfo = wifilist[0] ; // Get this entry |
24 | WiFi.begin ( winfo.ssid, winfo.passphrase ) ; // Connect to single SSID found in wifi_xx |
25 | dbgprint ( "Try WiFi %s", winfo.ssid ) ; // Message to show during WiFi connect |
26 | } |
27 | else // More AP to try |
28 | { |
29 | wifiMulti.run() ; // Connect to best network |
30 | } |
31 | if ( WiFi.waitForConnectResult() != WL_CONNECTED ) // Try to connect |
32 | { |
33 | localAP = true ; // Error, setup own AP |
34 | } |
35 | } |
36 | else |
37 | { |
38 | localAP = true ; // Not even a single AP defined |
39 | } |
40 | if ( localAP ) // Must setup local AP? |
41 | { |
42 | dbgprint ( "WiFi Failed! Trying to setup AP with name %s and password %s.", NAME, NAME ) ; |
43 | WiFi.softAP ( NAME, NAME ) ; // This ESP will be an AP |
44 | pfs = dbgprint ( "IP = 192.168.4.1" ) ; // Address for AP |
45 | } |
46 | else |
47 | { |
48 | ipaddress = WiFi.localIP().toString() ; // Form IP address |
49 | pfs2 = dbgprint ( "Connected to %s", WiFi.SSID().c_str() ) ; |
50 | tftlog ( pfs2 ) ; |
51 | pfs = dbgprint ( "IP = %s", ipaddress.c_str() ) ; // String to dispay on TFT |
52 | } |
53 | tftlog ( pfs ) ; // Show IP |
54 | delay ( 3000 ) ; // Allow user to read this |
55 | return ( localAP == false ) ; // Return result of connection |
56 | } |
Harry L. schrieb: > "WiFiManager" https://github.com/tzapu/WiFiManager/wiki/Examples Sehr schön, vielen Dank Harry :-)
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.