Core Networking · Study deck

UART and RS-232 Protocols

A sensor console prints nonsense when connected to a legacy instrument.

Packet Pete is your guide for this deck.

wiredcommuart
iotclass.org

After studying this chapter

Learning objectives

You will be able to:

  • Explain: The scale on the left of Figure: RS-232 uses inverted high-voltage signaling runs from plus fifteen volts to minus fifteen, and the two logic bands sit at its extremes.
  • Explain: A serial record should preserve connector gender, viewpoint, pin numbers, signal direction, and cable type, because a continuity test can pass while a mirrored interpretation still swaps TX and RX.
  • Explain: The serial-link record below must name each endpoint, the viewed side of the pinout, voltage standard, and any flow-control wires, then verify them on the actual link.
RS-232 uses inverted high-voltage signaling; it must be translated before it reaches normal 3.3 V or 5 V microcontroller UART pins.
RS-232 uses inverted high-voltage signaling; it must be translated before it reaches normal 3.3 V or 5 V microcontroller UART pins.
iotclass.org

Major section

Start With Two Devices Sending Bytes

A microcontroller means a small computer on one chip that reads inputs and controls a device.

  • UART is the simplest useful story for many devices: one side sends timed bits, the other samples them, and both must agree on framing and speed.
  • That simplicity is why UART is common for consoles, sensors, modules, and debugging.
  • It also means the evidence must be practical: voltage level, ground reference, baud rate, framing, and what each received byte is supposed to mean.
Connector diagrams must state the viewing side. Mirrored DB9 views are a common source of swapped TX/RX pins.
Connector diagrams must state the viewing side. Mirrored DB9 views are a common source of swapped TX/RX pins.
iotclass.org

Major section

Overview: UART Sends Bytes Without A Clock Wire

The line rests high while nothing is being sent.

  • The start bit is a single low, and it exists only to mark the moment the receiver should begin counting.
  • An optional parity bit sits after them, then one or two stop bits return the line to its idle level, ready for the next byte.
  • The whole of Figure: UART frame diagram moves from idle-high line to is therefore an agreement made in advance.
UART frame diagram moves from idle-high line to a low start bit, five to nine data bits, optional parity and one or two stop bits.
UART frame diagram moves from idle-high line to a low start bit, five to nine data bits, optional parity and one or two stop bits.
iotclass.org

Major section

Overview: UART Sends Bytes Without A Clock Wire (continued)

Both ends must already share the bit rate and the frame shape, or the bits are counted in the wrong places.

  • The line begins idle, then the falling start bit gives the receiver a timing reference.
  • It samples the data bits near their centres using its own baud-rate clock, optionally checks parity, and expects a stop bit at the idle level.
  • For an 8-N-1 frame, eight data bits plus start and stop make 10 bits; at 9600 bit/s, one frame takes 10 / 9600 s = 1.04 ms.
UART trades addressing and shared-clock features for a simple point-to-point byte stream.
UART trades addressing and shared-clock features for a simple point-to-point byte stream.
iotclass.org

Major section

Practitioner: Keep A Serial Link Record

Positive means zero here and negative means one, the reverse of the convention a microcontroller pin uses.

  • The photo shows several DB9/RJ45 adapter pieces beside a handwritten pinout note.
  • A connector shape and a handwritten note do not prove which pins the installed peer uses.
  • Two results follow, and both belong in the link record.

Why it matters

A serial record should preserve connector gender, viewpoint, pin numbers, signal direction, and cable type, because a continuity test can pass while a mirrored interpretation still swaps TX and RX.

Real photograph of db9 rs-232 connector/cable
Real photograph of db9 rs-232 connector/cable
iotclass.org

Major section

Practitioner: Keep A Serial Link Record (continued)

The serial-link record below must name each endpoint, the viewed side of the pinout, voltage standard, and any flow-control wires, then verify them on the actual link.

  • That single fact settles what each end can mate with, and it is not visible in any wiring diagram.
  • Contact gender, retention and installed length are three entries the link record needs, and the name RS-232 supplies none of them.
  • The scale on the left of Figure: RS-232 uses inverted high-voltage signaling runs from plus fifteen volts to minus fifteen, and the two logic bands sit at its extremes.
A coiled DB9 serial cable shows two female nine-contact connectors, metal shells, thumbscrews and molded strain relief. Record installed length and pinout before swapping TX and RX. Photo: David Marsh, CC BY 2.0
A coiled DB9 serial cable shows two female nine-contact connectors, metal shells, thumbscrews and molded strain relief. Record installed length and pinout before swapping TX and RX. Photo: David Marsh, CC BY 2.0
iotclass.org

Major section

Practitioner: Keep A Serial Link Record (continued)

Between them lies a band around zero that decodes to nothing at all, so noise landing there is simply undefined.

  • A level shifter is needed before any 3.3 or 5 volt pin, and the wide swing is what buys this link its noise tolerance over roughly fifteen metres.
  • Handshake lines must be crossed or intentionally omitted according to the configured flow control.
  • A serial record should preserve connector gender, viewpoint, pin numbers, signal direction, and cable type, because a continuity test can pass while a mirrored interpretation still swaps TX and RX.
iotclass.org

Major section

Under The Hood: Timing Error Accumulates Across The Frame

