I am trying to connect 2 IR receiver on 2 different data pins of esp32

look at their example

Si I would say (never tried) that you just need two instances for

IRRecv frontReceiver;
IRRecv backReceiver;

may be something like this

#include <IRRecv.h> // https://github.com/open-laser-tag/IR32/tree/94e7e7e883904f58c59e90d74d51ca19b418db45
IRRecv frontReceiver;
IRRecv backReceiver;

const byte frontRxPin = 16;
const byte backRxPin = 17;


void setup() {
  Serial.begin(115200);
  frontReceiver.start(frontRxPin);
  backReceiver.start(backRxPin);
}

void loop() { 
  while(frontRxPin.available()){
    char* rcvGroup;
    uint32_t result = frontReceiver.read(rcvGroup);
    if (result) {
        Serial.printf("Front Received: %s/0x%x\n", rcvGroup, result);
    }
  }  

  while(backReceiver.available()){
    char* rcvGroup;
    uint32_t result = backReceiver.read(rcvGroup);
    if (result) {
        Serial.printf("Back Received: %s/0x%x\n", rcvGroup, result);
    }
  }
}

(typed here based on their example)

I already tried this. Using this only last defined pin works.
If we see in this code, receiver connected on 17 no. pin will receive only.

are you really using IRRecv.h from this

(add the files to your project)

1 Like

Looking a bit into the library I see the constructor actually expects an RMT channel

The default is RMT_CHANNEL_0 so that's why It would not work as you would get RMT_CHANNEL_0 twice

Try this

#include "driver/rmt.h"
#include <IRRecv.h> // https://github.com/open-laser-tag/IR32/tree/94e7e7e883904f58c59e90d74d51ca19b418db45
IRRecv frontReceiver(RMT_CHANNEL_0);
IRRecv backReceiver(RMT_CHANNEL_1);

const byte frontRxPin = 16;
const byte backRxPin = 17;


void setup() {
  Serial.begin(115200);
  frontReceiver.start(frontRxPin);
  backReceiver.start(backRxPin);
}

void loop() { 
  while(frontRxPin.available()){
    char* rcvGroup;
    uint32_t result = frontReceiver.read(rcvGroup);
    if (result) {
        Serial.printf("Front Received: %s/0x%x\n", rcvGroup, result);
    }
  }  

  while(backReceiver.available()){
    char* rcvGroup;
    uint32_t result = backReceiver.read(rcvGroup);
    if (result) {
        Serial.printf("Back Received: %s/0x%x\n", rcvGroup, result);
    }
  }
}

the first include is just so that your code knows about the various RMT channels

Hello everyone,
I am trying to use RMT of ESP32 to receive IR signal. Actually I already tried to receive through IR receivers using IRremote library, but the issue with library is, it doesn't support multiple IR receivers on multiple data pins and for that someone suggested me to use RMT. But I am newbie to RMT I don't have any clue from where to start or to write a single line of code for that. If anyone can help me in this, it will be very helpful for me.
Thanks in advance

I have merged your topics due to them having too much overlap on the same subject matter @muskan_jhawar .

In the future, please only create one topic for each distinct subject matter and be careful not to cause them to converge into parallel discussions.

The reason is that generating multiple threads on the same subject matter can waste the time of the people trying to help. Someone might spend a lot of time investigating and writing a detailed answer on one topic, without knowing that someone else already did the same in the other topic.

Thanks in advance for your cooperation.

I moved the conversation in programming questions as it's more a programming issue than an hardware one

@muskan_jhawar please never again double post if you want any help from me. I hate loosing my time.

I am really sorry for the inconvenience, I am new to forum and I am not aware when 2 separated forums were created. And Thankyou so much for your help

1 Like

It finally works now I am able to receive on multiple pins just after making few changes in the library. I am attaching zip file of library after modifications and my working code as well.
IR32.zip (8.7 KB)

