sui77 / rc-switch

Arduino lib to operate 433/315Mhz devices like power outlet sockets.
1.92k stars 663 forks source link

Can't use more than one transmitter/receiver (trying to alternate between them without success) #446

Open lethevimlet opened 2 years ago

lethevimlet commented 2 years ago

I've been trying to setup multiple transmitter/receivers with no success since this is not supported apparently (would be nice to mention it on the README.md)

Now I was wondering if I could alternate between the transmitters and receivers but I had no success with the following approach, even trying to re-initalize RCSwitch().

int test = 0;
RCSwitch receiver;

setup() {
   receiver = RCSwitch();
   receiver.enableReceive(test);
}

loop() {
  if (receiver.available())
  {
    if(test == 0) {
      Serial.println("spawing to 315");
      test = 1; 
    } else {
       Serial.println("spawing to 433");
       test = 0;
    }

   receiver = RCSwitch(); // ISSUE! This wont reset all internal variables
   receiver.enableReceive(test); // ISSUE! This won't change once initialized
  }
}

Could you provide a way of changing dynamically transmitter/receiver pins or a way to create RCSwitch instances?

image

(Using 2 transmitters and 2 receivers to support 315/433MHZ for my WIP Web Universal Controller)

Similar issues:

422 (closed)

442

443