In SPI and I2C, there was a "Clock Line" (SCK/SCL). The Master would say, "Read data when I toggle the clock." UART, however, is Asynchronous. There is no shared clock line. The Receiver and Transmitter must have sworn (agreed) beforehand on the speed at which data will arrive.
If one speaks at 9600 and the other at 9650, communication will collapse after a few bytes. This is called Baud Rate Drift.
On a UART line, the voltage is HIGH (1) when Idle. Communication begins when the line is pulled LOW (0).
A standard data packet (Frame) consists of the following wagons:
- Start Bit (1 Bit): Always 0 (Low). Tells the receiver: "Wake up, data is coming!"
- Data Bits (5-9 Bits): Usually 8 bits (1 Byte). The Least Significant Bit (LSB) is sent first.
- Parity Bit (Optional): Added for error checking (Odd/Even/None).
- Stop Bit (1/1.5/2 Bits): Always 1 (High). Returns the line to idle and provides breathing room for the next byte.
Industry Standard: 99% of devices worldwide use 8N1.
- 8: Data Bits
- N: No Parity
- 1: 1 Stop Bit
graph LR
subgraph IDLE [Idle State]
I[HIGH]
end
subgraph FRAME [Data Frame (8N1)]
S[Start Bit\n(LOW)] --> D0[Bit 0]
D0 --> D1[Bit 1]
D1 --> D2[...]
D2 --> D7[Bit 7]
D7 --> ST[Stop Bit\n(HIGH)]
end
IDLE --> S
style S fill:#ffccbc,stroke:#d84315
style ST fill:#ffe0b2,stroke:#ef6c00
style D0 fill:#e3f2fd,stroke:#1565c0
style D7 fill:#e3f2fd,stroke:#1565c0
Baud Rate is the number of symbols (bits) per second. The higher the Baud Rate, the shorter the duration of a single bit.
| Baud Rate | 1 Bit Duration ( |
1 Byte Duration (Total 10 bits) | Use Case |
|---|---|---|---|
| 9600 | 104.16 µs | ~1.04 ms | Legacy sensors, GPS, Consoles |
| 115200 | 8.68 µs | ~86 µs | ESP32 Debug, Bootloader |
| 921600 | 1.08 µs | ~10 µs | High-Speed Data (Camera, etc.) |
| 250000 | 4.00 µs | 40 µs | DMX512 (Stage Lighting) |
⚠️ Field Note: With 9600 Baud, you can send a maximum of 960 Bytes per second (9600 / 10). Do not ask "Why does 1KB of data take longer than 1 second?". The Start and Stop bits create a 20% "tax" (overhead).
The UART receiver starts its stopwatch the moment it sees the Start bit (falling edge). It tries to read the line exactly in the middle (center sampling) of every
What happens if the sender is 3% slower?
- 1st Bit: Receiver reads correctly near the center. (No problem)
- 4th Bit: Receiver reads slightly off-center. (Risky)
- 8th Bit: Receiver has drifted so much that it reads the wrong bit entirely.
Result: Data arrives as 0xE5 instead of 0x55.
Rule: The Baud Rate difference between the two sides must not exceed 2%.
- Internal Oscillator: The crystal of the Arduino/ESP32 can be affected by heat and change frequency.
- Division Error: If you cannot divide the 80 MHz CPU clock by integers to get exactly 115200, you mathematically miss the target speed.
If you see strange characters or error flags in the terminal, let's identify the culprit:
- Event: Receiver read 8 data bits and now expects a "Stop Bit" (HIGH). But the line is still LOW!
- Meaning: "Synchronization lost, wrong Baud Rate, or interference."
- Symptom:
FEflag raised.
- Event: The sum of incoming bits should be "Even" but turned out "Odd".
- Meaning: "A bit flipped along the way (Noise)."
- Symptom:
PEflag raised.
- Event: The line stayed LOW for longer than a full packet duration.
- Meaning: "Cable cut or the other side is intentionally sending a 'Reset' signal." (Common in LIN Bus protocol).
- Overhead: To send 1 Byte, you actually spend the time of 10 bits (Start + 8 Data + Stop).
- Sensitivity: If the difference between Baud Rates exceeds 2%, data corruption occurs.
- Default: Unless stated otherwise in the datasheet, the setting is 9600 - 8N1.
- Oscilloscope: When analyzing a UART line, measure the "narrowest pulse width". This gives you the duration of 1 bit, and thus the Baud Rate.