#include "driver/rmt.h"
#include <IRRecv.h> // https://github.com/open-laser-tag/IR32/tree/94e7e7e883904f58c59e90d74d51ca19b418db45
IRRecv frontReceiver(RMT_CHANNEL_0);
IRRecv backReceiver(RMT_CHANNEL_1);
IRRecv leftReceiver(RMT_CHANNEL_2);

const byte frontRxPin = 16;
const byte backRxPin = 17;
const byte leftRxPin = 39;


void setup() {
  Serial.begin(115200);
  frontReceiver.start(frontRxPin);
  backReceiver.start(backRxPin);
  leftReceiver.start(leftRxPin);
}

void loop() { 
  while(frontReceiver.available()){
    char* rcvGroup;
    uint32_t result = frontReceiver.read(rcvGroup);
    if (result) {
        Serial.printf("Front Received: %s/0x%x\n", rcvGroup, result);
    }
  }  

  while(backReceiver.available()){
    char* rcvGroup;
    uint32_t result = backReceiver.read(rcvGroup);
    if (result) {
        Serial.printf("Back Received: %s/0x%x\n", rcvGroup, result);
    }
  }
    while(leftReceiver.available()){
    char* rcvGroup;
    uint32_t result = leftReceiver.read(rcvGroup);
    if (result) {
        Serial.printf("left Received: %s/0x%x\n", rcvGroup, result);
    }
  }
}

Thankyou so much for your help and efforts.

Sorry for the inconvenience, I am new to forum and was not aware about this. Such mistakes will not happen in future.

1 Like

Thanks for coming back with your working code - will help someone else one day for sure

1 Like

"I am facing a new issue within the same topic. While my three individual receivers are functioning properly, upon integrating a transmitter into the code and attempting to send data from the transmitter to be received by the other receivers on the same system, I am encountering difficulties. Although the entire setup operates smoothly on a single system, the receivers are failing to receive data transmitted by their own system's transmitter. I've verified that the receivers function correctly when paired with another system's transmitter. Could you provide insights into the cause of this issue?"

#include "driver/rmt.h"
#include <IRRecv.h> // https://github.com/open-laser-tag/IR32/tree/94e7e7e883904f58c59e90d74d51ca19b418db45
#include <IRSend.h> 
#define Trig 34

IRRecv leftReceiver(RMT_CHANNEL_2);
IRRecv frontReceiver(RMT_CHANNEL_3);
IRSend irsend(RMT_CHANNEL_1);

const byte frontRxPin = 16;
const byte leftRxPin = 39;
const byte TxPin = 15;

String receivedvalue;

void setup() {
  Serial.begin(115200);
  frontReceiver.start(frontRxPin);
  leftReceiver.start(leftRxPin);
  irsend.start(TxPin, "NEC");
  pinMode(Trig, INPUT_PULLUP);
}

void loop() { 
    if (digitalRead(Trig) == 0) {
    Serial.println("Data sent");
    irsend.send(0xBCDEF987);
  }
  if (frontReceiver.available()) {
    char* rcvGroup;
    uint32_t result = frontReceiver.read(rcvGroup);
    if (result) {
      receivedvalue = String(result, HEX);
      receivedvalue.toUpperCase(); 
      Serial.printf("Front Received: %x\n", result); 

    }
//    frontReceiver.clearBuffer();
    // Stop IR receiver after reception
//    frontReceiver.stop();
  }
    if (leftReceiver.available()) {
    char* rcvGroup;
    uint32_t result = leftReceiver.read(rcvGroup);
    if (result) {
      receivedvalue = String(result, HEX);
      receivedvalue.toUpperCase(); 
      Serial.printf("left Received: %x\n", result); 
    }
//    leftReceiver.clearBuffer();
  }
}

And additionally when transmitted from other system, receivers will receive 5-10 package and after that I have spam of this message on my serial monitor
E (29403) rmt: RMT RX BUFFER FULL

Even i realised program stucks after irsend.send command was executed it again starts after 8-9 seconds of delay.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.