WiFly shield throughput

Hi,

I’m trying to test the maximum data transfer rates of the WiFly shield, but so far it seems to be woefully slow.

For testing purposes, I have my Arduino generating a sine wave and sending values to the WiFly, using SpiSerial.print() from the WiFly library (see code below). The WiFly is in ad hoc mode, communicating directly with my laptop via UDP, which I assumed would provide the highest data rates. If I send a value every few hundred milliseconds, the transfer is very reliable. But if I make the interval less than 20 ms, the messages are junk, or don’t get sent at all. This constitutes a transfer of a few hundred bytes per second, far below what I expected.

Does anyone have an idea about what the limiting factor might be? Is it the Arduino, the SpiSerial code, the WiFly itself, or something else I’m not considering? If someone knows an easy way to increase the throughput, that would be greatly appreciated.

In general, what is a reasonable data transfer rate to expect from this configuration?

Thanks in advance for your help!

// WiFly timing test sketch

#include "WiFly.h"

unsigned long time = millis();

float iter = 0;

int timeInterval = 20;

void setup() {
  SpiSerial.begin();
}

void loop() {
  if (millis() - time > timeInterval) {
    iter += 1;
    float val = sin(iter/100*2*PI);
    SpiSerial.print(val);
    time = millis();
  }
}

Hi there,

I’m trying to send data via UDP from the WiFly to my computer as well, but I couldn’t make it work, so on my research I stumbled upon your post which indicates that you seem to have made the sending of UDP messages to the laptop work. How did you do that?

Where and how did you set the WiFly into UDP mode? Did you do that whilst being in the command mode or did you edit one of the header files in the WiFly library?

Would be great to hear back from you, I’ve been trying around for ages but no UDP messages seem to be coming through…

Thanks!

Dine

Factor 1: SPI speed. Slowest is clock /128, fastest is clock/2. Personally. I use clock/4. This determines how fast your Arduino can get back to polling for stuff.

Factor 2: Inherent slowness of the “digitalWrite()” command. Which is used many times in the transmission of every byte. Instead of:

digitalWrite(10,HIGH);

use:

PORTB |= _BV(PB2);

Instead of:

digitalWrite(10,LOW);

use:

PORTB &= ~_BV(PB2);

Note that this is only for Arduinos that are NOT the Arduino Mega. It has a different port mapping.

Factor 3: What speed are you running the WiFly’s UART at? Default is 9600. Set it faster! I use 460,800 baud for my stuff.