Sub topic 13
Troubleshooting Connection Problems
This chapter assumes you can write and upload an Arduino sketch, use the Serial Monitor, install board libraries, and identify your network's SSID, password, and IP address. The examples use a WiFiNINA board such as the MKR WiFi 1010 or Nano 33 IoT.
A connection failure has a location. The board may fail to detect its Wi-Fi module, join the access point, receive an IP address, find a host name, open a TCP connection, or complete TLS. Test these stages in order instead of changing several parts at once.
Start with the board and library
Confirm that the selected board matches the hardware. A WiFiNINA board normally uses:
#include <WiFiNINA.h>Other Arduino boards may use a different library, such as WiFiS3 or WiFi101. The wrong library can produce compile errors or make the sketch wait forever.
The WiFiNINA library can report whether it sees the module and which firmware it uses:
#include <WiFiNINA.h>
void setup() {
Serial.begin(115200);
while (!Serial && millis() < 5000) {}
Serial.print("Firmware: ");
Serial.println(WiFi.firmwareVersion());
if (WiFi.status() == WL_NO_MODULE) {
Serial.println("Wi-Fi module not found");
while (true) {}
}
Serial.println("Wi-Fi module detected");
}
void loop() {}If the module is missing, check the USB cable, board selection, power, and physical connections. If the firmware is old or incompatible, update it with the WiFiNINA firmware updater in the Arduino IDE. Record the result before continuing.
Check association and DHCP
Association means that the board has joined the wireless network. DHCP, or Dynamic Host Configuration Protocol, gives the board an IP address.
Common causes of failure include:
- The network is 5 GHz only. Many Arduino Wi-Fi boards require 2.4 GHz.
- The SSID or password contains a typo.
- The access point uses an unsupported security mode.
- The signal is too weak or the board is too far away.
- A guest network blocks new devices or client-to-client traffic.
Print the status during connection attempts. Do not retry in a tight loop because this can overload the access point and hide the original problem.
#include <WiFiNINA.h>
#include "arduino_secrets.h"
void setup() {
Serial.begin(115200);
while (!Serial && millis() < 5000) {}
int status = WL_IDLE_STATUS;
for (int attempt = 1; attempt <= 6 && status != WL_CONNECTED; attempt++) {
Serial.print("Attempt ");
Serial.println(attempt);
status = WiFi.begin(SECRET_SSID, SECRET_PASS);
delay(5000);
}
if (status != WL_CONNECTED) {
Serial.print("Wi-Fi failed, status: ");
Serial.println(status);
return;
}
Serial.print("IP: ");
Serial.println(WiFi.localIP());
Serial.print("RSSI: ");
Serial.println(WiFi.RSSI());
}
void loop() {}An RSSI value is received signal strength in decibels relative to one milliwatt. Values closer to zero are stronger. A value around -80 dBm or lower often indicates an unreliable connection, although walls and interference also matter.
Separate DNS, TCP, and TLS failures
If the board has an IP address, test the next layer separately. DNS translates a host name such as example.com into an IP address. A failed name lookup can look like an internet failure even when Wi-Fi works.
Try a known host and then its numeric address, if available. If the numeric address works but the name does not, investigate DNS or the router. If both fail, check routing, firewall rules, and the server port.
HTTPS adds TLS, which authenticates the server and encrypts traffic. A TLS connection may fail when the Wi-Fi module's root certificate store lacks the required certificate, the certificate is expired, or the board's clock is wrong. Update the module's certificate store with the firmware updater. Avoid disabling certificate validation in a deployed device.
Use evidence, not guesses
Record the exact Serial Monitor output, board model, library version, firmware version, network band, and destination host. These details distinguish a credential error from a server error.
A server that closes a connection after accepting it may be rejecting the HTTP request, requiring authentication, or enforcing HTTPS. At that point, Wi-Fi troubleshooting is complete. Inspect the response status line and headers.
Exercise
The board prints a valid IP address, but client.connect("example.com", 80) fails. Which layers should you test next?
Show answer
Test DNS resolution, then TCP access to port 80, and finally the server or firewall. Wi-Fi association and DHCP have already succeeded.