In this section, you will learn how to use the serial port of your Raspberry Pi. The serial port of Raspberry Pi is often used to access the shell. However, in some condition you just wanna use it to communicate with UART peripherals. You can disable shell and kernel messages on the serial connection via Raspberry Pi configuration tool: sudo raspi-config Select Advanced Options - Serial - to disable shell and kernel messages on the serial connection. Then edit the /boot/config.txt file and append: enableuart=1.
Jump to Glitch when opening serial port - If you wish to connect your Raspberry Pi to a PC with a USB port, the simplest option is to use a USB-to-serial cable which uses 3.3 V logic levels (e.g. The Adafruit 954 cable, the FTDI TTL-232R-RPI cable, or the Debug Buddy ultimate serial port). Created| Configure the serial port on Raspberry Pi 3 and Raspberry Pi Zero W with a Serial Pi. You can use the Serial Pi Plus and Serial Pi Zero with your Raspberry Pi 3 or Raspberry Pi Zero W if you disable the built in Bluetooth modem as this is mapped to the hardware UART by default and the 'mini uart' on the Raspberry Pi 3.
. To receive data, connect the GPIO 15 (UART0RXD) pin on the Raspberry Pi board to the TxD pin on the serial device. To transmit data, connect the GPIO 14 (UART0TXD) pin on the Raspberry Pi board to the RxD pin on the serial device. Connect a ground pin, GND, on the Raspberry Pi board to the GND pin on the serial device. Connect a +3.3V pin on the Raspberry Pi board to the VCC pin on the serial device. Before continuing, research the manufacturer’s product information to determine which baud rate, data bits, parity, and stop bit settings the serial device supports.
Use serialdev to create a connection to the serial device and assign the connection to a handle.