Data transfer instability Arduino Yun

Hi Artur,
Quite easy doing it if you use timers.h library.
Check it here: Arduino Playground - Timer Library

I extracted what matters most from my code as an example.

//in the include session:
#include <Time.h>
#include "Timer.h" // examples at http://playground.arduino.cc/Code/Timer#Links
Timer t; // creating a timer object named "t"

// in setup
void setup() {
// ... your code
  triggerTimers(); // Start timer that triggers events
}

void loop() {
//  Cayenne.run(); // don't run it here. Commented. Will kick it from triggerTimers
  t.update(); // triggers all timer t objects defined on setup
}

void triggerTimers() {
 t.every(1000 , callCayenne); // for some reason I could not call Cayenne.run() here so I call a routine that do it at every second
}

void callCayenne() {
Cayenne.run(); 
}

Hope it helps
Cheers
Carlos

1 Like

@carlos_benjamin

Hi Carlos,

The code is perfect, I’ve just tried it on my NANO and it worked right off :slight_smile: Thanks a lot!

Cheers,

Artur

For all those still facing transfer problems between Arduino Yun and Cayenne I strongly recommend to upgrade the OpenWrt-Yun image. More on that topic can by found under:

It works just great.

Cheers,

Artur

2 Likes

@adam and all others … found a simple solution … I think …
I was facing the same well known stability issues with my Yun and with Dragino Yun schield on a mega.
I changed to MQTT protocol for YUN and ALL my problems were gone … is working for many days non-stop now :wink:
Hope this helps you.