How many serial ports are on the Rpi3
I have been playing with serial communication this couple of days. I googled and the found the following tutorial useful.
Raspberry Pi Serial (UART) Tutorial - Roland Pelayo 2018jun22 17,305 Views
I extracted what the author says below:
Technically, the Raspberry Pi has two UARTs: PL011 UART and mini UART.
However, you only have one pair of TXD and RXD pins to work with.
The PL011 UART is the main UART for models without Bluetooth feature
and is tied directly to the Linux console output. This means you can
send Linux commands from your PC to the Raspberry Pi on this UART.
On the other hand, the mini UART becomes the Linux console UART for
models with Bluetooth like the Raspberry Pi 3 and Raspberry Pi Zero W.
For these models, the PL011 UART is tied directly to the Bluetooth
Whichever UART is assigned to the Linux console is accessible through
/dev/serial0. Each UART can be accessed individually via /dev/ttyS0
for the mini UART and /dev/ttyAMA0 for the PL011 UART.
Generally, the PL011 UART is more reliable than the mini UART because
the latter has smaller FIFOs, lacks flow control and has its baud
rate reliant on the VPU clock speed.
My experiment results
I followed Roland Pelayo's instructions and have been doing experiments and found everything works as he suggests.
I used to use four TXS0104 logical level converters to demux one UART channel into 4. I select one one of the four channels by enabling TXS0104 converter I want. It works smoothly, except you can not use more than one UART channel at the same time.
I also tried the USB to TTL adapters for Rpi3B+ Raspbian version 2019Apr. I found both PL2302 and CH340 adapters can be detected without first installing drivers.
In other words, Raspbian version 2019apr already have Pl2303 and CH340 drivers preinstalled.
I also tried the CP2102 USB to TTL adapters, but many CP2102 modules are sadly not compatible to Win10 and ESP8266-12. I have not tried it on Rpi (see update below).
NXP SC16IS750 I2C/SPI to UART Module Not Recommended for Newbies
SparkFun once sold a NXP I2C/SPI to UART module. I thought it too good to be true to be able to have as many UART channels as I wanted. But then I found the datasheet has some "special features" which are perhaps OK for hackers to deal with, but too hard for newbies to handle. I tried hard for a couple of days before giving up. SparkFun has now discontinued this module for a reason.
The other modules AdaFruit are recommending are TXS/TXB0108 modules. I have been using TSX/TSB0104s for demultiplexing UART/I2C/SPI channels and found them OK, if not too greedy to entertain too many channels at the same time. Actually I found many I2C modules (including MCP23017) when grouped more than two, become unstable and difficult to troubleshoot. Perhaps I have not learnt all the tricks in fiddling the I2C pull up resistors. Anyway, trying just one is OK for newbies.
Another thing is that I tested both TSX and TSB versions and found TSB more reliable. I also noticed that AdaFruit only sells TSB now and no loner TSX. This are the puzzles I never solved.
I checked out more than 20 very old USB to TTL adaptors which have been collecting dust for over 10 years. I bought some of them for WinXP and found they no longer working for Win7. I also bouoght some for Win7, and found them no good for Win10. Just now I tried all these old guys for my Rpi3B+ Raspian 2019Apr to see if I had any luck. Surprisingly I found the following:
Bad = 5 (not sure which driver)
Good HL340 = 5
Good PL2302 = 7
AdaFruit TXB0108 8-channel Bi-directional Logic Level Converter - $8.00
TXB0108 Datasheet - TI
TXS0104E Datasheet - TI
Amazon SC16IS750 I2C/SPI to UART Module
SparkFun SC16IS750 I2C/SPI-to-UART Module
SC16IS750 I2C/SPI to UART Datasheet - NXP
The 6 Best Arduino GPS Modules - Josh Darling 2019jan