Hello all,
I am pretty new to Arduino, but I have been asked to work on a project that uses a wifi connection as a form of testing proximity to a building. In this case, a buzzer would sound once the Arduino device was brought far enough away from a building that it could no longer connect to its wireless internet.
To do this I am using an Arduino Uno, a WiFly sheild WRL-09954 (this one: www.sparkfun.com/products/9954), and a tiny little buzzer I had around. My code uses the WiFly library.
I modified the code from some basic WiFly examples to suit my needs, but something is not right. I have done a lot of searching for WiFly documentation, but because I am so new to arduino, I'm not sure where to look for the documentation I need.
My overall plan was to move the WiFly library calls to connect to a network from setup() to loop() which seemed to half work, except that it only loops 7 or 8 times before seeming to stop. Here is my code:
#include "WiFly.h"
#include "Credentials.h"
int alarmPin = 5; //This is the pin with the buzzer.
int count = 0;
void setup() {
pinMode(alarmPin, OUTPUT);
Serial.begin(9600);
Serial.println("\n\r\n\rWiFly Shield in Use");
}
void loop() {
Serial.println("LOOP " + String(count));
count = count + 1;
WiFly.begin();
if (!WiFly.join(ssid)) {
Serial.println("Association failed.");
tone(alarmPin, 523, 500);
} else {
Serial.println("Associated!");
}
//I THINK I NEED A LINE HERE TO CLOSE THE WIFLY CONNECTION
}
If I had to venture a guess a guess as to why this is happening, I would say that I need a line to close the connection at the end of the loop function because currently it is keeping the old connections and starting a new one, and the Arduino is eventually running out of memory (at about 7 or 8 loops).
If I am correct, does anyone know what the call to the WiFly library would be? If I am wrong, I would love any assistance/advice on the project.
Also, if there is an official page with all the documentation for the WiFly library that I am missing, I would really appreciate a link to that as well.
Thank you all