I'm using https://github.com/sui77/rc-switch on my ESP8266 with 2 receivers (315MHz and 433MHz), attached to GPIO 4 and 5.
If I create 1 instance only, i.e. 315 OR 433, I'm able to receive properly. When I create 2 instances using the code below, 1 for each frequency, I hardly get any signals. i.e. I have to hold my TX buttons down really long just to receive 1 or 2 interrupts.
RCSwitch rc433 = RCSwitch();
RCSwitch rc315 = RCSwitch();
void setup(void)
{
...
rc433.enableReceive(digitalPinToInterrupt(D1));
rc433.setReceiveTolerance(70);
// issue happens when I enableReceive() on both instances
// 315 and 433 works fine when the other is not `enableReceive`
rc315.enableReceive(digitalPinToInterrupt(D2));
rc315.setReceiveTolerance(70);
...
}
The way I worked around the issue was to have 2 ISRs handleInterrupt0()
and handleInterrupt1()
, so it is not a hardware issue. See https://github.com/bilogic/rc-switch/commit/70320fbd9f099a31e75e186e3a8cbbffec533006
However, it does bring up a question which I could not find answers to:
- Can multiple interrupts point to 1 ISR? If not, why?
- Given that duplicating the ISR with small changes overcame the issue, the answer to #1 seems to be no.
- I like some confirmation as to whether it is possible and if not, why.
Thank you.