Wired Communication: Transferring data over a physical conductor (copper cable, optical fibre) rather than radio waves; typically more reliable and higher bandwidth than wireless
Differential Signalling: Transmitting data as the voltage difference between two wires rather than a single voltage; rejects common-mode noise and enables longer cable runs (RS-485, Ethernet)
Single-Ended Signalling: Transmitting data as a voltage level on one wire relative to a common ground; simpler but more susceptible to noise (UART TTL, SPI, I²C)
Baud Rate: The rate of symbol transmission; for binary signalling equals bit rate
Bus Topology (Wired): Multiple devices sharing one communication medium (e.g., RS-485, CAN bus, I²C); requires arbitration or addressing to avoid collisions
Point-to-Point Link: A dedicated wired connection between exactly two devices (USB, SPI, RS-232); no arbitration needed but scales poorly
Fieldbus: An industrial wired network protocol (CAN, Modbus, PROFIBUS) connecting sensors and actuators to programmable logic controllers
53.1 In 60 Seconds
Before any IoT sensor reading reaches the cloud, it must first travel centimeters from the sensor chip to the microcontroller using one of three wired protocols: UART (2 wires, simple point-to-point at up to 115.2 kbps), I2C (2 wires with addressing for up to 112 devices at 400 kbps), or SPI (4+ wires for high-speed full-duplex at 10+ Mbps). Choosing the right protocol depends on your device count, speed requirements, and available pins.
53.2 Learning Objectives
By the end of this chapter, you will be able to:
Identify the three main wired protocols (UART, I2C, SPI) and their physical characteristics
Compare protocol trade-offs in wire count, speed, device support, and complexity
Select the appropriate wired protocol for a given IoT sensor or peripheral scenario
Explain synchronous vs asynchronous communication and how clock signals coordinate data transfer
Apply protocol selection criteria to real-world IoT hardware design decisions
Minimum Viable Understanding (MVU)
If you only have 10 minutes, focus on these three essentials:
UART uses 2 wires (TX/RX) for simple point-to-point links at up to 115.2 kbps (standard RS-232 maximum; many MCU UARTs support higher) – ideal for GPS modules, Bluetooth adapters, and serial debugging where only two devices communicate
I2C uses 2 wires (SDA/SCL) with addressing to connect up to 112 devices at 400 kbps on a shared bus – the go-to protocol for temperature sensors, displays, and multi-sensor IoT projects
SPI uses 4+ wires (MOSI/MISO/SCK/CS) for high-speed full-duplex transfers at 10+ Mbps – required when data rate matters, such as SD card logging or high-resolution TFT displays
53.3 Introduction
Wired communication protocols form the foundation of IoT device interconnection at the local level. Before any sensor reading reaches the cloud via Wi-Fi or LoRaWAN, it must first travel a few centimeters from the sensor chip to the microcontroller – and that short journey uses one of three wired protocols: UART, I2C, or SPI. Understanding these protocols is essential for anyone building IoT hardware.
This chapter provides an overview and comparison of these three protocols, then directs you to focused sub-chapters for deep dives into each one.
Sensor Squad: The Three Wired Highways
Sammy the Sensor looks at the wires on the circuit board and asks: “How do I send my temperature reading to the brain chip?”
Lila the LED explains: “Think of it like roads! There are three types of roads on our circuit board:”
UART Road is like a two-lane country road – one lane going each way. Only two friends can talk, but it is simple and works great for chatting!
I2C Road is like a school bus route – one bus (2 wires) picks up many students (sensors). Each student has a seat number (address), so the driver knows who to talk to.
SPI Road is like a superhighway with dedicated lanes – super fast, but takes up more space (4+ wires). Perfect when you need to move a LOT of data quickly!
Max the Microcontroller adds: “I am the brain chip! I decide which road to use. If I only need one friend, I use UART. If I need lots of sensor friends, I use I2C. If I need speed, I go SPI!”
Bella the Battery warns: “Remember, more wires means more pins used up on Max. I2C is great because it uses only 2 wires for tons of sensors, saving pins and keeping things tidy!”
For Beginners: What Are Wired Protocols?
If you are new to electronics or IoT, here is the simplest explanation:
Wired protocols are the rules for how chips talk to each other over tiny copper wires on a circuit board. Think of them as different languages – each with its own grammar (timing rules), vocabulary (signal meanings), and number of speakers it supports.
Why does this matter? When you buy a temperature sensor for your Arduino or ESP32 project, the sensor’s datasheet will say “I2C interface” or “SPI interface.” You need to know:
Which wires to connect (each protocol uses different pins)
What code library to use (each protocol has different Arduino/MicroPython functions)
Whether it will work with your other sensors (some protocols share wires, others do not)
The good news: There are only three protocols to learn, and most IoT projects use I2C for sensors and SPI for storage or displays. If that is all you remember, you are already ahead!
53.4 Overview
Figure 53.1: The three main wired protocols for IoT: UART for point-to-point, I2C for multi-device, SPI for high-speed
The microcontroller sits at the center of all three buses, managing protocol-specific signaling on dedicated pins:
Figure 53.2: Signal lines from a microcontroller showing UART TX/RX, I2C SDA/SCL with shared bus, and SPI MOSI/MISO/SCK with individual chip-select lines
53.5 Wired Protocol Architecture
Understanding how each protocol physically connects devices is critical for PCB design and breadboard prototyping.
Figure 53.3: Physical wiring architecture of UART (crossed TX-RX), I2C (shared SDA/SCL with pull-up resistors), and SPI (shared bus with dedicated CS lines)
High-speed full-duplex interface for fast peripherals:
MOSI, MISO, SCK, and chip select signals
SPI modes (CPOL/CPHA) and clock configuration
Multi-slave configurations with dedicated CS lines
Protocol comparison and selection guide
SD card and display interfacing
53.7 Quick Protocol Comparison
Protocol
Wires
Speed
Devices
Duplex
Clock
Best For
UART
2
115.2 kbps (RS-232 max)
2
Full
None (async)
GPS, Bluetooth, debugging
I2C
2
400 kbps
112
Half
SCL (sync)
Sensors, displays, EEPROMs
SPI
4+
10+ Mbps
Many
Full
SCK (sync)
SD cards, fast sensors, displays
53.8 Protocol Selection Decision Flow
Choosing the right wired protocol is one of the first hardware decisions in an IoT project. Use this decision tree:
Figure 53.4: Decision tree for wired protocol selection: device count, speed, and pin constraints lead to UART, I2C, or SPI
53.9 Communication Timing Comparison
Understanding how data moves on the wire is essential for debugging. This diagram shows the fundamental timing difference between asynchronous (UART) and synchronous (I2C, SPI) protocols:
Figure 53.5: Timing comparison: UART uses start/stop bits (no clock), I2C uses SCL with ACK handshake, SPI uses CS activation with simultaneous MOSI/MISO transfer
53.10 Common Pitfalls
Common Wired Protocol Mistakes
1. Missing I2C pull-up resistors. I2C requires 4.7 kOhm pull-up resistors on SDA and SCL lines. Without them, the bus will not work at all – you will read all zeros or all ones. Many breakout boards include pull-ups, but if you connect multiple boards, you may end up with too many pull-ups in parallel (effectively lowering resistance), which also causes failures.
2. UART baud rate mismatch. If the transmitter sends at 9600 baud but the receiver expects 115200, you will see garbage characters (or nothing). Always verify both sides use the same baud rate, data bits (usually 8), parity (usually none), and stop bits (usually 1) – often written as “8N1”.
3. SPI mode mismatch (CPOL/CPHA). SPI has four modes (0-3) that define when data is sampled relative to the clock edge. If master and slave use different modes, data will be shifted or corrupted. Always check the peripheral datasheet for the required SPI mode.
4. Forgetting voltage level translation. A 3.3V ESP32 connected directly to a 5V UART device can damage the ESP32. Always use a logic level converter (bidirectional MOSFET-based) when mixing 3.3V and 5V devices.
5. I2C address conflicts. Two devices with the same 7-bit address on the same bus will cause collisions. Run an I2C scanner sketch first to detect all devices and check for conflicts. Some devices allow address configuration via address pins (A0, A1, A2).
53.11 Worked Example: Designing a Weather Station Bus
Scenario: You are building an IoT weather station with the following components connected to an ESP32:
Component
Interface Options
Data Rate Needed
Notes
BME280 (temp/humidity/pressure)
I2C or SPI
Low (1 reading/sec)
Default I2C address: 0x76
SSD1306 OLED (128x64 display)
I2C or SPI
Medium (10 fps)
Default I2C address: 0x3C
NEO-6M GPS Module
UART only
Low (1 fix/sec)
9600 baud default
MicroSD Card
SPI only
High (logging at 1 kB/sec)
Requires SPI
BH1750 Light Sensor
I2C only
Low (1 reading/sec)
Default address: 0x23
Step 1: Identify fixed-interface components.
GPS module = UART (no choice). Uses pins GPIO16 (RX2), GPIO17 (TX2) on ESP32.
MicroSD card = SPI (no choice). Uses the default SPI bus: GPIO23 (MOSI), GPIO19 (MISO), GPIO18 (SCK), GPIO5 (CS).
Step 2: Decide on shared-bus components.
BME280, SSD1306, and BH1750 all support I2C. Their addresses (0x76, 0x3C, 0x23) are all different, so no conflicts.
Putting these three on I2C saves pins: only GPIO21 (SDA) and GPIO22 (SCL) needed for all three.
Step 3: Verify no conflicts exist.
Bus
Devices
Wires Used
Pins
UART2
GPS (NEO-6M)
2
GPIO16, GPIO17
I2C
BME280 (0x76), OLED (0x3C), Light (0x23)
2
GPIO21, GPIO22
SPI
MicroSD
4
GPIO23, GPIO19, GPIO18, GPIO5
Total
5 devices
8 wires
8 pins
Putting Numbers to It
GPIO Pin Utilization: Protocol Selection Impact
Let us quantify how protocol choice affects precious GPIO pin count on an ESP32:
Scenario 1: All I2C-capable devices on SPI (hypothetical worst case for I2C-capable devices): - Each SPI device needs: MOSI, MISO, SCK (shared) + CS (dedicated) - For the 3 I2C-capable devices (BME280, OLED, BH1750) on SPI: 3 shared + 3 CS = 6 GPIO pins (vs. 2 pins total on I2C – a difference of 4 GPIO pins for just these three devices) - BUT: sensors and displays do not need SPI speed, wasting high-speed bus capability
Scenario 2: All devices on individual UART (impossible): - Each UART device needs: TX, RX (2 pins) - For 5 devices: \(5 \times 2 = 10\) GPIO pins - ESP32 has only 3 hardware UART ports → cannot support 5 devices
Pin savings by using I2C instead of SPI for the three shared-bus devices: \[\text{Pins saved} = 6 \text{ (SPI for 3 devices)} - 2 \text{ (I2C for 3 devices)} = 4 \text{ GPIO pins}\]
Alternative: I2C vs SPI for display:
I2C OLED: Uses shared SDA/SCL (0 additional pins beyond the 2 already used by other I2C sensors)
SPI OLED: Would need dedicated CS pin → +1 GPIO (plus MOSI/MISO/SCK if not already used by SD card)
For an ESP32 with GPIO0–GPIO39 (roughly 25 usable general-purpose pins after power, flash, and boot-strapping reservations), saving 4 pins for I2C devices = ~16% more GPIO available for future expansion. This matters when adding buttons, status LEDs, or additional sensors later.
Step 4: Hardware checklist.
Add 4.7 kOhm pull-up resistors on SDA and SCL (check if breakout boards already have them)
Use 3.3V power for all components (ESP32 is 3.3V logic)
Configure UART2 at 9600 baud 8N1 to match GPS default
Use SPI Mode 0 for SD card (standard for most SD libraries)
Result: Five peripherals connected using only 8 GPIO pins by mixing all three protocols strategically.
Figure 53.6: Weather station wiring: ESP32 using UART2 for GPS, I2C for BME280/OLED/BH1750, and SPI for MicroSD – all five peripherals on 8 GPIO pins
53.12 Knowledge Check
Test your understanding of wired communication protocols:
53.13 Learning Path
Recommended order:
Start with Fundamentals to understand core concepts
Problem identified: A 4.7kΩ pull-up is a widely used starting value for standard-mode I2C (100 kHz); the I2C specification actually defines a minimum pull-up resistance based on bus capacitance. The parallel combination of four sets creates 1.35kΩ — nearly 3.5× too low (i.e., too strong a pull-up).
Consequences:
Excessive current draw: (5V - 0.4V) / 1.35kΩ = 3.4 mA per line (SDA + SCL = 6.8 mA total)
Rise time too fast for long traces (capacitance limits violated)
Marginal signal levels at far end of bus
Intermittent communication errors at higher speeds
Correct Solution:
Remove all but one set of pull-ups: Desolder resistors from 3 boards, keep only one 4.7kΩ set
OR use external calculated values: Remove all onboard pull-ups, add single 4.7kΩ to the main controller board
For long buses or high capacitance: Calculate required minimum pull-up resistance using the NXP I2C specification formula:
R_min (Ω) = t_r (ns) / (0.8473 × C_bus (pF)) × 1000
Where:
t_r = maximum rise time allowed (1000 ns for standard-mode 100 kHz I2C)
C_bus = total bus capacitance in pF (traces + input capacitances of all devices)
Example: C_bus = 200 pF
R_min = 1000 ns / (0.8473 × 200 pF) × 1000
= 1000 / 169.46 × 1000 = 5903 Ω ≈ 5.9 kΩ → choose 6.8 kΩ (nearest standard value)
Quick Check Rule: Measure actual pull-up resistance with multimeter (power off, one end lifted). If below 3kΩ for a standard-speed bus, you have too many parallel pull-ups.
Why This Matters: Pull-up calculation errors are the #1 cause of “I2C works on my desk but fails in the field” bugs. Temperature changes affect resistance, making marginal designs unreliable.
Try It: I2C Pull-Up Resistance Calculator
Enter the pull-up resistor values on your I2C boards to see the effective parallel resistance and whether it is within spec.
Wired communication protocols are the essential building blocks for connecting sensors, displays, and peripherals to IoT microcontrollers. Here are the key points to remember: