Monthly Archives: March 2012

Connecting a Wifly shield to an Arduino

I’m trying to make a more mobile version of my ‘remote control’

which connects to the web in order to send commands. My first version was with a Nanode with built-in ethernet, but I also have a Arduino Duemilanove ATmega168, so I thought I’d try that with my new Wifly shield and a battery pack.

The Wifly shield is this version and I have some stackable headers to go with it. I connected the shield on top of the Arduino like this:

You can see that the USB socket means that the shield is a bit high up.

I downloaded this version of the Wifly library that’s been recently changed to work with Arduino 1.0 Library. All connected up, and running this code from the examples:

#include "WiFly.h"

char passphrase[] = "pass";
char ssid[] = "ssid";

byte server[] = { 66, 249, 89, 104 }; // Google

Client client("google.com", 80);

void setup() {

Serial.begin(9600);
delay(100);
Serial.println("[Wifly]");

WiFly.begin();

Serial.println("finished beginning");

if (!WiFly.join(ssid, passphrase)) {
Serial.println("Association failed.");
while (1) {
// Hang on failure.
}
}

Serial.println("connecting...");

if (client.connect()) {
Serial.println("connected");
client.println("GET /search?q=arduino HTTP/1.0");
client.println();
} else {
Serial.println("connection failed");
}

}

void loop() {
if (client.available()) {
char c = client.read();
Serial.print(c);
}

if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
for(;;)
;
}
}

it was hanging on Wifly.begin().

After a bit of hunting round I found this detailed description of what might be up – essentially a timeout, and then twice only, while I was fiddling with the headers, SpiUartTerminal.pde worked.

The rest of the time it just hangs on this:


Attempting to connect to SPI UART...

So really I’m looking for a bit of advice – I don’t really want to solder it on, but are there better ways of connecting the shield to the Arduino? Are headers typically less reliable than soldering? Is there a better way to connect the shield somehow maybe using a breadboard? (e.g. like this). Or am I just doing something daft …?

UPDATE: Thanks to John (see comment below) I sorted out the problem, which was a newby issue: stackable headers need to be soldered! Anyway I persuaded Damian to solder for me (I’ve never done it before) and we now have a working wireless, battery-powered remote control:

(All it does is send the category to a http web service and that randomly chooses an item from all iPlayer available items in that category, and sends it to a web page connected with XMPP).

Thanks everyone who helped. I’m very pleased with it :D