Skip to content

12. Networking and communication

UART

no clock, but fixed speed

NB. TX connects to RX (and vice versa).

I2C

I2C is aka TWI

7-bit addresses (mostly)

Uses these pins:

SCL = clock SDA = data Open-Drain Logic: I²C uses open-drain drivers, meaning devices can only pull the lines (SDA and SCL) down to ground (low state); they cannot drive them high directly.

Instead:

High State: Pull-up resistors connected to the supply voltage ensure the lines return to a high state when no device is pulling them low.

This design allows multiple devices to share the same bus without conflicts, but it relies on pull-up resistors for proper operation.

Most boards that speak a certain protocol have built in pullup/down resistors.

SPI

Has clock and data lines data out / data in (sdo/sdi)(MOSI/MISO)(PICO/POCI) More pins than I2C Advantage: more pins = higher data rate

SCLK - clock SS/CS - Chip select / enable MOSI (Master Out secondary In): This pin carries data from the master device to the secondary device. It is used for sending commands or data. MISO (Master In secondary Out): This pin carries data from the secondary device back to the master device, typically used for receiving responses. CPOL (Clock Polarity) parameter determines the idle state of the clock signal when no data is being transferred.

Network arrangement types (topologies) Serial bus

Daisy chain

Star - One main with many secondaries - UART / SPI

Ring topology - neopixels / SPI

Bus topology - One main with one big data line and main/secondaries connected to it - needs a network address (MAC address, for eg.)

TCP/IP

protocol used on the internet

OSI layers (7 layers) - standardizes how networks interact / communicate

  1. physical
  2. ethernet - Handles communication between devices on the same local network using MAC addresses.
  3. network layer - IPV4/6 - routing data packets between different networks, ensuring that data reaches its intended destination.
  4. transport layer TCP (data) / UDP (streaming - faster - throws data like a potato) - with TCP/IP you always get back an acknowledge
  5. session layer - how we're talking - HTTP - peer to peer
  6. presentation - encryption
  7. application - Defines how users interact with the network through applications. Every device on a network has a unique IP address, which identifies it for communication.

Networks are divided into subnets, each with a default gateway (the router that connects the subnet to other networks).

DHCP is a protocol that automatically assigns IP addresses and other settings to devices on a network.

Wireshark is a program that lets us see which packages out computer is sending and receiving, that would otherwise go unnoticed.