Hi there,
I want to trigger and send a message based on two interrupts, but only send once a minute. So I use two interrupts and the watchdog for this as below. So in theory, every watchdog cycle, SendData should be outputted only once. It gets outputted three times however.
The problem is that after the multiple interrupts are activated. So if the first pin interrupt is attached, and then deactivated, the second attachinterrupt on pin 2 activates the first interrupt. To me it seems like a bug, but it could be that I’m missing some point here. What do you think?
#include "Sodaq_wdt.h"
#define Led_Pin LED_BUILTIN
int interruptPin1 = 0;
int interruptPin2 = 1;
void setup()
{
pinMode(interruptPin1, INPUT);
pinMode(interruptPin2, INPUT);
sodaq_wdt_enable(WDT_PERIOD_8X);
}
void loop() {
if (sodaq_wdt_flag) {
sodaq_wdt_flag = false;
sodaq_wdt_reset();
SerialUSB.println("interrupt");
SerialUSB.print("attachInterrupt1 ");
attachInterrupt(interruptPin1, SendData, HIGH);
SerialUSB.print("attachInterrupt2 ");
attachInterrupt(interruptPin2, SendData, HIGH);
}
}
void SendData() {
detachInterrupt(interruptPin1);
detachInterrupt(interruptPin2);
SerialUSB.println("SendData");
}