5
votes

I'm trying to send information from the arduino board to my computer through the Wi-Fi network. for my project's purposes it has to be a UDP connection I use the "Send and Receive UDP String" example (http://arduino.cc/en/Tutorial/WiFiSendReceiveUDPString) with a few changes:

#include <SPI.h>
#include <WiFi.h>
#include <WiFiUdp.h>

int status = WL_IDLE_STATUS;
char ssid[] = "itay_net"; //  your network SSID (name) 
char pass[] = "0527414540";    // your network password (use for WPA, or use as key for WEP)

unsigned int localPort = 50505;      // local port to listen on

IPAddress remote_ip(192, 168, 1, 100);
unsigned int remote_port = 50505;


char  ReplyBuffer[] = "acknowledged";       // a string to send back

WiFiUDP Udp;

void setup() {
  //Initialize serial and wait for port to open:
  Serial.begin(9600); 
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present"); 
    // don't continue:
    while(true);
  } 

  // attempt to connect to Wifi network:
  while ( status != WL_CONNECTED) { 
    Serial.print("Attempting to connect to WPA SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network:    
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
    delay(10000);
  }

  // you're connected now, so print out the data:
  Serial.print("You're connected to the network");
  delay(10000);
  printWifiStatus();



  Serial.println("\nStarting connection to server...");
  // if you get a connection, report back via serial:
  Udp.begin(localPort);  
}

void loop() {

  int bite_send;
  Udp.beginPacket(remote_ip, remote_port);
  bite_send = Udp.write("hello");
  Udp.endPacket();
  Serial.println("the packet was sent");
  Serial.println(bite_send);



  delay(1000);
}


void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

It compiles and connects to the network just fine. the only problem is that I can't tell if the packet was sent because I see no trace of it on Wireshark. I also wrote a socket on java that listens to the port (50505) and should display the message from the packet, but it didn't work either. (I can copy the java code here but i can assure you that it is not the problem 'cause I tested it with a different java server and it worked, so the problem should be on the Arduino side)

a few details to narrow it down: I believe the "remote ip" is correct but even if it isn't - I still should have seen it in the Wireshark, so it can't be the problem. I should mention that the Wi-Fi shield works, I successfully sent pings and ran other examples (such as SimpleWebServerWifi).

I'm using an original Arduino Uno R3 board and an original Wi-Fi shield. The arduino IDE is the newest version. I updated the Wi-Fi shield with the newest update I found on GitHub.

I also ran the same "Send and Receive UDP String" code (with the necessary changes) on my Ethernet shield and it did work.

I don't know what else to try - please help. any help will be appreciated.

Itay

1
I have the same issue here, did you find anything now?Arnaud Aliès

1 Answers

0
votes

I dont think you have a reply buffer packet. google arduino wifisendrecieve and you will see the example they have that has a reply packet labeled as 'acknowledged'. Hope this helps