Hardware Reference
In-Depth Information
Here's how to scan for available networks:
WiFi Diagnostics
The WiFi shield gives you the ability to make networked
projects wireless, but it also gives you a few other useful
features for diagnosing the health of your connection.
Before you begin a WiFi project, run a few diagnostics to
make sure you have a good connection. Like any wireless
connection, it's invisible, and it's easy to get lost in trouble-
shooting something else when the problem is just that
you're not connected.
// scan for nearby networks:
byte numSsid = WiFi.scanNetworks();
// print the list of networks seen:
Serial.print("SSID List:");
Serial.println(numSsid);
// print the network number and name
// for each network found:
for (int thisNet = 0; thisNet<numSsid; thisNet++) {
Serial.print(thisNet);
Serial.print(") Network: ");
Serial.println(WiFi.SSID(thisNet));
}
No matter what WiFi module you're working with, you're
likely to run into some troubles when trying to connect
your microcontroller. Here are a few common ones to look
out for:
If you're working at a school or business where you don't
control the WiFi routers, make sure you have all the config-
uration information in advance, and that it matches what
your module can do. Enterprise protocols like WPA2 Enter-
prise are not available for microcontroller-based modules.
Here's how to get the signal strength once you're attached
to a network:
// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("RSSI:");
Serial.println(rssi);
Some public networks use a captive portal , which is an
open WiFi network, but you have to sign in through a web
page before you can access the wider Internet. These
are difficult to handle, because you have to program the
microcontroller (not the WiFi module) to make an HTTP
call to the captive portal with the login information first. If
you can use a network that doesn't use a captive portal,
you're better off.
Both of these techniques are handy diagnostic tools.
Depending on your environment and network setup, your
wireless network may not be stable all the time. Likewise,
you may want to wrap your whole main loop() in an if
statement that checks whether you're still connected to
the network, like so:
Some WiFi modules, like the Arduino WiFi shield, can't see
networks where the SSID is hidden. When possible, make
sure your network is publicly visible—even when security
is on.
void loop() {
if ( status == WL_CONNECTED) {
// do everything here
} else {
// let the user know there's no connection
}
}
X
Since you have no interface to get feedback on errors,
compare your configuration with that of your laptop, mobile
phone, or other device that you can connect successfully.
Here are two quick diagnostic code snippets for the
Arduino WiFi shield that may be useful as well: scanning
for available networks, and getting the signal strength of
the network to which you're attached.
 
Search WWH ::




Custom Search