I bought a wifly shield from sparkfun, and aim to use it post sensor information to the internet.
But the problem is getting the Wifly to connect to a network. When using SpiUartermial example from wifly library I can connect to the network by doing the following in the serial monitor:
$$$
scan
set wlan phrase mypassword
join myssid
I then check that I am connected using:
show net
And I am connected.
However when saved and reboot the information is lost. Following this guide http://www.mgisolutions.info/2012/05/arduino-wifly-shield-tutorial.html with additional settings from the data sheet http://www.sparkfun.com/datasheets/Wireless/WiFi/WiFlyGSX-um2.pdf I put the following commands through the serial monitor:
$$$
set ip dhcp 0
set ip address 192.168.1.1
set ip netmask 255.255.255.0
set wlan join 4
set wlan ssid myssidIts a virgin media hub if that changes anything
set wlan auth 4 WAP2 auth used
set wlan chan 11
set wlan phrase mypassword
save
reboot
Then when I check connection its not connected.
Its very frustrating as I can't move on with the project. I think I would prefer it if it didn't connect either way, then it would be less frustrating.
I have tried doing different dhcp settings, as well as copying ip/netmask/chan shown when connected through the first method.
I hope that is enough information, and I have done hours of internet trawling and can't find the solution.
Sorry that was a typo in the message, I have now edited the initial post. I have now managed to get connected to a network by changing the join option to option 1. I have also managed to mash together code to set the WiFly up in code without using the Spiuart terminal with manual inputs.
How ever I now have another problem, I can't seem to get the WiFly example for a web client to work. The code i am using is:
#include "WiFly.h"
Client client("google.com", 80);
void setup() {
Serial.begin(9600);
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");
}
Serial.println("End of setup.");
}
void loop() {
Serial.println("Start of void loop");
if (client.available()) {
char c = client.read();
Serial.print(coffee);
}
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
for(;;)
;
}
Serial.println("End of void loop");
}
Using the serial prints I can tell that it hangs at the if (client.connect() statement. Hopefully I have provided enough information for someone to be able to shed some light on the problem. I have tried several suggestions on other web client examples and still doesn't work.
EDIT: Solved, was missing just one line that fixed it all.
WiFlyClient client;