Editing
esp
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===WiFi(ESP8266WiFi library)=== This is mostly similar to WiFi shield library. Differences include:<br> :'''WiFi.mode(m)''' ::set mode to WIFI_AP, WIFI_STA, WIFI_AP_STA or WIFI_OFF. :'''call WiFi.softAP(ssid)''' ::to set up an open network. :'''call WiFi.softAP(ssid, password)''' ::to set up a WPA2-PSK network (password should be at least 8 characters) :'''WiFi.macAddress(mac)''' ::is for STA, WiFi.softAPmacAddress(mac) is for AP. :'''WiFi.localIP()''' ::is for STA, '''WiFi.softAPIP()''' is for AP. :'''WiFi.printDiag(Serial)''' ::will print out some diagnostic info :'''WiFiUDP class''' ::supports sending and receiving multicast packets on STA interface. When sending a multicast packet, replace udp.beginPacket(addr, port) with udp.beginPacketMulticast(addr, port, WiFi.localIP()). When listening to multicast packets, replace udp.begin(port) with udp.beginMulticast(WiFi.localIP(), multicast_ip_addr, port). You can use udp.destinationIP() to tell whether the packet received was sent to the multicast or unicast address. <br> :WiFiServer, WiFiClient, and WiFiUDP behave mostly the same way as with WiFi shield library. Four samples are provided for this library. <br> You can see more commands [http://www.arduino.cc/en/Reference/WiFi here]. <br> ====WL_DEFINITIONS==== :WL_IDLE_STATUS = 0, :WL_NO_SSID_AVAIL = 1, :WL_SCAN_COMPLETED = 2, :WL_CONNECTED = 3, :WL_CONNECT_FAILED = 4, :WL_CONNECTION_LOST = 5, :WL_WRONG_PASSWORD = 6, :WL_DISCONNECTED = 7 {{template:top}} ====Function to print the wifi.status==== <nowiki>const char* wl_status_to_string(wl_status_t status) { switch (status) { case WL_IDLE_STATUS: return "WL_IDLE_STATUS"; case WL_NO_SSID_AVAIL: return "WL_NO_SSID_AVAIL"; case WL_SCAN_COMPLETED: return "WL_SCAN_COMPLETED"; case WL_CONNECTED: return "WL_CONNECTED"; case WL_CONNECT_FAILED: return "WL_CONNECT_FAILED"; case WL_CONNECTION_LOST: return "WL_CONNECTION_LOST"; case WL_DISCONNECTED: return "WL_DISCONNECTED"; } } Serial.println(wl_status_to_string(WiFi.status()));</nowiki> {{template:toponly}} =====WiFi.status()===== The status function in the WiFi class, doesn’t take any arguments but it returns stuff depending on the status of the network that you’re connected to. ;The WiFi.status function returns a value:<br> {| class="wikitable" ! style="font-weight:bold;" | Code ! style="text-align: center; font-weight:bold;" | Vulue ! style="font-weight:bold;" | Meaning |- | WL_IDLE_STATUS | style="text-align: center;" | 0 | WiFi is in process of changing between statuses |- | WL_NO_SSID_AVAIL | style="text-align: center;" | 1 | SSID cannot be reached |- | WL_SCAN_COMPLETED | style="text-align: center;" | 2 | |- | WL_CONNECTED | style="text-align: center;" | 3 | Successful connection is established |- | WL_CONNECT_FAILED | style="text-align: center;" | 4 | Password is incorrect |- | WL_CONNECTION_LOST | style="text-align: center;" | 5 | |- | WL_CONNECT_WRONG_PASSWORD | style="text-align: center;" | 6 | Password is incorrect | |- | WL_DISCONNECTED | style="text-align: center;" | 7 | not configured in station mode |} If you get code 1, WL_NO_SSID_AVAIL, try adding this before WiFi.begin(): WiFi.enableInsecureWEP(); <br> It is recommended by some to set the mode to STA: WiFi.mode(WIFI_AP_STA); WiFi.begin(); {{template:top}}
Summary:
Please note that all contributions to Notebook may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Notebook:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Home Page
C++ Reference
ESP Hardware
ESPHome
Home Assistant
Network Stuff
Tools
What links here
Related changes
Special pages
Page information