Loading header...

Communication Protocols

Every electronic device you have ever owned — your phone, your router, your smartwatch, a temperature sensor inside a factory machine — communicates with other devices using a protocol. A protocol is simply a set of rules both sides agree to follow so they can understand each other.

This subject covers those rules, from the lowest level (individual voltage pulses on a wire) all the way up to the highest level (an application sending data across the internet to a server on another continent).


Why This Is a Separate Subject

When you study embedded systems, you learn how to make a microcontroller talk to a sensor over SPI or I²C — that is one wire, two devices, centimetres apart. When you study networking, you learn how a browser fetches a webpage over HTTP through TCP/IP across thousands of kilometres of fibre and wireless links. Both of these are communication protocols, but they operate at completely different levels of abstraction.

Understanding how these levels connect — and how each level depends on the one below it — is one of the most important mental models in all of computing.


The Big Picture — Layers of Communication

flowchart TD classDef hw fill:#fee2e2,stroke:#dc2626,color:#7f1d1d classDef link fill:#ffedd5,stroke:#ea580c,color:#9a3412 classDef net fill:#fef9c3,stroke:#ca8a04,color:#713f12 classDef tran fill:#dcfce7,stroke:#16a34a,color:#14532d classDef app fill:#dbeafe,stroke:#2563eb,color:#1e3a5f APP["Application Layer\nHTTP, MQTT, WebSocket, CoAP\n'What data am I sending and why?'"]:::app TRANS["Transport Layer\nTCP, UDP\n'Is delivery guaranteed? In order?'"]:::tran NET["Network Layer\nIP (IPv4, IPv6)\n'How do I find the destination across many hops?'"]:::net LINK["Data Link + Physical Layer\nEthernet, WiFi (802.11), Bluetooth\n'How do bits get onto the wire or into the air?'"]:::link HW["Hardware Protocols\nUART, SPI, I²C, CAN\n'How do two chips on the same board talk?'"]:::hw APP --> TRANS --> NET --> LINK --> HW

We will study each layer — starting from the hardware at the bottom and working upward.


What You Will Learn in This Section

Hardware Protocols — Chip to Chip

These are the protocols used inside a circuit board between a microcontroller and its peripherals. The wires are centimetres long, speeds range from 100 kbps to 50 Mbps, and there is no internet involved.

Protocol Wires Typical use
UART TX, RX Debug console, GPS, Bluetooth modules
SPI MOSI, MISO, SCK, SS̄ SD cards, displays, ADCs
I²C SDA, SCL Sensors, RTCs, small EEPROMs
RS-232 TX, RX + handshaking PC serial ports, PLC programming, test equipment
RS-485 A, B (differential pair) Industrial bus — Modbus, PROFIBUS, DMX512
CAN CAN_H, CAN_L Automotive, industrial machines
I²S SCK, WS, SD Digital audio — DACs, ADCs, MEMS microphones
4–20 mA 2-wire current loop Industrial process sensors — pressure, temp, flow
1-Wire Single wire Temperature sensors (DS18B20)

Hardware protocols define the electrical layer only — voltage levels, cable length, number of devices. They say nothing about what the bytes mean. That is the job of software protocols.

Software Protocols — What the Bytes Mean

Software protocols run on top of hardware protocols and define the meaning of data: which device is addressed, what operation is requested, how data is structured, and how errors are detected at the application level.

The same software protocol can run on different hardware. Modbus RTU runs on RS-485 or RS-232. Modbus TCP runs on Ethernet. The registers, function codes, and data model are identical — only the physical transport changes.

Protocol Runs on Typical use
Modbus RTU RS-485 (or RS-232) Factory sensors, power meters, drives, PLCs
Modbus TCP Ethernet / WiFi SCADA systems, cloud-connected field devices
PROFIBUS RS-485 variant Siemens industrial automation
BACnet MS/TP RS-485 Building management systems (HVAC, lighting)
DMX512 RS-485 Stage lighting control

Wireless and Network Protocols — Device to World

These protocols move data across rooms, buildings, cities, and continents. They run on top of the hardware protocols and add addressing, routing, error correction, and security.

Protocol Range Typical use
WiFi (IEEE 802.11) ~50–100 m Home and office networks, IoT devices
Bluetooth / BLE ~10 m Headphones, wearables, beacons
Ethernet (IEEE 802.3) ~100 m Wired LAN, switches, routers
LoRaWAN ~2–15 km Low-power wide-area IoT sensors
LTE / 5G Nationwide Mobile data, cellular IoT

Internet Protocols — Addressing and Routing

