Sign in to save

Bookmark this page so you can find it later.

Sign in to save

Bookmark this page so you can find it later.

Robots depend on communication buses to move data between a microcontroller and parts such as sensors, motor drivers, displays, GPS receivers, and wireless modules. I2C, SPI, and UART are three common ways to connect these devices using only a few wires. Choosing the right bus affects wiring complexity, speed, reliability, and how many modules can share the same controller pins.

Understanding these interfaces helps you design robots that are easier to debug and expand.

Key Facts

  • I2C uses two shared signal lines: SDA for data and SCL for clock.
  • SPI commonly uses four signal types: SCLK, MOSI, MISO, and CS or SS.
  • UART uses two main signal lines: TX and RX, with no separate clock line.
  • I2C devices share a bus and are selected by address, such as 0x3C or 0x68.
  • SPI devices share clock and data lines but usually need one chip select line per device.
  • UART timing must match on both devices, such as 9600 baud, 115200 baud, or another agreed data rate.

Vocabulary

Bus
A bus is a shared communication path that carries signals between electronic devices.
I2C
I2C is a two-wire synchronous bus that lets one controller communicate with multiple addressed devices.
SPI
SPI is a fast synchronous bus that sends data using separate clock, input, output, and device select signals.
UART
UART is an asynchronous serial interface that sends data over transmit and receive lines without a shared clock.
Baud rate
Baud rate is the number of signal changes per second used to time serial communication.

Common Mistakes to Avoid

  • Connecting TX to TX and RX to RX is wrong for UART because transmit on one device must go to receive on the other device.
  • Forgetting I2C pull-up resistors is wrong because SDA and SCL usually need pull-ups to return to a logic high state.
  • Using the same I2C address for two devices on one bus is wrong because the controller cannot tell which device should respond.
  • Leaving all SPI chip select lines active is wrong because more than one device may drive MISO at the same time and corrupt the data.

Practice Questions

  1. 1 An I2C bus has a 400 kHz clock. If one useful data byte requires 9 clock pulses including the acknowledge bit, about how many bytes per second can be transferred before other overhead is included?
  2. 2 A robot has one SPI display and three SPI sensor modules. If SCLK, MOSI, and MISO are shared, how many chip select lines are needed so each device can be selected separately?
  3. 3 A robot uses a microcontroller, an IMU, a small OLED display, a GPS module, and a fast motor driver. Choose I2C, SPI, or UART for each module and explain your choices based on wiring, speed, addressing, and data timing.