Interrupt triggers wrong?

The ISR in my Project (sendData) is called without the change of the attached Pin.

I attach my interrupt like that:

pinMode(3,INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(3),sendData,CHANGE);

and in my ISR i immediately save the value of pin 3 in a queue:

void sendData()
{
queue.push(digitalRead(3));
delayMicroseconds(1000);
}

The problem is now, that after some time(every 15 - 20 minutes) - without changing the value of pin - a value is written in my queue. And it is always "1". So the value clearly stays the same, but the ISR is still called for some reason. Any Ideas what could cause that?

Pumpe.ino (1.91 KB)

Did you miss the concept that an ISR is supposed to be fast? Why are you using delay in an ISR?

The hardware interrupt on pin 3 is interrupt 1 (not 3).

The hardware interrupt on pin 3 is interrupt 1 (not 3).

Good thing that digitalPinToInterrupt() knows that.

If i do it without the delay it bounces.. but even without the delay i got the problem with the self-triggering interrupt after several minutes :confused:

What is connected to pin 3?

If i do it without the delay it bounces

Use the blink without delay technique. Record when an interrupt happens. If this interrupt is too soon after the last interrupt, ignore it. That's far better then any kind of delay technique.