char ssid[] = "myNetwork"; // your network SSID (name) char pass[] = "myPassword"; // your network password
int status = WL_IDLE_STATUS;
IPAddress server(74,125,115,105); // Google
// Initialize the client library WiFiClient client;
void setup() {
Serial.begin(9600);
Serial.println("Attempting to connect to WPA network...");
Serial.print("SSID: ");
Serial.println(ssid);
status = WiFi.begin(ssid, pass);
if ( status != WL_CONNECTED) {
Serial.println("Couldn't get a wifi connection"); // don't do anything else: while(true);
}
else {
Serial.println("Connected to wifi");
Serial.println("\nStarting connection..."); // if you get a connection, report back via serial: if (client.connect(server, 80)) {
Serial.println("connected"); // Make a HTTP request: client.println("GET /search?q=arduino HTTP/1.0");
client.println();
}
}
}
#include <SPI.h>
#include <WiFi.h>
char ssid[] = "Jimmy network"; // your network SSID (name)
char pass[] = "123456"; // your network password
int status = WL_IDLE_STATUS;
IPAddress server(74,125,115,105); // Google
// Initialize the client library
WiFiClient client;
void setup() {
Serial.begin(9600);
Serial.println("Attempting to connect to WPA network...");
Serial.print("SSID: ");
Serial.println(ssid);
status = WiFi.begin(ssid, pass);
if ( status != WL_CONNECTED) {
Serial.println("Couldn't get a wifi connection");
// don't do anything else:
while(true);
}
else {
Serial.println("Connected to wifi");
Serial.println("\nStarting connection...");
// if you get a connection, report back via serial:
if (client.connect(server, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET /search?q=arduino HTTP/1.0");
client.println();
}
}
}
void loop() {
}
我用以上的程式
只有出現
Attempting to connect to WPA network...
SSID: Jimmy network
之後便一直沒出現任何訊息
我是有什麼地方出錯?還是wifi shiled壞掉了呢?作者: alibuda174 時間: 2013-2-23 16:48
沒有出現Couldn't get a wifi connection嗎?
其中有一行是status = WiFi.begin(ssid, pass);
根據文件http://arduino.cc/en/Reference/WiFiBegin
WL_CONNECTED when connected to a network連接網路成功
WL_IDLE_STATUS when not connected to a network, but powered on沒有連接網路,但有電源
你執行後,status是哪個呢?作者: hing0530 時間: 2013-2-28 14:25
師兄, 你所說的status在那裡可以看到呢?
因為我在monitor中只看到
Attempting to connect to WPA network...
SSID: Jimmy network