[SOLVED] Dropping off from Server after 10 Minutes (Arduino Ethernet Shield)

Hi everyone ,

I’m kind a new in Ubidots Server. I’ve written some basic codes to see the temperature and to activate a Led.But i’ve been dealing with some server problem.After i start my Arduino it works very well till the 10. min. then i’m dropped from server.And arduino doesn’t try to connect again. Would it be right call to reset(by code) my arduino every 10 minutes.Or is there any other solution for that ?

Thank you for your help.

here is the code:

int button=7;
int lm35=A2 ;
int relais=8;
Ubidots client(TOKEN);

void setup() {
Serial.begin(9600);
pinMode(button,INPUT);
pinMode(lm35,INPUT);  
pinMode(relais,OUTPUT);
pinMode(4,OUTPUT);
digitalWrite(4,HIGH);
delay(1);
   // start the Ethernet connection:
    if (Ethernet.begin(mac) == 0) {
      Serial.println("Failed to configure Ethernet using DHCP");
      // try to congifure using IP address instead of DHCP:
      Ethernet.begin(mac, ip);
    }  
    // give the Ethernet shield a second to initialize:
    delay(1000);
}

void loop() {
  float messung = analogRead(lm35);
  float temp;
  messung=(messung/1023)*5000;
  temp=messung/10,0;
  float schloss = digitalRead(button);   
  client.add(ID, schloss);
  client.add(ID2, temp);
  client.sendAll();
  delay(50);
  float value = client.getValue(ID3); 
  if(value){
  digitalWrite(relais,HIGH);
  }
  if(!value){
  digitalWrite(relais,LOW);
  }

}

Hello @mubuca95,

Are you using the last version of the library? On our last release of the library we fix that issue. If not, please go to the link below to download the new one.

Regards,
Maria C.

Thanks for the quick reply @mariahernandez. Problem was solved with updated Library.

We’re here to help you! :slight_smile:

Hi!

I have the same issue with Arduino UNO with Ethernet shield.
Library has been replaced with new one. Project recompiled. Problem still.
Any ideas?

I’ll answer myself. For now it works about half an hour.
Provided above link to library didn’t help.

I found another thread.

There you can find a link to another version of the library.
https://github.com/ubidots/ubidots-arduino-ethernet/archive/metavix/infinite_while.zip

You must delete existing library and add library from ZIP file. After that close and reopen Arduino IDE.

Good luck!

After 30 minutes it stopped to send data again. TX LED on Ethernet shield is not blinking.

Please, make sure that you are using the last version of the library. In our last release of the library we fix the issue reported.

If you are using the last version of the library and the issue insists, please let me know to try to replay it and working on!

Regards,
Maria C.

Maria,

Thank you for your reply!
I tried all versions of library.
First was a link for starters. Then I found this thread and downloaded “master” branch.
You can check yourself that there are two branches. "Master"and “metavix/infinite_while”.
I tried to compile with second one as well.

Just now for double check I downloaded again “master” branch. It’s dated 18 January 2017.
Is it the latest version? For clarity better to have version written in “H” and “CPP” files.

Now Arduino Uno with Ethernet shield was able to send data to cloud only during 3 minutes.
Originally I added two variables and once executed client.sendAll() method.
I thought that there is timeout on server side and split it on two while loops to minimize packets.

Dashboard is very simple.
https://app.ubidots.com/ubi/public/getdashboard/page/UJ2QlPTeBG8C18h-n9zWRoMzd7Q

Sketch is below (TOKEN has been erased, MAC address has been changed).

#include <Ethernet.h>
#include <SPI.h>
#include <UbidotsEthernet.h>

#define IDIl  "595e56367625421ac1abef7b"  // Put here your Ubidots variable ID // Illumination
#define IDTm  "59607c097625427206f8eeb8"  // Put here your Ubidots variable ID // Temperature
#define TOKEN  "MyToken"  // Put here your Ubidots TOKEN

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };

// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 0, 99);

const long interval = 15000;  // Seconds between loops

int illuminationPin = A0;   // photo cell
int temperaturePin = A1;    // LM35
int ledPin = 13;            // select the pin for the LED
int illuminationValue = 0;  // value from photo cell
int temperatureValue = 0;   // value from photo cell
float temperature = 0.0;    // calculated temperature
unsigned long curr_time = millis();
unsigned long prev_time = 0;

Ubidots client(TOKEN);

