Learning at Hexa Firmware Labs

UART vs SPI vs I²C

Compare three common serial interfaces by wiring, clocking and device selection, then check the exact peripheral datasheet.

UART: agree on a format

A typical UART connection uses transmit and receive signals with a common electrical reference. Both ends need compatible settings such as baud rate and frame format. UART does not provide a shared clock line.

Do not confuse the UART peripheral with an electrical standard such as RS-232 or RS-485. The appropriate interface circuitry and voltage levels still need to be checked.

SPI: clock and select the peripheral

SPI commonly uses a clock, separate data directions and a chip-select signal. The controller selects a peripheral and clocks the transfer. Confirm the required clock polarity, phase and data format in the peripheral documentation.

Multiple peripherals usually need separate selection signals. A device responding incorrectly may be a wiring, selection or timing problem rather than a software parsing error.

I²C: share a bus and address devices

I²C uses data and clock lines with pull-up arrangements appropriate to the bus. Devices are selected by address. Check for address conflicts, compatible signal levels and the pull-ups already present on modules.

Choose from the actual device requirements

The sensor or display usually determines which interfaces are available. Make a wiring table before writing code, then use serial output or a logic analyzer to compare the intended transfer with what is observed.

Continue learning

Learn UART, SPI and I²C in the lab →

Technical references

NXP: I²C-bus specification and user manual
CallWhatsApp