@quangan
Hi Maybe you can refer to this article.

https://www.esp32.com/viewtopic.php?t=276

/* IRda transmitter */ //HardwareSerial Serial1(1); HardwareSerial Serial2(2); // GPIO 17: TXD U2 + GPIO 16: RXD U2 void setup() { Serial.begin (115200); // (USB + TX/RX) to check Serial2.begin(115200); // GPIO 17: TXD U2 + GPIO 16: RXD U2 //UART_CONF0_REG Configuration register 0 //UART0: 0x3FF40020 //UART1: 0x3FF50020 //UART2: 0x3FF6E020 WRITE_PERI_REG( 0x3FF6E020 , READ_PERI_REG(0x3FF6E020) | (1<<16 ) | (1<<10 ) ); //UART_IRDA_EN + UART_IRDA_TX_EN "Let there be light" //Serial.print("Reg: "); Serial.println(READ_PERI_REG(0x3FF6E020),BIN); //For Debug only }//setup void loop() { Serial.println("Hello"); Serial2.println("Hello"); delay(1000); } //loop