void setup(){
    Serial.begin(115200);
    // start the Ethernet connection:
    if (Ethernet.begin(mac) == 0) {
      Serial.println("Failed to configure Ethernet using DHCP");
      // try to congifure using IP address instead of DHCP:
      Ethernet.begin(mac, ip);
    }
    // give the Ethernet shield a second to initialize:
    delay(1000);
    Serial.print("server is at ");
    Serial.println(Ethernet.localIP());

}
void loop(){

  boolean result1 = false;  //result of sendAll execution
  boolean result2 = false;  //result of sendAll execution

  curr_time = millis();
  if(curr_time - prev_time >= interval) {
    prev_time = curr_time;

    // read the values from the sensors:
    illuminationValue = analogRead(illuminationPin);
    temperatureValue = analogRead(temperaturePin);
  
    temperatureValue = temperatureValue * 1000.0 / 1024.0;
    temperature = temperatureValue / 2.0;

    while(!result1){
      client.add(IDIl, illuminationValue);
      result1 = client.sendAll();
    }

    while(!result2){
      client.add(IDTm, temperature);
      result2 = client.sendAll();
    }

    Serial.print("Time: ");
    Serial.print(curr_time);
    Serial.print("Illumination: ");
    Serial.print(illuminationValue);
    Serial.println(" Temperature: ");
    Serial.println(temperature);
  }
}

Hello @Scorpio9999,

The last version of the library is the “master” branch. To download the library please click on this link to download the right one.

I made a test during the night using this simple code and works properly during 8 hours until I stopped it.

#include <Ethernet.h>
#include <SPI.h>
#include <UbidotsEthernet.h>
#define ID  "Your_variable_ID_here"  // Put here your Ubidots variable ID
#define TOKEN  "Your_Ubidots_Token"  // Put here your Ubidots TOKEN

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 0, 177);

Ubidots client(TOKEN);

void setup(){
    Serial.begin(9600);
    // start the Ethernet connection:
    if (Ethernet.begin(mac) == 0) {
      Serial.println("Failed to configure Ethernet using DHCP");
      // try to congifure using IP address instead of DHCP:
      Ethernet.begin(mac, ip);
    }
    // give the Ethernet shield a second to initialize:
    delay(1000);
}
void loop(){
    float value = analogRead(A0);
    client.add(ID, value);
    client.sendAll();
}

Please verify if it works for you, once it worked you can add your routine to the code and you shouldn’t have any issue.

Regards,
Maria C.

The same result.
Several minutes and on Ethernet shield TX LED not blinking at all. Data not uploading to Ubidots. Is Internet connection should be permanent or library can reconnect Ethernet shield to Ubidots? I can think only if provider cut connection and then restore it after some period. What timeout is acceptable?

Is it possible to debug somehow what is the root of the problem?

Just for information results of tracert and ping from notebook in the same subnet.

   Tracing route to things.ubidots.com [50.23.124.68]
    over a maximum of 30 hops:

  1     1 ms     1 ms    <1 ms  Dlink-Router.Dlink [192.168.0.1]
  2     4 ms     4 ms     3 ms  comp35-101.2day.kz [80.241.35.101]
  3     3 ms     3 ms     3 ms  172.27.190.177
  4    13 ms    12 ms    14 ms  91.185.23.32
  5    22 ms    24 ms    22 ms  ae5-571.RT.INT.STV.RU.retn.net [87.245.238.38]
  6    74 ms    74 ms    74 ms  ae2-3.RT.EQX.FKT.DE.retn.net [87.245.233.58]
  7    79 ms    78 ms    78 ms  bbr01.xn01.fra01.networklayer.com [80.81.194.167]
  8    79 ms    79 ms    80 ms  a6.12.2da9.ip4.static.sl-reverse.com [169.45.18.166]
  9    90 ms    90 ms    93 ms  ae6.dar02.mil01.networklayer.com [50.97.19.191]
 10    93 ms    93 ms    94 ms  f.12.2da9.ip4.static.sl-reverse.com [169.45.18.15]
 11   166 ms   165 ms   167 ms  ae2.bbr01.tl01.nyc01.networklayer.com [50.97.19.204]
 12   171 ms   169 ms     *     ae5.cbs02.tl01.nyc01.networklayer.com [50.97.17.42]
 13     *        *      184 ms  ae0.cbs01.eq01.chi01.networklayer.com [50.97.17.48]
 14   180 ms     *      179 ms  ae7.cbs02.eq01.chi01.networklayer.com [50.97.17.27]
 15     *        *      201 ms  ae0.cbs02.cs01.den01.networklayer.com [50.97.17.46]
 16   224 ms   226 ms   241 ms  ae1.cbs01.eq01.sjc02.networklayer.com [50.97.17.89]
 17   223 ms   223 ms   223 ms  ae23.bbr01.eq01.sjc02.networklayer.com [50.97.17.73]
 18   224 ms   224 ms   226 ms  ae5.dar01.sjc01.networklayer.com [173.192.18.249]
 19   226 ms   225 ms   267 ms  po1.fcr01.sr01.sjc01.networklayer.com [50.23.118.131]
 20   226 ms   227 ms   226 ms  things.ubidots.com [50.23.124.68]

