UART
Loopback test
This examples have written based on under the Ubuntu 22.04 and Linux kernel 5.15.0-46-generic
Wire by crossing RX and TX pins.
Download fritzing
- Wiring part(H3) ☞ h3_uart_loopback.fzz
- ODROID-H3 part ☞ odroid-h3.fzpz
Wire pin #10(UART0_TXD) with pin #8(UART0_RXD).
Open two terminal windows
Press Ctrl + Alt + T
Install minicom util
sudo apt install minicom
Read and write characters
In one terminal, read from the ttyS0 with this command.
sudo minicom -D /dev/ttyS0
In the other terminal, write to the ttyS0 with this command.
echo "Hello World" > /dev/ttyS0
Usage RTS/CTS pin as GPIO
RTS (Request To Send): OUTPUT
CTS (Clear To Send): INPUT
Set the RTS pin High(0V) or Low(3.3V)
The RTS pins operate as active low. If you set the RTS to HIGH, it is 0V, if you set it to LOW, it is 3.3V.
import serial # '/dev/ttyS0' uart = '/dev/ttyS0' ser = serial.Serial(uart, 9600) ser.setRTS(1)
Get a value from the CTS pin
import serial # '/dev/ttyS0' uart = '/dev/ttyS0' ser = serial.Serial(uart, 9600) ser.getCTS()