A start bit tells the receiver when to sample the data bits, and stop bits check the end of the frame.

  • USB adds a host, device setup, named end points, framed moves, and error checks.
  • An adapter links the two systems, but it does not make their voltage, pins, flow control, or UART settings the same.
  • No protocol is named and no property is scored.
Asynchronous serial links depend on both endpoints keeping close enough timing until the stop bit is sampled.
Asynchronous serial links depend on both endpoints keeping close enough timing until the stop bit is sampled.
iotclass.org

Major section

Separate a Framing Error from a Voltage Mismatch

At 19,200 bits per second, one bit lasts about 52.08 microseconds and a full frame takes about 520.8 microseconds.

  • A 64-byte record takes about 33.33 ms without gaps.
  • Its nominal bit period is about 104.17 microseconds, twice the transmitter's.
  • Timing and wiring are separate checks.

Key terms

Adding a shared clock
Adding a shared clock is not the remedy; servicing the buffer or controlling the source rate addresses the observed failure.
A receiver synchronizes on the start bit, samples the data bits by timing, optionally checks parity, then waits for the stop bit.
A receiver synchronizes on the start bit, samples the data bits by timing, optionally checks parity, then waits for the stop bit.
iotclass.org

Major section

Separate a Framing Error from a Voltage Mismatch (continued)

The next byte needs space or an explicit overflow policy.

  • It samples the incoming signal on the wrong time scale, so clean voltage transitions cannot produce the intended byte stream.
  • The receiver uses that transition to establish timing for one frame.
  • This module makes serial troubleshooting a sequence of measurable boundaries.
iotclass.org

Major section

Separate a Framing Error from a Voltage Mismatch (continued)

The wiring figure at Figure: UART frame diagram moves from idle-high line to then connects transmit to receive with the required reference.

  • RS-232 signalling needs the appropriate electrical interface; direct connection to a low-voltage UART pin can be unsafe for the component.
  • For example, an incoming 64-byte burst fills a 64-byte receive buffer completely if nothing is removed during that interval.
  • Adding a shared clock is not the remedy; servicing the buffer or controlling the source rate addresses the observed failure.
UART frame diagram moves from idle-high line to a low start bit, five to nine data bits, optional parity and one or two stop bits.
UART frame diagram moves from idle-high line to a low start bit, five to nine data bits, optional parity and one or two stop bits.
iotclass.org

Deck summary

Key takeaways

A microcontroller means a small computer on one chip that reads inputs and controls a device.

  • The line rests high while nothing is being sent.
  • Both ends must already share the bit rate and the frame shape, or the bits are counted in the wrong places.
  • Positive means zero here and negative means one, the reverse of the convention a microcontroller pin uses.
  • The serial-link record below must name each endpoint, the viewed side of the pinout, voltage standard, and any flow-control wires, then verify them on the actual link.
iotclass.org

Retrieval practice

Recall check 1 of 3

Packet Pete says: answer from memory, then check your reasoning.

Q1A 3.3 V irrigation controller must read a water-meter module whose data sheet says 9600 baud, 8N1, TTL UART over a short harness. What must the release record prove before the field board is approved?

ARecord bench baud alone and let the controller infer voltage and wiring at startup.
BCheck a device address, as though UART provides I2C-style bus addressing.
CProve matching baud, 8N1, voltage, crossed TX/RX, and shared ground on the field harness.
DCheck a clock wire, as though UART uses a shared synchronous clock.
Show answer

Answer: C A working UART link requires matching timing, framing, electrical compatibility, physical wiring, and the actual installed harness.

iotclass.org

Retrieval practice

Recall check 2 of 3

Packet Pete says: answer from memory, then check your reasoning.

Q2A 3.3 V microcontroller must read a legacy device with a DB9 connector labeled RS-232. What is the safest next step?

AConnect DB9 TX directly to the 3.3 V pin because both links are serial.
BRaise baud rate to reduce exposure to the legacy signal voltage.
COmit ground because RS-232 uses positive and negative signaling.
DConfirm pinout and add an RS-232-to-TTL voltage-level shifter.
Show answer

Answer: D RS-232 and TTL UART can carry similar serial data, but they need a translator because their electrical levels differ.

iotclass.org

Retrieval practice

Recall check 3 of 3

Packet Pete says: answer from memory, then check your reasoning.

Q3A pump-house UART debug link works at 9600 baud but drops bytes intermittently at 115200 baud on the production cable. Which review question is most useful?

ACheck whether the receiver learned a new address at higher baud.
BAdd parity and assume it corrects timing and cable-induced byte loss.
CJoin TX and RX on one pin to create a shared data conductor.
DCheck clock error, thresholds, cable, ground, and signal edges.
Show answer

Answer: D UART failures at higher baud rates often expose timing, voltage, cable, edge-rate, or oscillator margin problems that were hidden at slower rates.

iotclass.org

Print reference

Answers

Answer key.

  1. C · A working UART link requires matching timing, framing, electrical compatibility, physical wiring, and the actual installed harness.
  2. D · RS-232 and TTL UART can carry similar serial data, but they need a translator because their electrical levels differ.
  3. D · UART failures at higher baud rates often expose timing, voltage, cable, edge-rate, or oscillator margin problems that were hidden at slower rates.
iotclass.org