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
Packet Pete, the module guide, in a scene from this chapter.
iotclass.org

After studying this chapter

Learning objectives

You will be able to:

  • Explain: Its visual vocabulary joins RS-232 Serial Cable to: DB-9 Null Modem Connection, which frames connector diagrams must state the viewing side. Mirrored db9 views are a common source of swapped tx/rx pins.
  • Explain: USB vs RS-232 supplies one named condition;: USB supplies the necessary comparison for asynchronous serial links depend on both endpoints keeping close enough timing until the stop bit is sampled.
  • Explain: Those diagram labels establish the scope of uart is point-to-point: tx on one device must reach rx on the other, and both sides need a common ground.
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.
iotclass.org

Major section

Overview: UART Sends Bytes Without A Clock Wire

Those diagram labels establish the scope of uart is point-to-point: tx on one device must reach rx on the other, and both sides need a common ground.

  • The decision in overview: uart sends bytes without a clock wire must preserve that labelled boundary.
UART is point-to-point: TX on one device must reach RX on the other, and both sides need a common ground.
UART is point-to-point: TX on one device must reach RX on the other, and both sides need a common ground.
iotclass.org

Major section

Practitioner: Keep A Serial Link Record

That labelled check bounds rs-232 uses inverted high-voltage signaling; it must be translated before it reaches normal 3.3 v or 5 v microcontroller uart pins.

  • Its visual vocabulary joins RS-232 Serial Cable to: DB-9 Null Modem Connection, which frames connector diagrams must state the viewing side. Mirrored db9 views are a common source of swapped tx/rx pins.
A DB9 serial cable is where the abstract DTE/DCE and pinout choices become physical. The shell orientation, male or female contact pattern, thumbscrews, cable shield, and installed length all belong in the link record before anyone starts swapping TX and RX. Photo: David Marsh, CC BY 2.0
A DB9 serial cable is where the abstract DTE/DCE and pinout choices become physical. The shell orientation, male or female contact pattern, thumbscrews, cable shield, and installed length all belong in the link record before anyone starts swapping TX and RX. Photo: David Marsh, CC BY 2.0
iotclass.org

Major section

Under The Hood: Timing Error Accumulates Across The Frame

USB vs RS-232 supplies one named condition;: USB supplies the necessary comparison for asynchronous serial links depend on both endpoints keeping close enough timing until the stop bit is sampled.

  • Carry: USB vs RS-232 into under the hood: timing error accumulates across the frame; use: RS-232 as its limiting condition.
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.

Numbers to remember

33.33 msA 64-byte record takes about 33.33 ms without gaps.
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 is point-to-point 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.
iotclass.org

Deck summary

Key takeaways

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

  • Those diagram labels establish the scope of uart is point-to-point: tx on one device must reach rx on the other, and both sides need a common ground.
  • That labelled check bounds rs-232 uses inverted high-voltage signaling; it must be translated before it reaches normal 3.3 v or 5 v microcontroller uart pins.
  • USB vs RS-232 supplies one named condition;: USB supplies the necessary comparison for asynchronous serial links depend on both endpoints keeping close enough timing until the stop bit is sampled.
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?

AThe baud rate, frame format, voltage level, crossed TX/RX wiring, and shared ground are all matched on the target harness.
BRecord only 9600 baud from a bench terminal and let the field controller discover parity, voltage level, wiring, and ground at startup.
COnly the device address, because UART uses addressing like I2C.
DOnly a clock wire, because UART samples data from the transmitter clock.
Show answer

Answer: A 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 microcontroller RX pin because both are serial links.
BConfirm pinout and add an RS-232-to-TTL shifter.
CIncrease the baud rate so the high voltage spends less time on the pin.
DOmit the ground wire because RS-232 carries both positive and negative voltages.
Show answer

Answer: B 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 clocks, thresholds, cable, grounding, and edges.
BDid the receiver learn a new address at the faster baud rate?
CEnable parity and mark the link repaired because parity will correct the bytes damaged by timing margin or cable noise.
DShould TX and RX be connected to the same pin so both devices share a data line?
Show answer

Answer: A 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. A · A working UART link requires matching timing, framing, electrical compatibility, physical wiring, and the actual installed harness.
  2. B · RS-232 and TTL UART can carry similar serial data, but they need a translator because their electrical levels differ.
  3. A · 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