Logic levels and communication buses: UART, I²C and SPI
Digital logic levels (3.3 V and 5 V, 5 V tolerance, level shifting) and the three common embedded buses: UART, I2C and SPI, with wiring, pull-ups and typical mistakes.
Logic levels
Modern microcontrollers run at 3.3 V (some at 1.8 V). Many older modules and sensors run at 5 V. A 5 V output into a 3.3 V input can damage the input unless the datasheet explicitly says it is 5 V tolerant. The other direction, 3.3 V into a 5 V input, often works but is not guaranteed: check the input-high threshold (VIH). Use a level shifter when in doubt.
UART (serial)
Two wires, TX and RX, crossed: your TX goes to their RX. No clock; both sides must agree on the speed (baud rate, for example 115 200) and share a common ground. Used for debug consoles, GPS modules and many radio modules. Point to point only.
I²C
Two shared wires, SDA (data) and SCL (clock), with a pull-up resistor on each. Every device has a 7-bit address, so many sensors can share the bus. Speeds of 100 kHz and 400 kHz are common. Typical failures: missing pull-ups, two devices with the same address, and buses too long for their pull-up values.
SPI
Four wires: clock (SCK), data out (MOSI or COPI), data in (MISO or CIPO) and one chip-select (CS) per device. Faster than I²C (several MHz to tens of MHz) and used for displays, memories and fast ADCs. Each device needs its own CS line, and devices must agree on the clock mode (idle level and sampling edge).
Debugging buses
When a bus does not work, stop guessing and look at it. A cheap USB logic analyser decodes UART, I²C and SPI on your computer and shows exactly what was sent and whether anyone answered.
Buses leave the breadboard badly: long cables, noisy motors nearby, several boards with different grounds. When a bus must run over cables or between boards, it needs proper drivers, protection and sometimes a different standard (RS-485, CAN). That is design work.
Parts and tools to practise
| Item | What to look for | Buy |
|---|---|---|
| USB logic analyser, 8 channels | Decodes UART, I²C and SPI on your computer. Essential for bus problems. | View on Amazon ↗ |
| Logic level shifter modules | Bidirectional 3.3 V to 5 V, for I²C and slow signals. | View on Amazon ↗ |
| ESP32 or similar development board | To try pull-ups, ADC readings, buses and PWM for real. | View on Amazon ↗ |
| Solderless breadboard kit with jumper wires | Full-size breadboard, pre-cut jumpers and flexible Dupont wires. | View on Amazon ↗ |
| Resistor assortment, 1 % metal film | E24 or E12 values from 10 Ω to 1 MΩ, 1/4 W. Sorted in labelled bags or a box. | View on Amazon ↗ |
Links go to Amazon. As an Amazon Associate we earn from qualifying purchases, at no extra cost to you. We only list tools of the kind we use on our own bench.
Send us what you have. We tell you what it takes to finish it.
Answer five questions and see an indicative budget in two minutes. When you are ready, sign our NDA, upload your documentation and get a fixed quote. Everything by e-mail, with a call whenever you prefer.