Feeds not updating after random time in emoncms.org

In reference to (similar problem):

http://openenergymonitor.org/emon/node/3584

I think the problem is not solved.

I have an arduino with 6 temperature sensors, sending data every 15 seconds, thanks to Ethernet shield..

Every 3 o 4 days, I have to "reset" mi system, because seems not to arrive data to emoncms.org. Las time was before yesterday, as you can see in the image attached.

The code to send data I use is:

// this method makes a HTTP connection to the server:
void sendData()
{
  Serial.println("Connecting...");
  // if there's a successful connection:
  if (client.connect(server, 80))
  {
    // send the HTTP GET request:

    client.print("GET /api/post?apikey=");
    client.print(apikey);
    if (node > 0) {
      client.print("&node=");
      client.print(node);
    }
    client.print("&json={Sensor0");
    client.print(":");
    client.print(TempInCelciusf[COLECTOR1]);
    client.print(",Sensor1:");
    client.print(TempInCelciusf[COLECTOR4]);
    client.print(",Sensor2:");
    client.print(TempInCelciusf[EXTERIOR]);
    client.print(",Sensor3:");
    client.print(TempInCelciusf[TANQUESUP]);
    client.print(",Sensor4:");
    client.print(TempInCelciusf[TANQUEINF]);
    client.print(",Sensor5:");
    client.print(TempInCelciusf[CASA]);
    client.print(",Bomba:");
    client.print(pumpWorking);
    client.print(",Bomba2:");
    client.print(pumpWorking2 + highSpeedFan);
  
    client.println("} HTTP/1.1");
    client.println("Host:emoncms.org");
    client.println("User-Agent: Arduino-ethernet");
    client.println("Connection: close");
    client.println();
    // note the time that the connection was made:
    lastConnectionTime = millis();
  }
  else
  {
    // if you couldn't make a connection:
    Serial.println("Connection failed");
    Serial.println("Disconnecting...");
    client.stop();
  }
}

Can anyone tell me if data was received around this time (16:39:00 h, 19 February 2014)

Any idea to solve this?

Is the string with data too long to send ?

I have new router and optical fibre now (50Mb), but one month ago I had a router with ADSL (10 Mb) and the problem was the same...

Thans in advance

aicanduit's picture

Re: Feeds not updating after random time in emoncms.org

I replaced the multiple calls to client.print with:

 

 

char data[180];

sprintf(data,"GET /api/post?apikey=%s&json={Sensor0:%d,Sensor1:%d,Sensor2:%d,Sensor3:%d,Sensor4:%d,Sensor5:%d,Bomba:%d,Bomba2:%d} HTTP/1.1",apikey,(int)TempInCelciusf[COLECTOR1],(int)TempInCelciusf[COLECTOR4],(int)TempInCelciusf[EXTERIOR],(int)TempInCelciusf[TANQUESUP],(int)TempInCelciusf[TANQUEINF],(int)TempInCelciusf[CASA],pumpWorking,pumpWorking2+highSpeedFan);

client.print(data);

 

(Only one call, avoiding multiple packets).

 

Now, the system ends blocking (can´t write or read to Internet ) even in a shorter period of time, as you can see in: http://www.emoncms.org/aicanduit/graftemp (Started at 18:29:50 and blocked at 7:29:50)

 

The big problem is that if it blocks when some pumps are running, the pumps remain running until I reset the system (is a thermal solar water system, with a tank and solar water collectors)

 

May long url be the cause ?

 

aicanduit's picture

Re: Feeds not updating after random time in emoncms.org

Returning to original code (first post).

If I put all data in a char array, then the system slows down, and send data even in minutes intervals.

Why ?

Is there any kind of bottleneck ?

Any idea, please ? Thanks in advance...

ukmoose's picture

Re: Feeds not updating after random time in emoncms.org

There are alot of things that might be going wrong.

If you are posting code, it's also useful to post the output of that code.  So for example, printing the long data submission string to the serial port and posting a bit of that serial output here will enable you to see if it's an erroneous data value that's causing it to hang.  

Looking at the serial output you've already got in your script should show you if the script is hanging (serial print stops) or it keeps printing the same loop over and over again, but without any data being sent.

Also have you tried looking on the Arduino forums for "ethernet shield stops working"?, you might pick up some tips.

You say "The big problem is that if it blocks when some pumps are running, the pumps remain running until I reset the system".

What is the "safe" state for your system? If within your system the safe state is for the pumps not to be running. The system controlling the pumps should be designed to stop the pumps if current data isn't being posted.  

 

 

 

 

aicanduit's picture

Re: Feeds not updating after random time in emoncms.org

The output of the code is revised by me and I think that it is correct (int version).

With this code (included output request)...

char data[180];
    char str[6][8];

    // dtostrf(FLOAT,WIDTH,PRECSISION,BUFFER);
    // send the HTTP GET request:
   // GET /api/post?apikey=XXXXXXXXXXXXXXX&json={Sensor0:23.57,Sensor1:2.56,Sensor2:3.79,Sensor3:33.56,Sensor4:-5.56,Sensor5:0.56,Bomba:0,Bomba2:0} HTTP/1.1

 
    dtostrf(TempInCelciusf[COLECTOR1],1,2,&str[0][0]);
    dtostrf(TempInCelciusf[COLECTOR4],1,2,str[1]);
    dtostrf(TempInCelciusf[EXTERIOR],1,2,str[2]);
    dtostrf(TempInCelciusf[TANQUESUP],1,2,str[3]);
    dtostrf(TempInCelciusf[TANQUEINF],1,2,str[4]);
    dtostrf(TempInCelciusf[CASA],1,2,str[5]);

    sprintf(data,"GET /api/post?apikey=%s&json={Sensor0:%s,Sensor1:%s,Sensor2:%s,Sensor3:%s,Sensor4:%s,Sensor5:%s,Bomba:%d,Bomba2:%d} HTTP/1.1",apikey,str[0],str[1],str[2],str[3],str[4],str[5],pumpWorking,pumpWorking2+highSpeedFan);
    Serial.println(data);

   Client..println(data);

 

...System stops sending data in few minutes...

 

Even I have defined...

#define SS_SD_CARD   4
#define SS_ETHERNET 10

void setup() {
    // ...
    pinMode(SS_SD_CARD, OUTPUT);
    pinMode(SS_ETHERNET, OUTPUT);
    digitalWrite(SS_SD_CARD, HIGH);  // SD Card not active
    digitalWrite(SS_ETHERNET, LOW);  ); // Ethernet active
    // ...
}

 

...also.

You said: "What is the "safe" state for your system? If within your system the safe state is for the pumps not to be running. The system controlling the pumps should be designed to stop the pumps if current data isn't being posted."

If the arduino system is blocked in a client.print(), or serial.print(), how can I controle the pumps ? If I loose the program control, how can I control the system ? Output pins remains low, keeping relays enabled...

 

I suspect that is something related with TimSurfer says in :

http://code.google.com/p/arduino/issues/detail?id=642

http://forum.arduino.cc/index.php?PHPSESSID=6bii8q14mb3neervjabvnfieh2&topic=72027.15

 

But it is strange that this does not happen to many people...

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.