FastLED library Interfereing with the RMT peripheral of the ESP 32

Hi.

I am trying to create a IR receiver with an ESP 32 Using Onboard RMT peripheral for the receiving.
I am also using 12 neopixels whose colours i want to change with the remote. I am using FastLED Library for the neopixels code.

Now my problem is fastled and RMT RX confing are not working together. My esp32 is panicking while initializing of the ir receiver.

I can confirm that this is only happening with the FastLED library,Not with the Adafruit neopixel library.
But i can not use the Adafruit neopixel library (as it has some other issues.)

I can also confirm that this is only happening with the RMT peripheral in RX mode. as i tried using the RMT peripheral in TX mode and everything worked, esp32 did not panic.

I also know that fastLed has an option for RMT peripheral for driving the neopixels, but i am not using it.

Here is my code

#include "ESP32_IR_Rx_m.h"
#include "ESP32_IR_Tx_m.h"
#include "ESP32_IR_Rx_m_prox.h"


int flag = 0;
ESP32_IRtrans irtrans(GPIO_NUM_5, RMT_CHANNEL_1);
ESP32_IRrecv irrecv38(GPIO_NUM_33, RMT_CHANNEL_3);
//ESP32_IRprox prox56(GPIO_NUM_34, RMT_CHANNEL_6); //56 KHZ IR receiver
uint8_t cmd = 0; //Stores receiverd  Hex Value from Remote

#include <FastLED.h>
#define NEO_PIX_PIN 2

#define NUM_OF_LEDS 12
CRGBArray<NUM_OF_LEDS> leds;   // leds array


//void tx(void *)
//{
//  while (1)
//  {
//    irtrans.sendIR(0x72); //Send 0x18
//    Serial.println("Sending...");
//
//  }
//  vTaskDelete(NULL);
//}

//void rx(void *)
//{
//  while (1)
//  {
//    cmd = irrecv.readIR(); //Start Reading IR values
//
//    if (cmd != 0)
//    {
//      Serial.print("Command Recieved: 0x");
//      Serial.println(cmd, HEX);
//
//      if (cmd == 0x18)
//      {
//
//        Serial.println("Obstacle Detected");
//      }
//
//
//    }
//  }
//  vTaskDelete(NULL);
//}


void rx38()
{
  flag = 1;
}

void setup()
{
  Serial.begin(115200);
  delay(1000);
  FastLED.addLeds<WS2813, NEO_PIX_PIN>(leds, NUM_OF_LEDS);   // Object created
  FastLED.setBrightness(50);
  FastLED.show(); // Initialize all pixels to 'off'
  Serial.println("Initializing...");
  Serial.println("Initializing. RX");
  attachInterrupt(digitalPinToInterrupt(GPIO_NUM_33), rx38, FALLING); // attaching interrupt to the reveiver Pin
  //  prox56.init(); //Initialising Reciever
  Serial.println("Initializing. TX");
  irtrans.nec_tx_init(); //Initialising Transmitter
  Serial.println("Initializing. RX38");
  irrecv38.init(); //Initialising Reciever

  Serial.println("Init Complete!");

  //  xTaskCreatePinnedToCore(tx, "transmit", 10000, NULL, 1, NULL,0);
  //  xTaskCreatePinnedToCore(rx, "reciever", 10000, NULL, 1, NULL,0);
  //  xTaskCreate(tx, "transmit", 10000, NULL, 1, NULL);
  //  xTaskCreate(rx, "reciever", 10000, NULL, 1, NULL);
  //  vTaskStartScheduler();
}


void loop()
{

  //  // irtrans.sendIR(0x72); //Send 0x18
  if (flag)
  {
    cmd = irrecv38.readIR(); //Start Reading IR values

    if (cmd != 0)
    {
      Serial.print("38Command Recieved: 0x");
      Serial.println(cmd, HEX);

      if (cmd == (uint8_t)0x16)
      {
        //noInterrupts();
        Serial.println("inside turn on");
        leds[0] = CRGB(255, 255, 255);
        FastLED.show();
        //interrupts();
      }
      else if (cmd == (uint8_t) 0x19)
      {
        //noInterrupts();
        Serial.println("Inside turn off");
        leds[0] = CRGB(0, 0, 0);
        FastLED.show();
        //interrupts();
      }
    }
    flag = 0;
    cmd = 0;
  }
}

And i have also attached header files for RMT Configs

my stack trace suggests that there is an issue while installing rmt_driver_isr()

here are my logs

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1100
load:0x40078000,len:9296
load:0x40080400,len:6364
entry 0x400806a4
Initializing...
Initializing. RX
Initializing. TX
Initializing. RX38
port = 
3
Checking COnfig
Checking driver install
ESP_ERROR_CHECK failed: esp_err_t 0x105 (ESP_ERR_NOT_FOUND) at 0x40087370
file: "C:\Users\user\AppData\Local\Temp\arduino_build_568105\sketch\ESP32_IR_Rx_m.cpp" line 151
func: void ESP32_IRrecv::init()
expression: rmt_driver_install(config.channel, 5000, 0)

Backtrace: 0x40086e90:0x3ffb1ef0 0x40087373:0x3ffb1f10 0x400d0de0:0x3ffb1f30 0x400d11a9:0x3ffb1f80 0x400e80ff:0x3ffb1fb0 0x4008af85:0x3ffb1fd0

and here is my decoded stack traces

0x40086e90: invoke_abort at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/esp32/panic.c line 155
0x40087373: _esp_error_check_failed at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/esp32/panic.c line 713
0x400d0de0: ESP32_IRrecv::init() at C:\Users\user\AppData\Local\Temp\arduino_build_568105\sketch\ESP32_IR_Rx_m.cpp line 151
0x400d11a9: setup() at C:\Work\MyFirstProject\Basic_Testing\Test_Codes\Proximity\IR_txrx_with_fastled/IR_txrx_with_fastled.ino line 73
0x400e80ff: loopTask(void*) at C:\Arduino\hardware\espressif\esp32\cores\esp32\main.cpp line 15
0x4008af85: vPortTaskWrapper at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/freertos/port.c line 143

IR_txrx_with_fastled.zip (12.4 KB)

Thank you for your help guys !!!

I figured it out.

So fastled driver takes control over rmt peripherals. this causes an issue with other devices that want to use rmt driver.

To remove this issue you can define this macro before including the Fastled Library .

#define FASTLED_RMT_BUILTIN_DRIVER 1
#include<FastLED.h>

This macro will use all the rmt channels available.
so before installing your own rmt driver you have to only uninstall the driver present on the channel you want to use ,using the following function.

rmt_driver_uninstall(rmt_channel_you_want_to_use);

Then you can install your own driver and use rmt as you want.
more details can be found here.
source

unfortunately it doesn't work for me.

after booting it says : No RMT driver for this channel.
then it initialize my stuff and prints: RMT driver already installed for channel
it writes a backtrace and reboots ....

i think i did it as you said:

#define FASTLED_RMT_BUILTIN_DRIVER 1
#include <FastLED.h>
....

rmt_driver_uninstall(RMT_CHANNEL_0);
irrecv.ESP32_IRrecvPIN(PIN_RECV,0);

it would be nice to solve this....

sorry - it was another problem. this solution works perfectly!

unfortunately - this was too early.

the ir library receives a code with a length of 75 bytes. this works 7 times, after that i can't receive any ir-data.
if i don't start any leds with fastled it works...

there might be a problem with the rmt ringbuffer. make sure it gets cleared.