Use Multiple Serial Ports on the STM32F411RE MCU

I am trying to communicate to a lantronix server using serial as well as communicate to a ATMega8 MCU using serial. The issue I have is I don’t know how to open 2 serial ports. I have labelled them “serial” and “serial1” but it doesn’t seem to work. I set them up the same way in the main function with the information below:

serial.baud(9600);
serial.format(8, Serial::None, 1); 

serial1.baud(9600);
serial1.format(8, Serial::None, 1); 

If someone could help it would be greatly appreciated.

the most important part is missing in your snippet: the instantiation of serial/serial1.

Sorry. I had it added but it didn’t copy over.

Serial serial(PA_11, PA_12);
Serial serial1(PA_2, PA_3);

for a Nucleo_F411 e.g. it looks ok, both serial use different uart and the pins are in the pinmap:

But if your board is a STM Nucleo, the Pins PA_2 and PA_3 are usually not connected to the header pins, they are routed to the virtual COM on the STLink. If that is the case, you should use other pins like in the PinMap.
The default setting for the serial is already 8N1 and you can add the baudrate as third argument to the constructor.

Hi;
Dont know about F4 series of Nucleo,but…
I used same port pins in my NUCLEO-64 (STM-32 L476) for UART and it is working.
Try to use library RawSerial instead of serial

UART CODE EXAMPLE LINK