Uno stops working after hour or so

I have installed my breadboard uno into my wall fuse box where i have all connections for my smart home controlling. After house was complete i added some movement sensors(PIR) on stairs, and now im reading those sensors and sending pulses to my main controler to turn lights on when i go on stairs. THe problem is that it all works fine for an hour or 2, but after then arduino stops(there is a blinking led on pcb to control working, and it also stops blinking at same time as sensors stop responding). And then if i remove the power of arduino and power it back on, it starts working again for an hour and stops again.

I did kinda fix this using the softrestart(); library(i call this function evry 30min) so the uno restarts evry half an hour.

But i still would like to find out why the uno stops working. I did check all the sensors and main controllers cables and they still work. also if i conenct main controller input to +5v the lights light up, so the problem is in the atmega328 for sure8 i tried several different megas).

Could it be some high current interferences causing the quartz-cap so change and fall out of sync or someting??

I can see nothing wrong with the code that you have not posted.

Likewise that circuit you didn't post is great. What can be the problem?

Please read this:-
How to use this forum
It will tell you how to ask a question.

At least nobody has been electrocuted and no fire has started.

...R

#include <SoftReset.h>
long cou = 0;



const int  buttonPin1 = A2;
const int ledPin1 = 11;
const int  buttonPin2 = A1;
const int ledPin2 = 10;
const int  buttonPin3 = A0;
const int ledPin3 = 9;

void setup() {
 pinMode(buttonPin1, INPUT);
 pinMode(ledPin1, OUTPUT);
 pinMode(buttonPin2, INPUT);
 pinMode(ledPin2, OUTPUT);
 pinMode(buttonPin3, INPUT);
 pinMode(ledPin3, OUTPUT);
}


void loop() {
 cou=cou+1;
 if(analogRead(buttonPin1)>140){
   digitalWrite(ledPin1, HIGH);
   delay(250);
   digitalWrite(ledPin1, LOW);
 }

 

 if(analogRead(buttonPin2)>140){
   digitalWrite(ledPin2, HIGH);
   delay(250);
   digitalWrite(ledPin2, LOW);
 }


 if(analogRead(buttonPin3)>140){
   digitalWrite(ledPin3, HIGH);
   delay(250);
   digitalWrite(ledPin3, LOW);
 }

 delay(1000);


 if(cou>300){
 soft_restart();
 }
}

CIRCUIT: is simple atmega328 whit 16MHz crystal and 2x 22pF capacitors. Its a basic arduino on pcb circuit i use in many projects and i never had problems whit it.

But now i noticed that even whit called reset the atmega328 stops responding after a day or so :S

Did you read that link I posted? I think the answer is no because the code is not posted correctly. We consider that as either that you are being discourteous or you will not understand any answer we can give you.

Have you really got no decoupling capacitors in that circuit? If so that is your problem.
Also have you pull up resistors?

Hi,

I have installed my breadboard uno into my wall fuse box

Breadboard, not good idea, you have a very electrically noisy environment, every electrical appliance and light will have in the house has current passing through the fuse box.
This includes:

  • fluorescent light starting current.
  • refrigerator starting current.
  • any kitchen bench top appliance noise.
  • AirConditioning / Heating compressor/fan current.

Not a good location, as Grumpy Mike has suggested bypassing may help,but get the circuitry out of the fuse box.
In Australia it would be illegal to put anything like that in the fuse box.

Tom... :slight_smile:

grumpy mike, sry i skipped that link, but i fixed my post now. :smiley:

I dont use pullups bcs the sensors do not work like on/off swithces but they give out analog voltage(0,1to1V no movement, 2Vto4V movement detected).

I will try using decoupling capacitors and i will also put atmega outside the fuse box and provide external 5v supply from a wall socket.

Thank you all for your help.