Arduino Mega + WiFly

Hello everybody,

I'm using arduino devices since 2 months ago and I like it. For the first time, it's really plug and play, and very simple for getting started. Nice job!
unfortunately, today, I'm experimenting troubles...
I use arduino mega 2560 + Ethernet shield, and I have developped very fast a UDP serversocket, which work very well...
So I tried to replace the Ethernet shield with a WiFly device (this one: WiFly Shield - WRL-09367 - SparkFun Electronics)
The problem is during the WiFly.begin(); which froze the system.

Here is my code

#include <SPI.h>
#include <WiFly.h>

#include "Credentials.h"

WiFlyServer server(80);

void setup() {
  Serial.begin(9600);
  Serial.print("Initialisation...");
  WiFly.setUart(&Serial);
  WiFly.begin();
  Serial.println("WiFly.begin finished.");
  if (!WiFly.join(ssid)) {
    while (1) {
      // Hang on failure.
	  Serial.println("Error connection");
    }
  }
  Serial.println("Connection OK.");
  Serial.print("IP: ");
  Serial.println(WiFly.ip());
  
  server.begin();
}

The result is (on the serial monitor):
Initialisation...$$$

ver
$$$

ver
$$$

ver
$$$

ver
$$$

ver

Do anyone have a suggest???
Thanks a lot

WiFly uses the serial interface for communication with the Arduino. Because of that you cannot use the hardware serial interface ("Serial") for debugging, if you wanna debug, use SoftwareSerial and some kind of USB2Serial adapter (p.e. USB2Serial Light, Foca, FTDI cable, etc.) to attach to your PC.

Thanks for your replie, Pylon.

I tried to use a LCD display instead of the serial interface.
The problem is the same: The message displayed is "Connecting..."

#include <SPI.h>
#include <WiFly.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

WiFlyServer server(80);

void setup() {
  lcd.begin(16, 2);
  
  char ssid[] = "arduino";
  lcd.print("Connecting...");
  WiFly.setUart(&Serial);
  WiFly.begin();
  lcd.print("End of begin!");
  if (!WiFly.join(ssid)) {
    while (1) {
      // Hang on failure.
        lcd.setCursor(0, 0);
	lcd.print("Connexion: Error");
    }
  }
  lcd.setCursor(0, 0);
  lcd.print("Connection: OK");
  lcd.setCursor(0, 1);
  lcd.print("IP:");
  lcd.setCursor(3,1);
  lcd.print(WiFly.ip());
  server.begin();
}

More precisions:

I use a belkin router and i have configured no security and ssid:arduino

I read somewhere that we must use:
No security: WiFly.join(“ssid”)
WPA Mode : WiFly.join(“ssid”, “passphrase”)
WEP Mode: WiFly.join(“ssid”, “passphrase”, WEP_MODE)

How did you connect the WiFly (are you using the shield or the RN-XV?) to the Arduino? Doesn't it have a switch to change from PC/USB to Arduino connection? Have you tried setting it up with commands from the PC directly?

this is this
There is no switch.

But now, I don't use the serial interface, so there must have no longer problems with it, no ?

Is this the new WiFly-Shield from Sparkfun?

If it is, you need other software because this does not use the UART of the Arduino for the connection but a separate SPI2UART chip, so the software has to use the SPI interface. They have an alpha level library in their forum: WiFly Shield code library alpha 2 release - SparkFun Electronics Forum.

The positive effect is that you can use the Serial for debugging and other stuff again.