leoP4
Posts: 6
Joined: Mon Aug 05, 2019 6:58 pm

Pi4 set serial ports UART

Mon Aug 05, 2019 7:25 pm

Hi everyone

I have a problem with the serial ports on the Raspberry Pi4. I created a graphical interface on Processing that uses multiple serial ports simultaneously, sending commands to Arduino Mega.

The serial ports I want to use are those on the GPIOs. I read how to create an additional serial port by editing /boot/config.txt and I added the "dtoverlay = uart2" line, in fact, Processing detects a new serial port / dev / ttyAMA1.

From what I understand, this serial port communicates via GPIO 0 and GPIO 1, for this reason I connected these GPIOs to Arduino Pin 19 RX and 18TX, through a level converter and taking care to cross over the connections.

I tried to change the GPIO setting but I didn't understand if what I did makes sense. I used the command sudo raspi-gpio set 0 a4 ​​in the terminal, but it didn't produce anything.

Could you help me figure out how to configure a serial port so that it communicates from the respective GPIOs? thank you.

danjperron
Posts: 3440
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Pi4 set serial ports UART

Mon Aug 05, 2019 9:43 pm

Hum try something else than uart2. I don't think that GPIO0 is available!

https://www.raspberrypi.org/forums/view ... l#p1506953

leoP4
Posts: 6
Joined: Mon Aug 05, 2019 6:58 pm

Re: Pi4 set serial ports UART

Tue Aug 06, 2019 3:00 am

but after I create the serial ports do I have to set any gpio?

I created the other serial ports but it doesn't change anything. I begin to think that the fault lies with the logic level converter.

danjperron
Posts: 3440
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Pi4 set serial ports UART

Tue Aug 06, 2019 3:26 am

OK now you know that uart2 is not available. You should remove uart2 from the config.


Try uart5! add this line into /boot/config.txt

Code: Select all

enable_uart=1
dtoverlay=uart5
The TX will be GPIO12 and RX GPIO13

B.T.W. uart3 use the same pin than i2c and uart4 the SPI.

The simple method to check if it works will be to install a serial terminal like minicom.

sudo apt update
sudo apt install minicom

Try to connect GPIO12(pin32) and GPIO13(pin 33) together.
Then if you run minicom it should echo what you type. if you break the connection between GPIO12 and GPIO13 it shouldn't work.

Code: Select all

minicom -D /dev/ttyAMA1 -b 9600
If it works then try to connect serial0 with uart5(ttyAMA1). TXD0 to RXD5 and RXD0 to TXD5. Use two terminals with specific minicom on them

The FIrst terminal with the previous minicom command and the second with

Code: Select all

minicom -D /dev/serial0 -b9 600
I assume that you disabled the serial login on serial0.

leoP4
Posts: 6
Joined: Mon Aug 05, 2019 6:58 pm

Re: Pi4 set serial ports UART

Wed Aug 07, 2019 11:21 am

Thanks for the reply

I did what you told me but when you open the minicom screen I can't type anything. But when the serial ports are activated, are the GPIOs of a serial port immediately active to transmit and receive?

danjperron
Posts: 3440
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Pi4 set serial ports UART

Wed Aug 07, 2019 12:34 pm

I found out that uart2 is available but there is some restriction you need to know
https://www.raspberrypi.org/forums/view ... 5#p1514415


Normally if you reboot the Pi and set the uart properly minicom should echo if you short the uart TX ad RX pin together!


First Check the default serial using raspi-config. Disable login,enable seria, quit and reboot

Now connect together GPIO14 & GPIO15. (pin 8 and 10).


using minicom -D /dev/serial0 -b 9600 . The software should echo what you type.

This is the first step.

After that enable uart 5 , connect the RX ad TX pin and do the same with minicom. If you add dtoverlay=uar5 the device should be /dev/ttyAMA1.

If you add another serial then the device will be /dev/ttyAMA2, etc...

leoP4
Posts: 6
Joined: Mon Aug 05, 2019 6:58 pm

Re: Pi4 set serial ports UART

Wed Aug 07, 2019 12:44 pm

I was reading the same post but as I said before when I open minicom I can't type anything!

Return to “Advanced users”