USB to TTL connection to Raspberry Pi
I got curious about the Raspberry Pi serial connection recently so went about getting it to work on mine. It's mostly for fun but I can see the benefit when I want to find out the IP address of my Pi without having a monitor and keyboard on hand. Plus, I this would benefit the classes I plan on running as I may not have extra monitor and keyboard for the classes. The serial connection would be a great start for them to start using the Pi. Below are the steps I did to get it working.
A serial console connection lets you view the entire startup process thus being able to identify any causes of slowdown or problems that could crop up.
These steps are done on Raspbian Stretch.
Enable UART on Raspberry Pi
After flashing the Pi using Etcher, I plugged the MicroSD back to my computer to detect the
boot partition. I edited the
boot/config.txt file to enable serial at the end of the file by adding the
enable_uart=1. It will look like the following
For Raspberry Pi 2
For Raspberry Pi 2, I had to modify the
boot/cmdline.txt file to view the console. I had to change
dwc_otg.lpm_enable=0 console=tty1 root=PARTUUID=34ce222b-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=34ce222b-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
The addition is the entry console=serial0,115200
Connect the serial cable to the Raspberry Pi
I bought this PL2303 USB to serial cable for really cheap online.
Connecting it to the Raspberry Pi was a breeze. Use the following diagram for connecting the PL2303 to the Raspberry Pi.
|PL2303 cables||Raspberry Pi GPIO||Description|
|White||8||Connect the PL2303 RX to the Raspberry Pi TX.|
|Green||10||Connect the PL2303 TX to the Raspberry Pi RX.|
Notice the cross between the PL2303 and the Raspberry Pi TX and RX. The transmission (TX) from the PL2303 goes into the Raspberry Pi receiving (RX) and vice versa.
Do not connect the red cable (5.5V) to the Raspbery Pi unless you wish to power the Pi from the cable. Since I am powering the Raspberry Pi using the Micro USB, I see no need to use the red cable.
Connect to the Raspberry Pi using the serial cable
Now, all that is left is to establish a connection from my computer. Since I'm using Linux, I used
picocom to connect it. The serial connection setting for the Raspberry Pi is as follows
- 115200 baud
- 8 bits
- no parity
- 1 stop bit
- no flow control
NOTE: On My ArchLinux, I had to reboot it while the PL2303 was plugged in for it to be detected.
Typically, the PL2303 will be available on
/dev/ttyUSB0 so make sure it is detected otherwise the proceeding command will not function.
Once it was detected, all I had to do was type the following command and I could see my Raspberry Pi console over serial.
picocom -b 115200 /dev/ttyUSB0
Happy serial-ing. Cheers!