Protocol Purpose
IPv4 / IPv6 Address every device on earth uniquely
TCP Reliable, ordered byte stream
UDP Fast, best-effort datagrams
DNS Translate names to IP addresses
DHCP Automatically assign IP addresses

Application Protocols — What the Data Means

Protocol Port Purpose
HTTP / HTTPS 80 / 443 Web pages, REST APIs
MQTT 1883 / 8883 IoT messaging (publish/subscribe)
WebSocket 80 / 443 Real-time two-way web connections
FTP / SFTP 21 / 22 File transfer
Modbus varies Industrial sensor/actuator control

The OSI Model — A Universal Framework

The OSI (Open Systems Interconnection) model was created in 1984 by the ISO to give the industry a common vocabulary for talking about protocol layers. Every protocol you will ever encounter can be placed on this stack.

flowchart TD classDef l7 fill:#dbeafe,stroke:#2563eb,color:#1e3a5f classDef l6 fill:#e0e7ff,stroke:#4338ca,color:#312e81 classDef l5 fill:#f3e8ff,stroke:#9333ea,color:#581c87 classDef l4 fill:#dcfce7,stroke:#16a34a,color:#14532d classDef l3 fill:#fef9c3,stroke:#ca8a04,color:#713f12 classDef l2 fill:#ffedd5,stroke:#ea580c,color:#9a3412 classDef l1 fill:#fee2e2,stroke:#dc2626,color:#7f1d1d L7["Layer 7 — Application\nHTTP, FTP, SMTP, DNS, MQTT\nWhat the user or application sees"]:::l7 L6["Layer 6 — Presentation\nTLS/SSL encryption, JPEG compression\nData format, encryption, compression"]:::l6 L5["Layer 5 — Session\nManages connections (login/logout)\nRarely implemented separately today"]:::l5 L4["Layer 4 — Transport\nTCP (reliable) / UDP (fast)\nEnd-to-end delivery, ports, flow control"]:::l4 L3["Layer 3 — Network\nIP addressing, routing\nFinds the path across multiple networks"]:::l3 L2["Layer 2 — Data Link\nEthernet frames, MAC addresses, WiFi frames\nNode-to-node delivery on one network segment"]:::l2 L1["Layer 1 — Physical\nVoltage levels, frequencies, cables, radio waves\nActual bits on the wire or in the air"]:::l1 L7 --> L6 --> L5 --> L4 --> L3 --> L2 --> L1

How a Message Travels from Your Browser to a Server

When you type https://techarya.net and press Enter, here is what actually happens at each layer:

flowchart TD classDef you fill:#dbeafe,stroke:#2563eb,color:#1e3a5f classDef net fill:#dcfce7,stroke:#16a34a,color:#14532d classDef phys fill:#fee2e2,stroke:#dc2626,color:#7f1d1d A["Your browser (Layer 7)\nBuilds an HTTP GET request:\nGET / HTTP/1.1\nHost: techarya.net"]:::you B["TLS (Layer 6)\nEncrypts the HTTP request\nSo only the server can read it"]:::you C["TCP (Layer 4)\nWraps in a segment with:\nsource port 54321, dest port 443\nSequence numbers for ordering"]:::you D["IP (Layer 3)\nAdds source IP + destination IP\nRouters read this to forward the packet\nacross the internet"]:::net E["WiFi / Ethernet (Layer 2)\nWraps in a frame with MAC addresses\nSent to your router's MAC address first"]:::net F["Radio waves / copper / fibre (Layer 1)\nActual bits transmitted as\nvoltage pulses or electromagnetic signals"]:::phys G["... travels through ISP routers ...\nEach router reads Layer 3 IP header,\nforwards to next hop, repeats"]:::net H["Server receives, unwraps each layer\nHTTP handler sends the webpage back\nSame process in reverse"]:::you A --> B --> C --> D --> E --> F --> G --> H

Each layer adds its own header (wrapping) on the way down and removes it on the way up at the other end. This is called encapsulation.


Where to Start

If you are coming from the Embedded Systems track and want to understand how your microcontroller talks to sensors:

→ Start with Hardware Protocols (UART, SPI, I²C)

If you want to understand how devices connect to the internet and talk to cloud services:

→ Start with OSI Model and TCP/IP, then move to WiFi and HTTP/MQTT

If you want a fast overview of the most important concept before anything else:

→ Read the OSI Model lesson — everything else hangs off that framework


Hardware protocols (electrical layer): UARTSPII²CRS-232RS-485I²SCAN4–20 mA

Software protocols (data meaning): Modbus RTUModbus TCP