Trace complete.

Ping test

Pinging 50.23.124.68 with 32 bytes of data:
Reply from 50.23.124.68: bytes=32 time=226ms TTL=47
Reply from 50.23.124.68: bytes=32 time=226ms TTL=47
Reply from 50.23.124.68: bytes=32 time=226ms TTL=47
Reply from 50.23.124.68: bytes=32 time=226ms TTL=47

Ping statistics for 50.23.124.68:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 226ms, Maximum = 226ms, Average = 226ms

Greetings, looping here, the sendAll() method always attempts to connect to the Server before of sending data. As our tests here seems to work properly and our services have not experienced any downtime I suspect that the issue may be at your side. Maybe you should try to make a GET examples from the Arduino’s library to check if the issue is at your side or to try to perform additional tests.

Regards

Hi!
Yesterday I tried GetValues and it failed as well after several minutes.

I want to clarify a little details first.
I have Windows 10 Home Edition (Russian). I installed Arduino IDE 1.8.3.
By default editor language was Automatic and I had warnings during compilation.
Then I thought that you should repeat my error and I changed editor language to English.
For some reason warnings during compilation have gone.
I uploaded project to Arduino I hoped that problem is gone. It looked like this.

Then I connected USB cable and run Serial Monitor. All packets were the same until it stuck again.
RX LED blinking once each 3 seconds.
TX LED is not blinking anymore.

Here is the end of log from Serial Monitor. Hope it helps.

...

148
{"count": 23, "next": "http://things.ubidots.com/api/v1.6/variables/596667e37625420686ced300/values?page=2&page_size=1", "previous": null, "results": [{"url": "http://things.ubidots.com/api/v1.6/values/596722d17625422dc4bca6ea", "value": 1.0, "timestamp": 1499931345
Geting your variable
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 13 Jul 2017 07:37:05 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: close
Vary: Accept-Encoding
Vary: Accept, Cookie
Allow: GET, POST, HEAD, OPTIONS

148
{"count": 23, "next": "http://things.ubidots.com/api/v1.6/variables/596667e37625420686ced300/values?page=2&page_size=1", "previous": null, "results": [{"url": "http://things.ubidots.com/api/v1.6/values/596722d17625422dc4bca6ea", "value": 1.0, "timestamp": 1499931345
Geting your variable
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 13 Jul 2017 07:37:07 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: close
Vary: Accept-Encoding
Vary: Accept, Cookie
Allow: GET, POST, HEAD, OPTIONS

148
{"count": 23, "next": "http://things.ubidots.com/api/v1.6/variables/596667e37625420686ced300/values?page=2&page_size=1", "previous": null, "results": [{"url": "http://things.ubidots.com/api/v1.6/values/596722d17625422dc4bca6ea", "value": 1.0, "timestamp": 1499931345
Geting your variable

Dear user,

Regrettably I’m not able to reproduce your issue. I made a test with the examples codes provided in the library and works successfully during 10 hours until I stopped the Arduino:

Maybe, the issue is in your routine code. I recommend you start with these samples code, then you can add your routine to the code step by step to be able to verify where can be the problem.

Unfortunately we solve customized code issues as a service only for users with a business license, if you have a business license please provide us your userid through the direct support channels to give you assistance faster.

Best Regards,
Maria C.

Well, in this case I’m done with Ubidots.
I tried stock codes with latest library and it doesn’t work for me. As customer I disappointed with such level of service. I don’t want to waste my and your time further. There are plenty of other cloud services over the globe.

Device, dashboard and account for cloud service have been deleted.

Good luck!

P.S. I’m in IT business since 1989. I know how it should be by ITIL in proper way. I have 5000 clients on 24/7.

Dear user,

We respect the decision of our users regardless of the situation. Unfortunately as you can see in my last posts, I was not able to reproduce your issue. The scripts were tested for long hours without any issue.

As you know, we are a software company so we take care of any support present within the platform. Also, we provide to our users the hardware tools to get started with IoT like libraries and sample (provided “AS IS” without warranty); the propose of them is just to get start. To scalable solution, we recommend to our users build their own libraries or scripts following our API documention.

All the best,
Maria C.