Interfacing Ubuntu and Raspberry Pi via UART Serial
My aim is to establish UART serial communication between raspberry pi to ESP32.
Before that, I want to confirm rpi UART is functional by loopback or connecting to another laptop or not (in my case Ubuntu laptop).
Items needed: Raspberry pi, FTDI USB to TTL Serial Cable, one jumper cable.
Connected FTDI USB side to Ubuntu laptop.
Open Terminal.
dmesg | grep tty
Typically you should see output like dev/ttyUSB0 or dev/ttyUSB1. This means laptop is detecting the TTL cable.
Install minicom
sudo apt update
sudo apt install minicom
configure 'minicom'
goto 'serial port setup' and configure the following
Serial Device: `/dev/ttyUSB0`
Bps/Pas/Bits: 115200
Hardware Flow Control: No
Software Flow Control: No
save the setup and exit.
Other end of TTL cable will have Tx(Green) and Rx(white) pin. connect them with a jumper cable.
Start 'minicom'
sudo minicom
Type something, you should be able to see the echoback, it means all good in laptop side.
Do the same setup in raspberry pi.
Open Terminal.
dmesg | grep tty
Typically you should see output like dev/ttyS0.
Recommended by LinkedIn
Install minicom
sudo apt update
sudo apt install minicom
configure 'minicom'
Goto 'serial port setup' and configure the following
Serial Device: /dev/ttyS0
Bps/Pas/Bits: 115200
Hardware Flow Control: No
Software Flow Control: No
save the setup and exit.
This time connect TTL Tx pin(Green) to Rpi Rx pin(10) and, TTL Rx pin(white) to Rpi Tx pin(8), connect the TTL ground(black) to Rpi Gnd pin(6).
Typing in minicom terminal in laptop should be visible in the terminal running minicom in rpi side and vice versa.
In laptop side, Below command will transmit data "hello" into serial terminal.
echo "hello" > /dev/ttyUSB0
In case of permission error, use "sudo" or "chmod 777 /dev/ttyUSB0"
Below command will display the receive data from raspberry pi
cat /dev/ttyUSB0
some commands like new line, carriage return, backspace wont work. It should be handled in application.
Also, when we tried same thing in windows with putty, some garbage data used to appear. I will post update soon.
Credit: Balaji Sriram R M