Yun , hangs sometimes on sending over httpclient . Uses Wifi , 3G is available

Hi all,

i'm running a Yun for monitoring 2 sensors. He outputs the sensor data every 5 seconds to a thingspeak account.

On the Yun there is a (working) 3G HuaweiE303 dongle, Wifi signal is good . I have these two options bc the boards needs to be installed on several different places where we are not always sure that there is ethernet or wifi available.

Now, when i boot the board (no utp cable is attached) it starts to send out data perfectly. But sometimes, it hangs on this piece of code. I recognice that bc the LED stays on.

 digitalWrite(led, HIGH); 
 HttpClient client;
  String request_string =  thingspeak_update_API + thingspeak_write_API_key + thingspeakfieldname1 + temp +  thingspeakfieldname2 + hum + thingspeakfieldname3 + cnt;
  digitalWrite(led, LOW);

I tried to 'solve' this by adding a watchdog in the setup and call the reset every time the loop passes.


That works, but it happens way too much. I have no idea what is going on, sometimes it even happens that my linux side hangs. am i calling the httpclient too often ?

Next to that, i'm haven't tested this so far, but will the Yun try to send it's data over 3G when Wifi isn't available?

Thanx so far.

bartdereu: He outputs the sensor data every 5 seconds to a thingspeak account.

Be aware that ThingSpeak limits the connection rate to once every 15 seconds. That is probably not what is causing your hang ups, but still an issue nonetheless. I don't recall if using a higher data rate returns an error response, or if they just drop the additional accesses. And it's not just channel updates, it also includes status updates and ThingTweet calls.

Indeed, i forgot about that one. I also don't think it causes the hangs, but you'll never know.

I set it to 5 seconds bc my watchdog was set to 8s. Normally it has to update every 15 minutes. But when i had it at 1 minute, the problem was also there.

now i came accross this :