Yun suddenly hangs

Hi experts,
Really need an advice here, I am working on an important project and I am strangling to make it reliable and stable.

I am sending sensor data (speed) of a manufacturing line to google sheet via pushingbox.com. Data sent about every one minute to pushingbox using the below function taken from here: GitHub - Clement87/PushingBox-for-Arduino-Yun. Yun is connected to internet via wifi and the data pushing to google works great.

The issue: the Yun seems to just hang after a while (sometimes after 1 hour, sometimes after 3 hours), it does not recover by itself, only reboot helps. Of course I want it to work continuously without need to physically reboot every time.

On the serial port the last message I see before it is hangs is :"sending request". Although the wifi connectivity looks ok I rebooted the linux part via ssh to see what will happen, the serial started showing output again but very very very slowly, looks like the Yun is still stuck but still showing some weak life signs. Only reboot make it working properly again.

I have the latest OpenWrt-Yun image, Wifi is good and stable, internet connectivity also seems ok, I have added delay(20) in several places in the loop to make processing more stable.

What could be the issue? And how to resolve?

Huge thanks for any advice

//Function for sending speed to PushingBox
void sendToPushingBox(char devid[], char Speed_str[])
{
  String APIRequest;
  
  Serial.println("Connecting to PushingBox ...");
  Console.println("Connecting to PushingBox ...");
  HttpClient client; 
  Serial.println("connected");
    Console.println("connected");
Serial.println("sending request");
  Console.println("sending request");
    
  //build API request
 
  APIRequest = String(serverName) + "/pushingbox?devid=" + String(devid)+ String("&speed=")+String(Speed_str);
  
  
  client.get (APIRequest);
  Serial.println("sent ");
  Serial.println(APIRequest);
  Console.println("sent ");
  Console.println(APIRequest);
  

    //DEBUG part
    // this write the response from PushingBox Server.
    // You should see a "200 OK"
    if (client.available()) 
    {
      char c = client.read();
      if(DEBUG){Serial.print(c);}
      if(DEBUG){Console.print(c);}
    }  

}

@odeduxi,
we have seen this problem before. I contend that the wifi chip is the problem. I contend that the manufacturing occasional (sometimes in batches) turns out faulty chips. Some people disagree with me. The chip makers certainly claim there is no problem.

TO FIX:
Sometimes buying another Yun (and replacing the current Yun) will fix the problem. Sometimes rebooting the Yun on a regular basis will fix it.

ALSO:
some people think the driver is the problem. This could be. Sometimes a down stream router will drop a packet and the system "dominos" into destruction.

To be clear, this (dropping network communication for no apparent reason) happens with SOME YUN, but I cannot tell you with which.

Other people on the forum will confirm this.

What is your final goal? May be we can find a work around.
Jesse

You could set a watchdog that resets the wifi. Some guy claimed that this worked. Dont remember the post now.

thank you mart256, I will look into it.

jessemonroy650, many thanks for the detailed answer, I have tried this on 2 different new Yun I just got, same results.

Per your question, the final goal is to have an Arduino connected to wifi sending data every minute to a cloud service (in this case pushingbox), and the most important part is that it will be stable and reliable without the need to manual reboot it every couple of hours as it is going to be deployed in a place where there is no convenient physical access.

I have tried also working with Uno+CC3000 wifi shield, and also tried working with ESP8266, but I could not get a reliable result either. Do you know of any good sketch example with these HW that could deliver a reliable and stable solution (with self wifi monitoring and automatic troubleshot in case of issue)?

Many thanks again, really appreciate the help

mart256:
You could set a watchdog that resets the wifi. Some guy claimed that this worked. Dont remember the post now.

I guess here is typo, should be watchcat, Watchdog takes care hardware issue like CPU over temperature or over load. Watchcat takes care software issue like network drop...

Install watchcat:

opkg update
opkg install watchcat
opkg install luci-app-watchcat

odeduxi:
...
I am sending sensor data (speed) of a manufacturing line to google sheet via pushingbox.com. Data sent about every one minute to pushingbox using the below function taken from here: GitHub - Clement87/PushingBox-for-Arduino-Yun. Yun is connected to internet via wifi and the data pushing to google works great.

The issue: the Yun seems to just hang after a while (sometimes after 1 hour, sometimes after 3 hours), it does not recover by itself, only reboot helps. Of course I want it to work continuously without need to physically reboot every time.

On the serial port the last message I see before it is hangs is :"sending request". Although the wifi connectivity looks ok I rebooted the linux part via ssh to see what will happen, the serial started showing output again but very very very slowly, looks like the Yun is still stuck but still showing some weak life signs. Only reboot make it working properly again.
...

Move most of business logic into Linux side, plus local logging.

$ch = curl_init('http://api.pushingbox.com/pushingbox?devid=v0123456789ABCDE');
curl_exec ($ch);
curl_close ($ch);

PHP & SQLITE3 for Process Class

thanks for the input sonnyyu, I followed your institutions and installed the watchcat, but how do I get to the web configuration page you have shown in your example?

Now I have another issue, after installing the watchcat I cant access the Yun anymore via ssh, I see that the ping from my PC to the Yun is very unstable, this didnt happen before, what do I do now? how to fix?
I am quite a newbie so any step by step guide will help.

Also about moving business logic into Linux side, I will appreciate if you could provide more step by step guide, what do I put in sketch and what in linux side

many thanks again for all the assistance

an updated, I can connect to the Yun now via ssh, not sure what was the issue.

odeduxi:
thanks for the input sonnyyu, I followed your institutions and installed the watchcat, but how do I get to the web configuration page you have shown in your example?
...

What is the output of :

opkg update
opkg install luci-app-watchcat

odeduxi:
::::SNIP::::

I have tried also working with Uno+CC3000 wifi shield, and also tried working with ESP8266, but I could not get a reliable result either. Do you know of any good sketch example with these HW that could deliver a reliable and stable solution (with self wifi monitoring and automatic troubleshot in case of issue)?

Many thanks again, really appreciate the help

@odeduxi,
rebooting an embedded system is NOT that unusual, especially for lower-end units like Arduino and Raspberry Pi. There are more reliable units with proprietary software, they usually run $500-$1000 or more.

There are still more alternatives. However, the ALL amount to resetting the system to some degree.

One other popular method, that works occasionally is to turn off the wifi for a period of time. Some people wait for a failure, some do it on a periodic schedule (of expected failure), some people just reboot every 24 hours.

In your case, I would say there is some software misconfigured, or poorly written, or written with a misunderstanding about protocols.

My wild guess is the network stack is incorrect. I will look at the code you have.

Jesse

@odeduxi,
I looked at your code. Three things come to mind.

  1. Have you updated your IDE and supporting libraries.

@Angelo9999 or someone else, what is the latest version of the libraries.

  1. Is the serial port constantly connected to this unit? Is it always in DEBUG mode? Can you turn off the Serial port?

  2. @ShapeShifter, would this work better by sending the data to the Linux side, then doing the data transfer from that side?

Jesse