Hello,
I’ve been having a problem of Wifly shield. The connection seems stopping after some minutes until I manually reset the arduino.
The code is like this:
#include "WiFly.h"
#include "Credentials.h"
Client client("google.com", 80);
boolean animation= false;
String number;
int skipCount= 0;
int numSkipLines=7;
int page=0;
void setup() {
Serial.begin(9600);
wiflySetup();
}
void wiflySetup()
{
WiFly.begin();
if (!WiFly.join(ssid, passphrase)) {
Serial.println("Association failed.");
while (1) {
// Hang on failure.
}
}
Serial.println("connecting...");
wiflyUpdate();
}
void loop()
{
if(!animation){
wiflyLoop();
delay(1);
}
else{
// segDisplay(); // *** I control segments/matrix LEDs with the data from wifi
// matrixDisplay(); //*** I comment out these to debug but the connection will still be lost
}
}
void wiflyLoop()
{
if (client.available()) {
char c = client.read();
Serial.print(c);
}
if (!client.connected())
{
Serial.println("unconnected - will be updated");
client.stop();
skipCount=0;
delay(1000);
wiflyUpdate();
}
}
void wiflyUpdate()
{
client.flush();
Serial.flush();
Serial.println("updating...");
if (client.connect()) {
Serial.println("connected");
client.println("GET /search?q=arduino HTTP/1.0");
client.println();
}
else
{
Serial.println("connection failed");
}
}
When it stops, it usually stops just after it prints “updating…” in the methods of “wiflyUpdate()”.
When I add LED controls (segDisplay() or matrixDisplay()) it stops even earlier than when I don’t use them. When I run just the code above it will run over an hour but when I run with the code controling LEDs, it sometime stops within 3 mins.
(In both case, it will stop anyway.) Is this something for memories…?
Could someone give me any suggestion how to solve the problem? I will really appreciate any info.
Thanks in advance,