G. WiFi
The last few chapters were all about built-in functions of the Arduino/ESP8266 platform. Now
we will start using libraries which are part of the platform and are already installed. So how
can we use the WiFi module of the ESP8266? First of all you need to know that the ESP8266
can operate as a WiFi client (like a smartphone or laptop) and/or as an access point (like a
WiFi router or extender). You can set this mode with:
WiFi.mode(m);
where m must be one of the following modes:
WIFI_AP (access
point),
WIFI_STA
(client),
WIFI_AP_STA(AP and client)
or WIFI_OFF.
Now let's connect to your access point:
WiFi.begin(WIFI_SSID, WIFI_PWD);
This will connect you to an access point given its SSID and the password. Please note that this
call is not blocking. This means that the code will immediately proceed to the next instruction
whether the ESP successfully connects to the access point or not.
Need help?
Do you have a question about the ESP8266 and is the answer not in the manual?