1

I am trying to use the second serial port. In /boot/config.txt I have put at the end :

# swap UARTs
dtoverlay=pi3-miniuart-bt
dtoverlay=uart2
enable_uart=1

I have checked and re-checked the pin connections. Uart 2 is on GPIO 0 and 3. Still cant receive anything from an arduino on the other side. Is there some configuration missing ?

dlsa
  • 111
  • 1
  • 3

2 Answers2

2

I use the following settings:

dtoverlay=uart2
dtoverlay=uart3

dtoverlay=pi3-miniuart-bt enable_uart=1

They give access to uart2 (on GPIO 0 and 1) and uart3 (on GPIO 4 and 5). Bluetooth works, and the default UART on GPIO 14 and 15 is available as well.

PMF
  • 886
  • 7
  • 13
0

The BCM2711 has 6 UART (of which 4 are usable on the Pi4).

See How do I make serial work on the Raspberry Pi3 or later
Raspberry Pi4 UART

Milliways
  • 59,890
  • 31
  • 101
  • 209
  • Even though pins 0 and 1 are officially reserved, they can be used freely if no HAT is being used that has an EEPROM. I've been using UART2 for a long time without any issues now. – PMF Oct 06 '21 at 09:31
  • @PMF I concede that this appears to work, as I just tried on my Pi4. I have not actually used as a serial port (I see no need - there are so many other options for serial which don't ignore the reserved status) but status reports say it is UART2 on /dev//dev/ttyAMA1. My attempts to use GPIO0/1 for other purposes have failed. – Milliways Oct 06 '21 at 11:32
  • I didn't try them as GPIO for instance, so you might be right there. I decided to use UART2 (and UART3) because it used only pins I wasn't using otherwise (namely SPI0 and Pwm). My project uses quite a bunch of pins. – PMF Oct 06 '21 at 12:39
  • I had the pins wrong. somewhere I saw uart2 gpio 0 and 3. Tried with 0 and 1, but nothing. Then tried uart3, got it to work at the start. After successive uses of the serial ports, now the reads block on serial port 1, when I have configured non-blocking reads. What could be the problem ? Do serial ports "jam" ? – dlsa Oct 06 '21 at 21:51
  • OK, I disconnected the Pi and the two arduinos that are talking to it from the power. Ran my software, and it works. How can I make this work permanently ? – dlsa Oct 06 '21 at 21:55
  • @dlsa DO NOT ask new questions in Comments - edit your Question. – Milliways Oct 06 '21 at 23:17