UART
Pin# | Pin Label | dev node | Pin# | Pin Label | dev node |
---|---|---|---|---|---|
3 | UART2_TXD | /dev/ttyS1 | 8 | UART1_RXD | /dev/ttyS0 |
5 | UART2_RXD | 10 | UART1_TXD | ||
7 | UART2_RTS | 12 | UART1_CTS | ||
9 | UART2_CTS | 14 | UART1_RTS |
Loopback test
Wire by crossing RX and TX pins.
Download fritzing
- Wiring part(H2) ☞ loopback_uart_h2.fzz
- Wiring part(H2+) ☞ h2plus_loopback_uart_h2.fzz
- ODROID-H2 part ☞ odroid-h2.fzpz
- ODROID-H2+ part ☞ odroid-h2plus.fzpz
Wire pin #3(UART2_TX) with pin #8(UART1_RX) and pin #5(UART2_RX) with pin #10(UART1_TX).
Open two terminal windows
Press Ctrl + Alt + T
Grant tty access to user
sudo usermod -aG dialout $USER sudo reboot
Configure your tty devices
Enter these commands to set the baud rate to 9600, 8 bits, 1 stop bit, no parity
stty -F /dev/ttyS0 9600 cs8 -cstopb -parenb stty -F /dev/ttyS1 9600 cs8 -cstopb -parenb
Read and write characters
In one terminal, read from the ttyS0 with this command.
cat /dev/ttyS0
In the other terminal, write to the ttyS1 with this command.
echo "123" > /dev/ttyS1
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' or '/dev/ttyS1' uart = '/dev/ttyS0' ser = serial.Serial(uart, 9600) ser.setRTS(1)
Get a value from the CTS pin
import serial # '/dev/ttyS0' or '/dev/ttyS1' uart = '/dev/ttyS0' ser = serial.Serial(uart, 9600) ser.getCTS()