This library is the generic WiFi library for any Arduino and Arduino-compatible board. It is a thin wrapper around the various platform-specific WiFi implementations that allows you to include just "WiFi.h" in your sketch without worrying about the exact WiFi library to include for each specific platform. With this approach you don't need to write conditional inclusions yourself, as this library will take care of that.
Using this library in sketches and other libraries is the recommended way to use WiFi as it ensures the maximum code portability.
This library imports the the right library automatically:
| Boards | Underlying library |
|---|---|
| NINA-based boards (MKR WiFi 1010, Nano 33 IoT, Nano RP2040 Connect etc.) |
WiFiNINA |
| Portenta boards | MBed/WiFi |
| ESP8266 boards | ESP8266WiFi |
| ESP32 boards | ESP32/WiFi |
See the examples shipped with such libraries to learn more about using WiFi functionality. These WiFi implementations share most of their API, so good chances are your sketch or library will be truly platform-agnostic.
(If you're looking for the library to use for the retired Arduino WiFi Shield, it's now called WiFiShield.)
#include <WiFi.h>
void setup() {
WiFi.begin("your-ssid", "your-password");
}