1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-30 16:24:09 +03:00

Cleaned up wifi library examples

moved old examples to libraries/Wifi/examples/old_examples, to finish
later.  Added five new examples which work in 1.0 beta4
This commit is contained in:
Tom Igoe
2011-09-16 21:12:38 -04:00
parent c518f50035
commit 301c1d71d8
20 changed files with 573 additions and 0 deletions

View File

@ -0,0 +1,50 @@
/*
Open connection using the WiFi shield. Attempts to connect
and prints out the signal strength.
Circuit:
* WiFi shield attached
created 5 June 2011
by Tom Igoe
*/
#include <SPI.h>
#include <WiFi.h>
char ssid[] = "yourNetwork"; // the name of your network
int status = WL_IDLE_STATUS; // the Wifi radio's status
byte mac[6]; // the MAC address of your Wifi shield
IPAddress ip; // the IP address of your shield
void setup() {
// initialize serial:
Serial.begin(9600);
// attempt to connect using WEP encryption:
Serial.println("Attempting to connect to open network...");
status = WiFi.begin(ssid);
Serial.print("SSID: ");
Serial.println(ssid);
// if you're not connected, stop here:
if ( status != WL_CONNECTED) {
Serial.println("Couldn't get a wifi connection");
while(true);
}
}
void loop() {
// if you're connected, print out the signal strength:
if ( status != WL_CONNECTED) {
// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("RSSI:");
Serial.println(rssi);
delay(250);
}
}