Wifi Sparkfun RN-XV problem


I come here to explain my problem using the wifi shield from Sparkfun : Roving Network RN-XV.

So I have the following set : arduino uno + wifi prototype shield + Wifi Roving Network RN-XV.

After lot of tests, I found that the library provided by SParkfun doesn’t work for wifi deconnection and reconnection automatically. So I used the following librairy: GitHub - harlequin-tech/WiFlyHQ: WiFly RN-XV Arduino Library.

I use this system to post data on a personnal webserver. Everything works great during 15 to 45 min, once this time is spent the program blocks. In order to make it works again, I have to remove the power supply from the arduino (a simple push on the reset button doesn’t work). That’s why, I think it needs to empty the capacities. It is not a problem of memory leak on the Arduino, I already check that, maybe a problem of memory leak on the Wifi chip.

Below is my code :

#include <SPI.h>
#include <WiFlyHQ.h>

#include "Credentials.h" // Contains connection informations (ssid, passphrase)

WiFly wifly;

/************ variables ******************/
unsigned long timet  = 0 ;
unsigned long time;
unsigned long period;
const char *data = "data to send to the webserver";

void setup() {

    while (!Serial) {
        // wait for serial port to connect

    wifly.begin(&Serial, NULL);   

void loop()
    time = millis(); //Returns the number of milliseconds since the Arduino 
    //board began running the current program. This number will overflow 
    //(go back to zero), after approximately 50 days
    period = time - timet;

    if (period>10000){

        // if the wifi is associated we try to send data
        if (wifly.join(ssid, passphrase) && !wifly.isConnected())

            // If the connection to the server is Ok then we send the data
            if(wifly.open("data.egreen.fr", 80))

                //Send data to the server
                wifly.println( F("POST http://data.egreen.fr/energy/create HTTP/1.1") );
                wifly.println( F("Host: data.egreen.fr") );
                wifly.println( F("User-Agent: Arduino/1.0"));
                wifly.println( F("Content-Type: application/x-www-form-urlencoded") );
                //wifly.println( F("Connection: close") );
                wifly.print( F("Content-Length: "));

                // Close the connection and desassociate the wifi

                // reset period, set timet to the current millis() and reset wh   
                period = 0;

 * Return quantity of free ram
int freeRam() {
    extern int __heap_start, *__brkval;
    int v;
    return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);

Any help would be apreciate :slight_smile:

THanks by advance,