aioscilloscope / Learn / Decode a serial signal

Decode a serial (UART) signal with an oscilloscope: an XBee radio, step by step

A serial port sends one bit after another on a single wire. An oscilloscope shows those bits and turns them back into the characters that were sent. Here is how, with a real radio, from the wiring to the decoded answer.

CH1What you need

CH2What a serial character looks like

The line rests high (3.3 V on an XBee). A character starts with a start bit (low), then 8 data bits, lowest first, then a stop bit (high): "8N1", 10 bit times a character.

idlestart0D01D10D20D30D40D50D61D70stop1idle
The letter A (0x41, binary 01000001) as 8N1: the start bit, then D0 to D7 lowest bit first, then the stop bit.

One bit lasts 1 / baud rate: 17.4 µs at 57,600 baud. There is no clock wire: the receiver times every bit from the start bit's falling edge, so the scope triggers on that edge and both ends must agree on the rate. Don't know it? Find the baud rate.

CH3Step by step

  1. Connect the probe. Probe tip on the radio's DOUT (pin 2 on a through-hole XBee) for its replies, ground clip on GND (pin 10). Open a terminal on the PC at the radio's baud rate: ours is 57,600, a new XBee 9600.
  2. Set the channel. CH1 at 1 V/div, DC coupling, probe 10× (the probe's switch at 10× too). Move the trace down so 0 to 3.3 V is on screen.
  3. Trigger on the start bit. Edge trigger, source CH1, slope Falling, level 1.6 V (half the swing): every character starts by pulling the line low.
  4. Pick a time base. 500 µs/div at 57,600 baud (2 ms/div at 9600), the trigger point toward the left edge.
  5. Turn on the decoder. The scope's serial (RS232/UART) decoder: source CH1, threshold 1.6 V, the line idling high, 57,600 baud, 8 data bits, no parity, 1 stop bit, ASCII.
  6. Capture the radio's OK. Press Single, type +++ in the terminal (no Enter) and wait. The radio answers OK, decoded under its bits.
  7. Capture a real answer. Press Single and, within 10 seconds, type ATVR and Enter. The radio answers with its firmware version.

The XBee takes commands only in command mode: one second of silence, +++, another second of silence, and it answers OK. Commands are AT plus two letters, ended by Enter (Digi's XBee-PRO S3B user guide, 90002173). Other devices: send them any text.

CH4Both directions at once

Probe each direction on its own pin: CH1 on DOUT as the decoder's Tx, CH2 on DIN as its Rx, both at 1.6 V, and trigger on CH2. The decoder shows your command, then the radio's answer.

On Digi's XBee Grove Development Board, probe header J3 (Digi's user guide 90001457):

XBeeModuleU1J3J1J2J4Grove DIO12Grove DIO1/DIO11/I2CGrove DIO4Grove PWM0Grove AD0/CBGrove AD2RXTXRSSIAssociateUser LEDOn/sleepResetCommissioningUser ButtonPotentiometerUSBBatteryLoopbackUARTLoopbackP11CH1 tip: J3 pin 2, DOUTthe radio's replies: decoder TxCH2 tip: J3 pin 3, DINcommands to the radio: decoder Rxboth ground clips: J3 pin 10, GNDpin 1 (square pad) is 3.3 VJ3 comes as empty holes: solderin a 10-pin 2.54 mm (0.1") header.The XBee's own 2 mm sockets (J1, J2)are too fine for two probe hooks.Keep the P11 jumper on UART.
Probing both directions on Digi's XBee Grove Development Board: CH1 on J3 pin 2 (DOUT), CH2 on J3 pin 3 (DIN), both ground clips on J3 pin 10 (GND), the P11 jumper on UART.

If the decode looks wrong

What you seeWhat to change
"Waiting for a trigger"Nothing was sent while armed, or the level is outside the swing. Arm first, then send (why).
Wrong characters, error marksThe baud rate is wrong: measure it, or use the decoder's Auto setting if it has one.
Every character wrong at the right rateInverted polarity. Logic-level UART idles high (Positive); a real RS-232 port idles negative (Negative, threshold near 0 V).
Garbled at a slow time baseToo few samples a bit: use a faster time base or deeper memory.
A small 60 Hz wave, no charactersThe probe is not on the line, or the device is off: that is mains hum.

Questions

Can any oscilloscope decode UART?

Any scope shows the bits, and you can read them by eye from the start bit, lowest bit first. A serial decoder writes the characters for you.

What is the difference between UART, TTL serial and RS-232?

A UART on a circuit board swings between 0 V and 3.3 V or 5 V and rests high (TTL serial). RS-232 is a cable standard whose resting line is negative. Same characters; different polarity and threshold.

Which pin do I probe, TX or RX?

The TX of the device you want to read. On a through-hole XBee that is DOUT, pin 2.

More to try

Every guide