Go Down

Topic: Sketch setup reruns  (Read 122 times) previous topic - next topic


Jul 10, 2019, 04:07 pm Last Edit: Jul 10, 2019, 06:21 pm by orangesmell

I face a problem that I can't explain.

I have been developping a rather large sketch. It's been working very well both from USB and then from the Wifi. But I realised that after 10/12 hours, the sketch runs its setup function again, and then more and more up to a point, after 2 more hours roughly where it runs the setup function more than once per minute.

I thought I might have had a memory leak so I then tried with a much smaller sketch that only outputs two lines (date then the word REBOOT) to a file on the SD card.

The result is the same, even though I think it does take a bit longer to occur.

I tried to resend the sketch from the web interface, but with no success.

I tried to reset the MCU through /usr/bin/reset-mcu but with no success.

I tried to reset Linux from the command line or from the web interface, with no success.

I then thought that I might have reached some temperature which would explain everything pretty well, so I "unpowered" the Yun for 3 seconds, then replugged it. I expected to reboot every few minutes, but no, it took a new 10/12 hours.

I know I can definitely put a time driven power socket (no the right word in english, my bad, but I am sure that's pretty self explanatory) and, configure it to switch on and off the power for 1 minute every 6 hours for example and that it should work, but wow, that's a very bad solution...

So I came here to ask if anyone had any idea about it all...

The board is an Arduino Yun Rev 2 running 17.11 and Linux does not restart when the sketch restarts

Thanks in advance


I thought I might have had a memory leak so I then tried with a much smaller sketch that only outputs two lines (date then the word REBOOT) to a file on the SD card.
Please post that sketch here using code tags (</> button on the toolbar).

Does this happen when you have the Yun powered via a USB cable connected to your computer?



Thanks for your reply.
The problem happens when the Yun is powered through the wall power socket, not my PC (as I never tried to run from my PC form 10/12h).

Here's my code (sorry for the comments in French):
Code: [Select]
 *  =============================
 * Parametrage variables globales
 * Passer PinBas de 1 à 4 !!!!!!!
 * Passer debug a 0 *

// --- Programme Arduino ---
// par A Desbordes - Juin 2019

 * Change log
 * 1.0 | 01/07/19 |Version initiale

//**************** Entête déclarative *******
// A ce niveau sont déclarées les librairies, les constantes, les variables...

// --- Inclusion des librairies utilisées ---
#include <FileIO.h>
#include <Process.h>
#include <Bridge.h>

// --- Déclaration des variables globales ---
Process date;

// --- Déclaration des constantes ---

// --- constantes des broches ---

// --- variables globales
int globalErreur=0;
String HeureDemarrage;

// --- Déclaration des objets utiles pour les fonctionnalités utilisées ---

//**************** FONCTION SETUP = Code d'initialisation *****
// La fonction setup() est exécutée en premier et 1 seule fois, au démarrage du programme

void setup()   { // debut de la fonction setup()
  FileSystem.begin(); // initiliase le FileSys Linux


} // fin de la fonction setup()
// ********************************************************************************

//*************** FONCTION LOOP = Boucle sans fin = coeur du programme *************
// la foncétion loop() s'exécute sans fin en boucle aussi longtemps que l'Arduino est sous tension

void loop(){ // debut de la fonction loop()


// ****************** FONCTION getHeure *******************
// la fonction getHeure() retourne la date et l'heure actuelles sous forme de string au format
// dd/mm/YY HH:MM:SS
String getHeure(){
  String localHeure;

  // obtenir l'heure
  date.addParameter("+%d/%m/%Y %T");
  //if there's a result from the date process, get it.

  while (date.available()>0) {
    // print the results we got.
  return localHeure;

//**************** SUB debug ************
// Cette fonction permet d'écrire sur /mnt/sda1/ArduinoJardin/debug.txt ce qui est passé en paramètre (avec l'heure sur la ligne d'avant)
void debug(String msg){
      File dataFile = FileSystem.open("/mnt/sda1/ArduinoJardin/debug.txt", FILE_APPEND);
      // if the file is available, write to it:
      if (dataFile) {

// --- Fin programme ---


I was thinking maybe it was a power problem, since an SD card draws quite a bit of current. However, I'm kind of doubting this now because I remembered that the Yun doesn't have an onboard voltage regulator. What is the current rating of your power supply?



I was thinking the same, so I change the power adaptor (4 different ones). To be honest, I don't know the current ratings for them, but one of them is an high speed power charger for my phone, so I guess the current can be relatively high.

Also, the Linux part keeps running (uptime keeps going) while the MCU restarts.

For me it looks like something is building up up to a point where the MCU fails. But what puzzles me is that mcu-reset or a new sketch don't solve the issue... I am more and more thinking that I have an hardware issue.

If I ever put my hands on another Yun, I'll try the same conf...

Go Up