Problem in Handling with UART

We are using RAK3172 module, We need to use Ultrasonic sensor and GPS (NEO-7M)module using UART. So we connected each modules in UART-1 and UART-2. We also specified everything in code. The problem is, both the modules working at UART-1 only when we tested separately. Why this issue happening? If we specify ultrasonic as UART-2, it is not giving data, when we specified it as UART-1 it’s working, The same happens with GPS also. P.S:I am not connected both the modules is same UART

I tested both modules separately it’s working good, but when i tried to use both in my module using UARTs, either one of them is working. What is the reason?

I tried RAK11720 also, same issue occurring.

UART2 is reserved for AT commands and you cannot use it for a sensor and AT commands at the same time.

You can set UART2 for usage with your sensor by initializing it with Serial.begin(9600, RAK_CUSTOM_MODE); as shown in our documentation.

But then you loose the option to setup the device with AT commands or update the firmware by forcing bootloader mode with AT+BOOT. In this case the only way to update the firmware will be using STM32CubeProgrammer over SWD interface or UART after forcing STM bootloader mode by pulling BOOT0 to VDD.