簡體   English   中英

Arduino Wifi Shield沒有通信

[英]Arduino Wifi Shield is not communicating

我的項目是用Android控制的Arduino遙控車。 為此,我買了Arduino Uno R3和Arduino WiFi盾牌 問題是wifiShield沒有監聽客戶端而無法接收數據。 我不知道如何解決問題,也無法在設備之間建立連接。

Arduino代碼:

char ssid[] = "***";         
char pass[] = "***";   
int status = WL_IDLE_STATUS;

WiFiServer server(1991);


boolean alreadyConnected = false; 

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");
        while(true);
    } 
    else {
        server.begin();
        server.status();
        Serial.print("Connected to wifi. My address:");
        IPAddress myAddress = WiFi.localIP();
        IPAddress inetAddress=WiFi.gatewayIP();
        Serial.println( myAddress);

        Serial.println("Inet: ");
        Serial.println(inetAddress);
    }
}

void loop() {

    WiFiClient client = server.available();

    if(client) {
        if (!alreadyConnected) {

            client.flush();    
            Serial.println("We have a new client");
            client.println("Hello, client!"); 
            alreadyConnected = true;
        } 

        if (client.available() > 0) {
            // read the bytes incoming from the client:
            char thisChar = client.read();
            // echo the bytes back to the client:
            server.write(thisChar);
            // echo the bytes to the server as well:
            Serial.write(thisChar);
        }
    }
}

什么可能導致我的問題,我該如何解決?

有這個完全相同的問題。 確保你使用的是Arduino 1.0.3而不是1.0.5,這就是為我做的:)

我可以確認使用Arduino IDE 1.0.5 WiFi屏蔽是行不通的。 使用1.0.3它工作得很好。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM