Uno freeze randomly, power supply quality ?

Hello

I started on Arduino a mounth ago, so I am new in the matter.
I would like to use the Arduino for many projects, But actually I have a serious problem : my Arduinos are not reliable, they freeze randomly. I can't imagine using one for my gate, as I would have 100% chances to find it stuck, if not 20 minutes later power up, but 3 days later.

I did many searches first about the matter on power supply quality, and also about arduino uno freeze, I found a few informations, not very convincing.

Actually my code is very simple, I can't belive the problem comes from it. I haven't try, but it seems to me it seems able to freeze only with the original blink code.

I am using the Chinese cheap power supply like this, in 9 volts version :
http://www.ebay.fr/itm/1Pcs-9V-500Ma-4-5W-Ac-Dc-Power-Supply-Module-Step-Down-Isolated-Switching-Ic-N-R/262965087901?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2057872.m2749.l2649

I am very satisfied using them until now, I've got 3 working 24/24 on 2 gates, powering Radio receptors.
But they are switching type (as most of 5 V usb adapters and so on)

MY question :

I wonder if someone also wants to use them powering arduinos, and if happy with it or not.

I put some de-coupling devices between it and the arduino : ferrites, and 0.1 microfarad type X, they are no help.

Yesterday I put a tantallum small capacity directly on the 5V arduino board near the chip... I 'll see during the next days what will happen...

MY second question :
it doesn't looks like many people does experience many freeze problems with arduino's ? yes, no ?

Are we only mostly playing a few hours with arduinos, or seriously put them at work 24/24 as most electronic devices should, and with a high level of reliance. Every Chinese programmator can be in use for many years without any freeze problem

I found one blog of someone using a trinket to "push down" automatically the reset of he's arduino when it stops deliver a blinking.

Is Arduino not reliable, or Am I only in a power supply problem ?
Many thanks to contributors and arduino long experienced users.

my stuff :

arduino uno brand new and original (freeze after a couple minutes or hours)
arduino chinese copy purchased in a kit (freeze randomly from a few minutes to a few days)
arduino chinese copy smd with Chinese usb device, 3 euros (freeze after couple of hours or days)

about loads, I'm only powering a small relay, with an opto device, on the arduino pin it draws very little current. And the freeze don't seem related to the moment the relay is on.

Or it's a code problem :slight_smile:

Please post links of whatever is connected to the Arduino (relay, optocoupler, sensors, ...)
Please post a diagram of how everything is connected (a photo/scan of a hand drawn one is OK); this should include all the power connections as well.
Please post your code (using code tags)

Hello Sterretje

I’ve got a LCD like this :
http://www.ebay.fr/itm/1284-1602-16x2-HD44780-Character-LCD-Display-Module-yellow-Blacklight-arduino-/292036692546?var=&hash=item43febe4a42:m:mHNzFiDuKczbMBLpyUH4Qqg

(but before having it, I had freeze also)

a RTC1307 like this :
http://www.ebay.fr/itm/Module-tiny-RTC-DS1307-I2C-horloge-Real-Time-Clock-avec-pile-Arduino-DIY-/322072366318?hash=item4afd024cee:g:5DoAAOSwu-BWOjR~

(but before having it, I had freeze also)

a relay with optocoupler like this :

Have a led to send a signal that tell some loop is still running (although the LCD send the seconds too)

the power supply 9v like the one I posted on my former post.
with decoupler devices.

I’ll make the drawing schematic tomorrow.

This is a device to power a bell, a kind of chime, 4 times a day. 2 calls “make food” and 2 calls “come to have lunch/dinner”

Code is still a little dirty…

This code is currently running on 2 Unos. One on a Chinese Uno is working perfectly for … 1 day and a half on the real bell, and another is genuine Uno working on a buzzer at the output (no relay).
This second one had a bug today, it starts ringing almost continuously, it was because the “test” pin8 was configured input but was not connected to anything, even without a wire plugged into the arduino connector, but it was sensing some electricity from the air and detecting. Now directly plugged into grnd, no problem anymore.

but as you can notice, I try everything, including the watchdog (not in use now ) but the watchdog did not stop the uno from freezing.

I also made a code for making my gate automatic (not descripted here) same problem. Was working properly, but after a certain time, will freeze.

Comments are in French, I hope it’s not a problem ?

Now I send the code :

#include <Adafruit_SleepyDog.h>



#include <LiquidCrystal.h>















#include <RTClib.h>

#include <Wire.h>


RTC_DS1307 RTC; //Classe RTC_DS1307



//declaration du format heure
int temps ;
//nommer la variable de sonnerie
const int ring = 10 ;

//choix des heures de sonneries en heures pleines, en fixe (constantes) hfairemidi veut dire heure de faire midi
const int hfairemidi = 11;
const int hmidi =12;
const int hfairediner = 17;
const int hdiner = 18;

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);    // a l'origine 5, 4, 3, 2);

void setup () {
  Serial.begin(9600); //Démarrage de la communication
  Wire.begin(); //Démarrage de la librairie wire.h
  RTC.begin(); //Démarrage de la librairie RTClib.h
  lcd.begin(16, 2); //démarrage du LCD
  //Si RTC ne fonctionne pas
  if (! RTC.isrunning()) {
    Serial.println("RTC ne fonctionne pas !");
    }

   // RTC.adjust(DateTime("Sept 3 2017","06:50:00")); //ligne a reactiver a la bonne date pour faire une mise a l'heure

// initialize the digital pin as an output.
  pinMode(ring, OUTPUT);
  pinMode(9, OUTPUT);  //pin pour verification du processus
  }

void attends(){
  
for(int I =1 ; I<60 ; I++)
{
  lcd.setCursor(0, 0); lcd.print("                ");
lcd.setCursor(0, 1); lcd.print("                ");
lcd.setCursor(0, 0); lcd.print(" attente apres  ");
lcd.setCursor(0, 2); lcd.print("   tintement"); 
digitalWrite(9,HIGH);delay(50);digitalWrite(9,LOW); //diode temoin de passage dans la boucle
//Watchdog.enable(4000);

if (digitalRead(8)==HIGH) //test de la boucle de volee, utilisant le bouton du shield qui met au plus 5V
{
 Serial.print("touche test on"); delay (30);
  }


delay(900);
}}


//sonnerie à la volée
void volee()
{
lcd.setCursor(0, 0); lcd.print("                ");
lcd.setCursor(0, 1); lcd.print("son de volee   ");


//debut avec une double
digitalWrite(ring, HIGH);
delay(100);
digitalWrite(ring, LOW);
delay(400);

//Watchdog.reset();
digitalWrite(ring, HIGH);
delay(100);
digitalWrite(ring, LOW);


delay(2000);

//Watchdog.reset();


//isolée
digitalWrite(ring, HIGH);
delay(100);
digitalWrite(ring, LOW);
//Watchdog.reset();


delay(1600);

//Watchdog.reset();



//tintements à 1 seconde
for(int B =1 ; B<=3 ; B++)
{

//isolée
digitalWrite(ring, HIGH);
delay(100);
digitalWrite(ring, LOW);
//Watchdog.reset();
delay(900);
}

//Watchdog.reset();


// double
digitalWrite(ring, HIGH);
delay(100);
digitalWrite(ring, LOW);
delay(400);
digitalWrite(ring, HIGH);
delay(100);
digitalWrite(ring, LOW);

delay(2000);

//Watchdog.reset();


digitalWrite(ring, HIGH);
delay(100);
digitalWrite(ring, LOW);
delay(3000);

//Watchdog.reset();


digitalWrite(ring, HIGH);
delay(100);
digitalWrite(ring, LOW);
delay(400);


//Watchdog.reset();


attends(); //attente une minute afin de ne pas refaire la sonnerie tout de suite



}






void loop() {

 
if (digitalRead(8)==HIGH) //test de la boucle de volee, utilisant le bouton du shield qui met au plus 5V
{
 Serial.print("touche test on");
  }
  if (digitalRead(8)==HIGH) //test de la boucle de volee, utilisant le bouton du shield qui met au plus 5V
{
 volee();
  }
//Watchdog.reset();
 // digitalWrite(11,LOW); //extinction diode check de marche de cette boucle
  //Affichage de l'heure
  
  DateTime now = RTC.now();
  Serial.print(now.day(), DEC);
  Serial.print('/');
  Serial.print(now.month(), DEC);
  Serial.print('/');
  Serial.print(now.year(), DEC);  
  Serial.print(' ');
  Serial.print(now.hour(), DEC);
  Serial.print(':');
  Serial.print(now.minute(), DEC);
  Serial.print(':');
  
  Serial.print(now.second(), DEC);
  Serial.println();

  
lcd.setCursor(0, 0); lcd.print("                ");
lcd.setCursor(0, 1); lcd.print("                ");
  
 // set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 0); lcd.print(now.hour()); 
lcd.setCursor(3, 0); lcd.print("H");
lcd.setCursor(5, 0);lcd.print(now.minute());
lcd.setCursor(9, 0); lcd.print("min");
lcd.setCursor(14, 0); lcd.print(now.second());
  
  temps = now.hour();
  
  delay(150);
//lcd.noDisplay();//éteint le lcd pour effacer l'écran
delay(150);
//lcd.display();//rallume le lcd 


  digitalWrite(9,HIGH);delay(50);digitalWrite(9,LOW); //diode temoin de passage dans la boucle

//Watchdog.disable();
  //sonneries :

if(hfairemidi==now.hour() && now.minute() == 0)   
{son2coups();
  }


if(hmidi==now.hour() && now.minute() == 0)
{volee();
  }

if(hfairediner==now.hour() && now.minute() == 30)   
{son2coups();
  }

if(hdiner==now.hour() && now.minute() == 30)  
{volee();
  }


}


//sonnerie à deux fois deux coups
void son2coups(){
  
lcd.setCursor(0, 0); lcd.print("                ");
lcd.setCursor(0, 1); lcd.print("son deux coups  ");
for(int B =1 ; B<=3 ; B++)
//premiers deux coups
{
digitalWrite(ring, HIGH);
delay(100);
digitalWrite(ring, LOW);
delay(900);
digitalWrite(ring, HIGH);
delay(100);
digitalWrite(ring, LOW);
//Watchdog.reset();
//attente intermediaire
delay(3000);
//Watchdog.reset();
}
//derniers deux coups
//digitalWrite(ring, HIGH);
//delay(100);
//digitalWrite(ring, LOW);
//delay(900);
//digitalWrite(ring, HIGH);
//delay(100);
//digitalWrite(ring, LOW);
//Watchdog.reset();
attends(); //attente une minute afin de ne pas refaire la sonnerie tout de suite
}

Here I found the person who use a trinket as a watchdog, to make sure the arduino will keep doing it's job :

Are we numerous ?

This is a chance for you to learn/practice troubleshooting techniques. You swap out hardware and cut out software/disconnect components etc and see whether the problem goes away, you may be able to narrow down the problem to a piece of code or one specific piece of hardware.

The obvious candidates to start looking at are:

1 - bad arduino hardware
You seem to be having the same problem with every piece of hardware you tried so it seems unlikely to be a bad arduino (they are pretty robust)

2 - poor power supply
all of your tests involved the same power supply. Can you reproduce problem with a different power source? The one you have was very cheap chinese …

3 - memory corruption.
take out code/disconnect peripherals until the problem goes away. The last component removed could be the culprit.

Hello Evanroode

I did this also, at a point the arduino was only with one led, to see if alive or not.

But maybe I could use several arduinos each in different configurations to point track quickly where is the problem.

I put the led , the LCD, also the serial communication to be able to track the problem, it was of great help until now.

I first sight, I had the idea to get an arduino properly working should not be so hard.

Until now, none of them already froze (3 at work now)

maybe they feel something like can't afford a freeze ? :-[

picture of schematic (if it works)

It's usually advised not to power the relay from the 5V pin on the Arduino.

Yes, normally would need another supply. By the way, the relay is small.

I know you are right, Also, I never seen a commercial card with a separate supply for the relays.

The problem has never occured when the relay was powered. Always before.

And also occured often on the desk without relay.

well, until now, no freeze anymore, it means 2-3 days without problems. it's my Arduinos record until now.
same setup than before, the only added thing is the tantalum capacitor.

I just received 3 new Unos, I will put such a capacitor on all of them.

Maybe, for a finished project, it would be a good thing to put a resistor to ground on every unused pins from the microcontroller. Yesterday on an other project, simply approaching my finger to a pin configured as input was enough to get random I / O on it. Probably 50Hz induction.

Stop fiddling with bare board supplies and caps.
Use a 5volt cellphone charger, connected to the USB socket.
Leo..

Sterretje : you mean the relay is after the card regulator.

47francois:
Sterretje : you mean the relay is after the card regulator.

The relay and the Arduino should be parallel to the power supply. The power to the relay should NOT go through the Arduino at all.

some news :
Until now, no more problems, actually I have 2 unos working without any problems since I added tantalum capacitor on the Unos near to the microcontroller.

I will install them in proper boxes, and will give them more care about parasitic avoidance.
Relay will be replaced by solid state relay.