41 Ua UART

Element 41 of 86 — The Periodic Table of Robotics

UART

Signals & Comms

Two wires, two directions, one rock-solid link — UART is the classic serial protocol that powers debugging, GPS, and more.

UART has been around since the dawn of microcontrollers, and it’s still one of the first things you reach for when you want two devices to talk. Two wires, a shared baud rate, and you’re off.

What is UART?

UART stands for Universal Asynchronous Receiver-Transmitter. It’s a hardware serial communication protocol that sends data one bit at a time over two lines: TX (transmit) and RX (receive). Cross them over between devices — your TX connects to their RX, and vice versa — and they can exchange data in both directions.

The “asynchronous” part means there’s no shared clock signal. Instead, both sides agree on a baud rate — the speed in bits per second. Common rates are 9600, 115200, and 921600 baud. Get the baud rate wrong and you’ll get garbled nonsense; get it right and data flows cleanly.

A typical UART frame is just a start bit, eight data bits, and a stop bit. That’s it. Beautifully simple.

The crossover wiring

The one rule that trips everyone up: TX connects to RX, not TX to TX. Each device’s transmit line feeds the other’s receive line, and they must share a common ground:

      Device A                     Device B
   ┌───────────┐                ┌───────────┐
   │       TX ─┼────────────────┼─▶ RX      │
   │       RX ◀┼────────────────┼─ TX       │
   │      GND ─┼────────────────┼─ GND      │
   └───────────┘                └───────────┘
        TX → RX (crossed),  GND → GND (common)

One byte on the wire

With no shared clock, both sides must agree on the baud rate in advance. The line idles HIGH, a single LOW start bit wakes the receiver, then 8 data bits follow, finished by a HIGH stop bit:

   idle  start │  8 data bits (LSB first)  │ stop  idle
   ────┐       ┌───┐   ┌───┐       ┌───────┐       ┌────
       │       │ 0 │ 1 │ 0 │ 1 1 0 │ 1   1 │       │
       └───────┘   └───┘   └───────┘       └───────┘
        ↑start                              ↑stop
        bit                                 bit

Get the baud rate wrong and the receiver samples at the wrong moments — that’s why a mismatched setup gives you garbled characters rather than silence.

Why robot builders care

UART is everywhere in robotics. GPS modules, GSM shields, LiDAR sensors, servo driver boards — a huge number of peripherals speak UART because it needs so few pins and works reliably over short cable runs.

It’s also your best friend for debugging. When your robot is misbehaving and you can’t work out why, printing messages over UART to a serial terminal tells you exactly what’s happening inside. On MicroPython, print() goes straight to the REPL over USB-serial — that’s UART under the hood.

Bus servos are a great modern example. The Feetech STS3215 and similar bus servos use half-duplex UART — a single wire handles both TX and RX — to daisy-chain multiple servos on one connection. Each servo has an ID, so the controller can address them individually.

Get started

The Raspberry Pi Pico has two hardware UART peripherals, UART0 and UART1, available on several pin pairs. Here’s the simplest MicroPython setup:

from machine import UART, Pin

uart = UART(0, baudrate=9600, tx=Pin(0), rx=Pin(1))
uart.write("Hello from UART!\n")

if uart.any():
    print(uart.read())

Pick a baud rate, hook up TX-to-RX and RX-to-TX, share a common ground, and start sending.

A solid first project is to wire up a cheap UART GPS module (like the NEO-6M) to your Pico. At 9600 baud it streams NMEA sentences — strings of text containing your position, speed, and time. Parse those and you’ve got a GPS robot on your hands.

For a broader grounding, the Talking to the World — Working with I2C and SPI course covers the neighbouring protocols in detail — understanding all three helps you pick the right bus for the job. And if MicroPython is new to you, Learn MicroPython — the basics is the place to start before diving into hardware communication.

Once you’re comfortable with basic UART, explore half-duplex setups for bus servos, or try logging sensor data to a PC in real time. UART keeps popping up no matter where you look in robotics.

Reacts well with

More Signals & Comms

Learn more on KevsRobots

Courses
Projects to build
Articles to read

Share this element

This page is awesome? Show some love!

Did you find this content useful?


If you found this high quality content useful please consider supporting my work, so I can continue to create more content for you.

I give away all my content for free: Weekly video content on YouTube, 3d Printable designs, Programs and Code, Reviews and Project write-ups, but 98% of visitors don't give back, they simply read/watch, download and go. If everyone who reads or watches my content, who likes it, helps fund it just a little, my future would be more secure for years to come. A price of a cup of coffee is all I ask.

There are a couple of ways you can support my work financially:


If you can't afford to provide any financial support, you can also help me grow my influence by doing the following:


Thank you again for your support and helping me grow my hobby into a business I can sustain.
- Kevin McAleer

What are you looking for?
Watch Videos Get Ideas Learn Something Read a Review Read the Blog Search
... Z Z z