RS232
The Pi-Tron has an RS232 interface connected to uart1. In order to use uart1 the following adjustments have to be made.
Baud rate: 115200
1. Update Raspberry Pi OS
pi@raspberry:~ $ sudo apt-get update
pi@raspberry:~ $ sudo apt-get dist-upgrade
2. Edit the config.txt
pi@raspberry:~ $ sudo nano /boot/config.txt
Enter the following at the end of the file:
### Serial interface
core_freq=250 ## needed for mini-UART
enable_uart=1
dtoverlay=uart1,txd1_pin=40,rxd1_pin=41 ## RS232 on UART1
3. UART and Serial device assignments
The following table shows the relation between the UART, tty and serial devices on the Pi-Tron.
Pi-Tron | Used as | Accessible via | Connector |
---|---|---|---|
uart0 | Console; TTL; RS485 | /dev/ttyAMA0, /dev/serial0 | X800 |
uart1 | Console; TTL; RS485; RS232 | /dev/ttyS0, /dev/serial1 | X900 |
After the activation of a UART on the Pi-Tron, the relation between serial device and tty device can be looked up in the /dev
folder of the OS.
The following command shows which serial device points to which tty device.
pi@pitron:~ $ ls -la /dev/ser*
lrwxrwxrwx 1 root root 7 Feb 14 2019 /dev/serial0 -> ttyAMA0
lrwxrwxrwx 1 root root 5 Feb 14 2019 /dev/serial1 -> ttyS0
In the above listing both Pi-Tron serial devices have been activated. If only one UART device is on then this command will only produce one line as a result or if no UARTs are active, an error will be shown.
Note: After activating a serial device on the Pi-Tron, there could still be an operating system console active on the serial device. To make sure the serial device can be used exclusively by the user, the cmdline.txt
file in the /boot
folder has to be checked.
pi@pitron:~ $ sudo nano /boot/cmdline.txt
Look for the part which reads console=serial0,115200
or console=serial1,115200
and delete it from the cmdline.txt file if it is present. Make sure to not insert any line breaks, all the information in the cmdline.txt has to be on one single line.
Example:
Before, the system console is active on serial0:
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=43c1e3bb-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles
After, the console is now deactivated on all serial devices:
dwc_otg.lpm_enable=0 console=tty1 root=PARTUUID=43c1e3bb-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles
4. Further reading
For more information about the Raspberry Pi serial devices, visit the Raspberry Pi website here: https://www.raspberrypi.org/documentation/computers/configuration.html#configuring-uarts