UART to the rescue!


So imagine your shiny new Raspberry Pi is plugged in but you can't communicate with it.  You see blinking lights and it appears to be functional but SSH, Telnet, web interface, etc. isn't working and now you're at a loss to figure out why.  This sounds like a job for... UART!

Universal Asynchronous Receiver-Transmitter allows you to communicate directly with the device over a serial connection.  Anyone younger than 40 probably has no idea what a serial connector is but way back in the computing dark ages it was a common cable connector type:


The connector port is long since gone but the underlying system for communicating with a device over a serial connection remains.  The "modern" version uses USB:


It's a little complicated so I thought I'd document my process with a ZeroPi:

1.  Connect Wires to Adapter

The wires with black ends pictured above are called Dupont connectors or jump wires.  They're just wires that don't require soldering to connect.  You'll need to attach four of them to the USB adapter by pushing them onto the metal pins sticking out the end opposite the USB connector.  You'll notice, however, there are five Dupont connectors and five metal pins on the adapter.  This is because the adapter shown above supports both 3.3 volt and 5 volt boards.  You'll need to consult your board manufacturer documentation to determine which voltage is correct for your board.  Raspberry Pi uses 3.3V and my ZeroPi uses 5V.  So, in my example, I pushed Dupont connectors onto the following adapter pins:
    • GND (ground)
    • TXD
    • RXD
    • +5V   <--  IMPORTANT: double-check your specific board to choose between 3.3 and 5 volt
2. Connect Wires to Board

Okay, so we now have a USB UART adapter with four wires connected to it.  Now you'll need to plug the other ends of those wires into your board.  Your board manufacturer should provide a schematic of UART pinsIMPORTANT: plug the TX wire from your adapter into the RX pin on your board and plug the RX wire from your adapter into the TX pin on your board.  This is because when the USB device transmits data (TX) you want the board to receive it (RX) and vice versa.  Other than the voltage selection, this is the trickiest thing to remember.


3. Install Serial Software

We'll need software on our computer to enable serial communication (since we don't have a serial port it will act as a "pretend serial port").  I recommend picocom:

sudo apt install -y picocom

4. Plug in USB Adapter (not the wall plug for the device)

Plug in your USB adapter and run: dmesg

You should see something like: [1113.310173] usb 1-8: cp210x converter now attached to ttyUSB0

If not:
  1. run lsusb
  2. look for your board in the list and note the vendor and product value
  3. run sudo modprobe usbserial vendor=0x067b product=0x2303   <-- replace the values in red with your vendor and product values
  4. unplug and replug in USB adapter
5. Login to Device

Run the following command, replacing the value in red with the baud rate (in bps) for your board:

sudo picocom -b 115200 -r -l /dev/ttyUSB0


When you see Terminal ready hit ENTER and you will be given a login prompt on the device. Yay!

Comments

Popular Posts