Reliability Test: Uno R3 + Wifi Shield UDP

Written by  on April 29, 2014 

* A log of reliability tests and subsequent findings when working with the Uno R3 + Wifi Shield *

—————————-
Setup:
Arduino IDE 1.5.6-r2
Arduino Uno r3
Arduino Wifi shield updated with the firmware that comes with Arduino IDE 1.5.6-r2
—————————-

Learning the hard way: When you get the Arduino wifi shield it’s reccomended that you update the firmware. At the time I tried it it was a problematic process. I followed the step by step photo guide here.
I was stymied by two things using that guide: The first is that when using the FTDI cable (which is optional) it’s not clear of the orientation of the FTDI connector on the wifi board as it isn’t labelled. It turns out the DTR pin is closest to the USB connector and the GND pin is closest to the reset button.
The other thing is I couldn’t find firmware that would actually load, got all sorts of weird errors from the firmware updater. None of the download locations on either the Binary Task Force guide or the official Arduino site gave me usable files. In the end I used the ones already on my computer that had been isntalled with the 1.5.6r2 Arduino IDE. The ones that worked had sizes in the hundreds of kb. Ones that didn’t were quite small.
The end result is that I updated the firmware from something with a build date in 2012 to something with a build date in 2013 but it’s not clear what version number or if this is actually the very latest version.

Learning the hard way: When using the wifi UDP example sketches make sure the Wifi.begin function is set for WPA (or WEP as required), by default it is for open (no password) networks. At the top of the sketch there is a constant where you can set your password however it isn’t included in the begin function by default.
Original (for open network):
status = WiFi.begin(ssid);
Correction (for WPA):
status = WiFi.begin(ssid, pass);

Test A – Reliability Test – Wifi UDP over WPA. Based on the WifiUDPSendReceiveString
Using WifiUDPSendReceiveString_test – same as demo sketch but with my wifi info and with it modified for WPA. I wrote a vvvv patch to send it the test packets.

– Results 1 –
Works but not seeing echo, although its apparently transmitted so potentially vvvv problem.
Trasmitting a packet to the Arduino every 1 second seems ok.
0.25 second transmit locks it up
transmit while it’s rebooting and it seems to screw up and never receive anything. That’s not very robust.

– Results 2
At 0.25s transmission intervals it runs for about 30 sec before freezing

– Results 3
At 0.1s transmission interval runs for about 10 seconds then freezes

– Results 4
at 1s transmission interval runs for 5 minutes then freezes
Pretty shitty for the demo program that comes with the shield

– Results 5
With 1s transmission interval, 4 byte packet.
Runs for 4.5 minutes then freezes

– Results 6
With 0.25s transmission interval, 4 byte packet
Runs for 30 seconds then freezes

==== Conclusion ====
Wifi shield is not a reliable product at the moment, at least not with UDP which is pretty basic. Disappointing. The firmware and libraries I’m using are the ones that came with IDE 1.5.6 r2. I’d tell you what version number firmware I’m using but I’m not even sure because of this firmware updating/github fiasco.

Final Sketch


/*
Test, identical to WifiUDPSendReceiveString demo, but without while (Serial.
 */


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

int status = WL_IDLE_STATUS;
char ssid[] = "yourSSID"; //  your network SSID (name)
char pass[] = "yourPass";    // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0;            // your network key Index number (needed only for WEP)

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

char packetBuffer[255]; //buffer to hold incoming packet
char  ReplyBuffer[] = "acknowledged";       // a string to send back

WiFiUDP Udp;

void setup() {
  //Initialize serial and wait for port to open:
  Serial.begin(9600);
  

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

  String fv = WiFi.firmwareVersion();
  if ( fv != "1.1.0" )
    Serial.println("Please upgrade the firmware");

  // attempt to connect to Wifi network:
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
    delay(10000);
  }
  Serial.println("Connected to wifi");
  printWifiStatus();

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

void loop() {

  // if there's data available, read a packet
  int packetSize = Udp.parsePacket();
  if (packetSize)
  {
    Serial.print("Received packet of size ");
    Serial.println(packetSize);
    Serial.print("From ");
    IPAddress remoteIp = Udp.remoteIP();
    Serial.print(remoteIp);
    Serial.print(", port ");
    Serial.println(Udp.remotePort());

    // read the packet into packetBufffer
    int len = Udp.read(packetBuffer, 255);
    if (len > 0) packetBuffer[len] = 0;
    Serial.println("Contents:");
    Serial.println(packetBuffer);

    // send a reply, to the IP address and port that sent us the packet we received
    Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
    Udp.write(ReplyBuffer);
    Udp.endPacket();
  }
}


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");
}



What next:
Let’s look at the Seeduino Ethernet as a base unit. See if we can get UDP working without worrying about wifi. Check it out.