Linkit ONE + WiFi stop working after some time elapsed

For several days I create a project in which I have a Linkit One connected to WiFi, functioning as a WebService client sending the following information using GET:

GPS: Latitude and Longitude
Analog sensor value of 1
Value of 3 Switches

The information is sent every minute.

Initially I thought it would be problem because RAM used various STRING variables, thus optimizing the variables and also use the Flash to send texts and not saturate the RAM.

However at this time after several hours (24-30), The linkitOne disconnect from WiFi, stops sending the information and the TX and RX LEDs begin to flash continuously and slightly.

From there just restarting the button, the LinkitOne starts sending information.

That can happen?

I share the code for some help

[code]/*

  • Project Tank Gauging
  • Por: Ing.Diego Bonilla
  • Junio 2015
  • Hardware: Linkit ONE SeedStudio
  • Level Sensor Analogas Omnicomm
  • Dont Forget:
  • WiFi_AP, WiFiPassword, Sensor High and the IMEI.
    */

#include <LTask.h>
#include <LWiFi.h>
#include <LWiFiClient.h>
#include <LGPS.h>

#define WIFI_AP “MY WIFI”
#define WIFI_PASSWORD “MY PASSWORD”
#define WIFI_AUTH LWIFI_WPA

gpsSentenceInfoStruct info;

char action[] = "GET ";

char server[] = “idi.besaba.com”;
char path[] = “/registros/registros.php?Imei=”;

int port = 80;
char IMEI[] = “9876543210”; //This value i use like a ID.
int sensorPin = A0; // Sensor for IN
float sensorValue = 0;
int ign = 4;
int sen1 = 7;
int sen2 = 8;
int sen3 = 12;
unsigned int valorIG;
unsigned int valorS1;
unsigned int valorS2;
unsigned int valorS3;
double latitude;
double longitude;
int latitud;
int longitud;
int altura = 1500;
int Nivel;
bool Ign_Pwr;
bool Sensor1;
bool Sensor2;
bool Sensor3;
unsigned long time = 0;
unsigned long Temp1 = 0;
unsigned long Temp2 = 0;
unsigned long tiempo = 0;
bool contador;

//int tiempo = 120;

LWiFiClient globalClient;

static unsigned char getComma(unsigned char num,const char *str)
{
unsigned char i,j = 0;
int len=strlen(str);
for(i = 0;i < len;i ++)
{
if(str[i] == ‘,’)
j++;
if(j == num)
return i + 1;
}
return 0;
}

static double getDoubleNumber(const char *s)
{
char buf[10];
unsigned char i;
double rev;

i=getComma(1, s);
i = i - 1;
strncpy(buf, s, i);
buf[i] = 0;
rev=atof(buf);
return rev;
}

static double getIntNumber(const char *s)
{
char buf[10];
unsigned char i;
double rev;

i=getComma(1, s);
i = i - 1;
strncpy(buf, s, i);
buf[i] = 0;
rev=atoi(buf);
return rev;
}

void parseGPGGA(const char* GPGGAstr)
{
/* Refer to http://www.gpsinformation.org/dale/nmea.htm#GGA

  • Sample data: $GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,*47

  • Where:

  • GGA Global Positioning System Fix Data

  • 123519 Fix taken at 12:35:19 UTC

  • 4807.038,N Latitude 48 deg 07.038’ N

  • 01131.000,E Longitude 11 deg 31.000’ E

  • 1 Fix quality: 0 = invalid

  •                        1 = GPS fix (SPS)
    
  •                        2 = DGPS fix
    
  •                        3 = PPS fix
    
  •                        4 = Real Time Kinematic
    
  •                        5 = Float RTK
    
  •                        6 = estimated (dead reckoning) (2.3 feature)
    
  •                        7 = Manual input mode
    
  •                        8 = Simulation mode
    
  • 08 Number of satellites being tracked

  • 0.9 Horizontal dilution of position

  • 545.4,M Altitude, Meters, above mean sea level

  • 46.9,M Height of geoid (mean sea level) above WGS84

  •               ellipsoid
    
  • (empty field) time in seconds since last DGPS update

  • (empty field) DGPS station ID number

  • *47 the checksum data, always begins with *
    */
    double latitude;
    double longitude;
    int tmp, hour, minute, second, num ;
    if(GPGGAstr[0] == ‘$’)
    {
    tmp = getComma(1, GPGGAstr);
    hour = (GPGGAstr[tmp + 0] - ‘0’) * 10 + (GPGGAstr[tmp + 1] - ‘0’);
    minute = (GPGGAstr[tmp + 2] - ‘0’) * 10 + (GPGGAstr[tmp + 3] - ‘0’);
    second = (GPGGAstr[tmp + 4] - ‘0’) * 10 + (GPGGAstr[tmp + 5] - ‘0’);
    tmp = getComma(2, GPGGAstr);
    latitude = getDoubleNumber(&GPGGAstr[tmp]);
    latitud = latitude;

    tmp = getComma(4, GPGGAstr);
    longitude = getDoubleNumber(&GPGGAstr[tmp]);
    longitud = longitude;

    tmp = getComma(7, GPGGAstr);
    num = getIntNumber(&GPGGAstr[tmp]);
    }
    else
    {
    Serial.println(“Not get data”);
    }
    }

