Arduino becomes unstable after some time

Hello,

I am using an Arduino UNO with a 433 rf transmitter receiver to trigger a realy. The whole project is working fine but after some time (about 1-2 months) it becomes really unstable. The rf is not receiving correct signal and I have to go really close (about 50cm) to work correctly.

If I connect it to a usb and I re-load the programm the project is working fine again.

Is there any chance that something affects my system?

Can you post the code ?? are you relaying on the millis() function ?? The unsigned long var = millis(); will reset after nearly 49 days check if that is happening ??

-Malhar

I will find my code and post it here but I think it must be something else...I dont use millis() I only use digitalread if() and some delay()...

Is there any chance that lower or higher voltage affects it?

yes. Lower voltage can cause problems. generally, < 4.5V is not good for arduino uno running at 16MHz

millis() should run fine if you reset or turn off/on the board right?

eldonate: millis() should run fine if you reset or turn off/on the board right?

Yes, and it will work forever without a reset if your code uses subtraction - for example

if (millis() - prevMillis >= interval) {

...R

Is there anything wrong with my code?

#include <Wire.h>

static const int buttonPin1 = 8;     // koumpi down
static const int buttonRelay1 = 9;    //relay down
static const int buttonPin2 = 10;     // koumpi up
static const int buttonRelay2 = 11;    //relay down

unsigned long buttonPin1_Timer;
unsigned long buttonPin2_Timer;

void  setup()
{
  Serial.begin(9600);

  pinMode(buttonPin1, INPUT);
  pinMode(buttonPin2, INPUT);
  pinMode(buttonRelay1, OUTPUT);
  pinMode(buttonRelay2, OUTPUT);

  digitalWrite (buttonRelay1, HIGH);
  digitalWrite (buttonRelay2, HIGH);
}

void loop()
{
  if (digitalRead(buttonPin1)) {
    digitalWrite(buttonRelay1, LOW);
    buttonPin1_Timer = millis();
  }
  else if (millis() - buttonPin1_Timer > 500)
    digitalWrite(buttonRelay1, HIGH);

  if (digitalRead(buttonPin2)) {
    digitalWrite(buttonRelay2, LOW);
    buttonPin2_Timer = millis();
  }
  else if (millis() - buttonPin2_Timer > 500)
    digitalWrite(buttonRelay2, HIGH);
}

eldonate: Is there anything wrong with my code?

Does it do what you want?

...R

Robin2: Does it do what you want?

...R

It doesn't. Hence his post.

eldonate: Is there anything wrong with my code?

you must read http://playground.arduino.cc/Code/TimingRollover

ieee488:
you must read http://playground.arduino.cc/Code/TimingRollover

the arduino is being reset/power off once a week…is it possible to still affect it?

If the above code is complete, I see no problems with millis() anyway.

But the #include <Wire.h> lets me think that it is only a part or the whole story.

eldonate: the arduino is being reset/power off once a week....is it possible to still affect it?

If it is being reset once a week, that rules out the millis() rollover issue. It also tends to rule out some sort of memory leak or something like that since it is being restarted every week, but has issues after a month or two. It almost sounds more like a radio issue since he says when it goes bad the range is very decreased although what would happen that takes 2 months (and why reloading the sketch would fix it) is very odd.

ieee488:
It doesn’t. Hence his post.

The words of the Reply I was commenting on do NOT say that there is a problem

Is there anything wrong with my code?

That question only makes sense if “no” is a possible answer. Hence my question.

…R