Raspberry Pi 5 uses the serial port in the same way as any other Pi or Linux computer for that.
And read
https://forums.raspberrypi.com/viewtopic.php?t=105995 for general knowledge and
https://www.waveshare.com/wiki/Raspberry_Pi_Tutorial_Series:_Serial for serial python knowledge