Sub topic 1
Choosing a Wi-Fi Board and Its Library
Prerequisites
You should know how setup(), loop(), and Serial output work in an Arduino sketch. You should also be able to select a board in the Arduino IDE or Arduino CLI and install a library. This chapter assumes you know what an IP address, router, port, and SSID are.
What a Wi-Fi board provides
A Wi-Fi-capable Arduino has a radio that connects to a wireless network. The radio may be built into the main microcontroller, built into a separate module, or provided by an add-on shield.
The board's Wi-Fi hardware needs a matching software library. The library supplies objects and functions for starting Wi-Fi, checking connection state, opening network clients, and running servers. The library is not interchangeable across all Arduino boards.
| Board or family | Typical Wi-Fi hardware | Common library |
|---|---|---|
| MKR WiFi 1010 | u-blox NINA-W102 module | `WiFiNINA` |
| Nano 33 IoT | u-blox NINA-W102 module | `WiFiNINA` |
| UNO R4 WiFi | ESP32-S3 connectivity module | `WiFiS3` |
| Nano ESP32 | ESP32-S3 microcontroller | `WiFi` |
| Ethernet-only boards | Ethernet controller | An Ethernet library, not a Wi-Fi library |
Check the exact board model printed on the board and selected in the IDE. Similar names do not guarantee compatible libraries.
Choosing a board
Choose based on the project requirements, not only on processor speed.
- Use a board with built-in Wi-Fi when you want a compact project with fewer connections.
- Choose a board with a separate connectivity module when the Arduino core and examples match your existing code.
- Check whether the board supports the network band you have. Many small boards support 2.4 GHz networks but not 5 GHz-only networks.
- Check available pins, voltage levels, memory, and power requirements.
- Check whether the library supports the protocols you need, such as HTTPS or MQTT.
- Check whether the board needs module firmware updates in addition to normal sketch uploads.
A board can compile a sketch successfully while its connectivity module has old firmware. Treat the board package, library, and module firmware as separate parts of the system.
Confirming a WiFiNINA installation
For a MKR WiFi 1010 or Nano 33 IoT, install the board package and the WiFiNINA library. Then run a small hardware check before adding application code.
#include <WiFiNINA.h>
void setup() {
Serial.begin(115200);
while (!Serial && millis() < 5000) {
}
if (WiFi.status() == WL_NO_MODULE) {
Serial.println("Wi-Fi module not found");
while (true) {
}
}
Serial.print("Wi-Fi module firmware: ");
Serial.println(WiFi.firmwareVersion());
}
void loop() {
}This sketch does not join a network. It only confirms that the selected library can communicate with the Wi-Fi module. Open Serial Monitor at 115200 baud.
The #include line is the first compatibility test. A missing header usually means the library is not installed or the example uses the wrong library. A WL_NO_MODULE result usually points to an incorrect board selection, a disconnected module, incompatible firmware, or a board that does not use WiFiNINA.
Common selection errors
Do not choose a library because its name contains “WiFi.” Compare the library name in the board's official examples with the board package documentation. Also avoid copying a sketch for one board family to another without changing the include statement and API calls.
Exercise
You have a Nano 33 IoT and a Nano ESP32. Should both sketches normally begin with #include <WiFiNINA.h>? Explain your choice.
Show answer
No. The Nano 33 IoT normally uses WiFiNINA because it has a NINA connectivity module. The Nano ESP32 uses the Wi-Fi library supplied by its ESP32 board package.