Can you have multiple IR Receiver/Decoders on one Arduino?

Hi,

I’m attempting to receive and decode IR using multiple . This is the model I’m currently using:
http://osepp.com/products/sensors-arduino-compatible/ir-receiver/

However, I notice that when I duplicate the code, the only pin that reads info from the IR receiver signal is the pin that is listed last in the code above the setup loop.

Here’s my code:

#include <IRLib.h>

IRsend My_Sender;             // Create a sender object
IRrecv Receiver13(13);       // Create a receiver object to listen on pin 13
IRrecv Receiver11(11);       // Create a receiver object to listen on pin 11
IRrecv Receiver12(12);       // Create a receiver object to listen on pin 12
IRdecode Decoder11;          // Create a decoder object
IRdecode Decoder12;          // Create a decoder object
IRdecode Decoder13;          // Create a decoder object

unsigned long time;

void setup()
{
  Serial.begin(9600);
  Receiver11.enableIRIn();   // Start the receiver 11
  Receiver12.enableIRIn();   // Start the receiver 12
  Receiver13.enableIRIn();   // Start the receiver 13
}

void loop() {

  // Continuously look for results. When you have them pass them to the decoder
  if (Receiver11.GetResults(&Decoder11)) {
    Decoder11.decode();      // Decode the data
    Decoder11.DumpResults(); // Show the results on serial monitor
//    Receiver11.resume();     // Restart the receiver
    
//    Receiver11.enableIRIn();

    time = millis();
    Serial.print(time); // prints the time since the program started/
    Serial.println(": Time at end of IF loop.");
    Serial.println("");

    My_Sender.send(NEC, 0xfd30cf, 32);  // Send out an NEC 0xfd30cf signal

  }

    Receiver11.enableIRIn();
    
    delay(200);

    time = millis();
    Serial.print(time); // prints the time since the program started/
    Serial.println(": Time at end of PROGRAM loop.");
    Serial.println("");
}

So if I write:

IRrecv Receiver11(11); // Create a receiver object to listen on pin 11
IRrecv Receiver12(12); // Create a receiver object to listen on pin 12
IRrecv Receiver13(13); // Create a receiver object to listen on pin 13

The pin that receives info is pin 13. However if I write:

IRrecv Receiver13(13); // Create a receiver object to listen on pin 13
IRrecv Receiver11(11); // Create a receiver object to listen on pin 11
IRrecv Receiver12(12); // Create a receiver object to listen on pin 12

The pin that receives info is 12.

This is inspite of the fact that in the if loop, I’m only calling on Receiver11.

Can anyone tell me why that is?

Thanks,
Tori

You will have to look at the library code for the receiver, but I suspect it is blocking and implementing basically a software uart to receive the data. If it is doing it that way, then while it is waiting for the bits to come in, it is not listening to anything else. To use multiple receivers simultaneously, you would need non-blocking code (not using regular type delay() calls) OR an add on chip with multiple uarts on it so that they handle the receiving of data from the receiver and you only have to read it once the bits have been assembled into a word.

Thanks for this gpsmikey!

Have a look at the website of osepp.com; they have a simple example how to read those sensor's by simple (and non-blocking) code. Just apply it to all of your sensors and continuously read the data in the main loop and avoid any delay() code.

Hello SheCurvesMobius, did you resolve your issue? I have the same problem. In case you figured it out, can you please post your new working code?