void leernivel () {
sensorValue = analogRead(sensorPin); //Read the Sensor Value
Nivel = (sensorValue*altura)/1023;
}

void leerONOFF (){
valorIG=digitalRead(4);//IGNICION
if (valorIG==LOW){
Ign_Pwr = false;
}else{
Ign_Pwr = true;
}

valorS1=digitalRead(7);//ALIMENTACION
if (valorS1==HIGH){
Sensor1 = false;
}else{
Sensor1 = true;
}

valorS2=digitalRead(8);//TAPA

if (valorS2==LOW){
Sensor2 = false;
}else{
Sensor2 = true;
}

valorS3=digitalRead(12);//INCLINACION

if (valorS3==LOW){
Sensor3 = false;
}else{
Sensor3 = true;
}
}

void SendData () {

if (globalClient.connect(server, port)){
// Serial.println(“conectado”);
// Serial.print(action);
// Serial.print(path);
// Serial.print(IMEI);
// Serial.print("&");
// Serial.print(“latitud=”);
// Serial.print(latitud1000);
// Serial.print("&");
// Serial.print(“longitud=”);
// Serial.print(longitud
1000);
// Serial.print("&");
// Serial.print(“nivel=”);
// Serial.print(Nivel);
// Serial.print("&");
// Serial.print(“ign_pwr=”);
// Serial.print(Ign_Pwr);
// Serial.print("&");
// Serial.print(“sensor1=”);
// Serial.print(Sensor1);
// Serial.print("&");
// Serial.print(“sensor2=”);
// Serial.print(Sensor2);
// Serial.print("&");
// Serial.print(“sensor3=”);
// Serial.print(Sensor3);
// Serial.println(" HTTP/1.1");
// Serial.print(F("Host: "));
// Serial.println(server);
// Serial.println();
// Serial.println();

  globalClient.print(action);                   
  globalClient.print(path);
  globalClient.print(IMEI);
  globalClient.print(F("&"));
  globalClient.print(F("latitud="));
  globalClient.print(latitud*1000);
  globalClient.print(F("&"));
  globalClient.print(F("longitud="));
  globalClient.print(longitud*1000);
  globalClient.print(F("&"));
  globalClient.print(F("nivel="));
  globalClient.print(Nivel);
  globalClient.print(F("&"));
  globalClient.print(F("ign_pwr="));
  globalClient.print(Ign_Pwr);
  globalClient.print(F("&"));
  globalClient.print(F("sensor1="));
  globalClient.print(Sensor1);
  globalClient.print(F("&"));
  globalClient.print(F("sensor2="));
  globalClient.print(Sensor2);
  globalClient.print(F("&"));
  globalClient.print(F("sensor3="));
  globalClient.print(Sensor3);
  globalClient.println(F(" HTTP/1.1"));
  globalClient.print(F("Host: "));
  globalClient.println(server);
  globalClient.println();
  globalClient.println();

}
globalClient.stop();
globalClient.flush();

}

void setup() {
Serial.begin(19200);
pinMode(ign, INPUT);
pinMode(sen1, INPUT);
pinMode(sen2, INPUT);
pinMode(sen3, INPUT);
LGPS.powerOn();
while (!LWiFi.connect(WIFI_AP, LWiFiLoginInfo(WIFI_AUTH, WIFI_PASSWORD)))
{
delay(500);
}
LWiFiClient client;
globalClient = client;
}

void loop() {
Temp1=millis();
LGPS.getData(&info);
parseGPGGA((const char*)info.GPGGA);
leernivel ();
leerONOFF ();
//Serial.print(“connect to:”); //Initially i use this for see the Count and the conetion
//Serial.println(server);
//Serial.println(time);

if (time>=60000) {
contador=true;
}
else{
contador=false;
}

if (Ign_Pwr==true || Sensor1==true || Sensor2==true || Sensor3==true || contador==true){
SendData();
time=0;
}
if (contador==false) {
Temp2=millis();
tiempo=Temp2-Temp1;
time=time+tiempo;
}
}[/code]

The Firmware of Linkit ONE are updated 1.1.05