Connecting Peripherals

You now know a bit more about your device. But what if you have several devices and you wish to make them communicate?

There are several ways to connect hardware elements and allow them to exchange data. This exchange of data is done through small changes in voltage. Data can be exchanged through a variable voltage between 0V and 3.3V (analog pins), or through simple on/off (0V/3.3V) states (digital pins). Data can also be exchanged through special digital toggling referred to by their communication protocols. Communication protocols (such as GPIO, SPI, I2C, and UART) involve a predefined set of pins used in a specific way. These protocols are used to encode complex messages. It's a lot like Morse code, but for electronics.

In embedded electronics, the most commonly-used protocols are:

  • GPIO (General Pin Input/Output)
  • SPI (Serial Peripheral Interface)
  • I2C (Inter-Integrated circuit)
  • UART (Universal Asynchronous Receiver/Transmitter)

Here, we provide a brief overview of these protocols, and discuss some of the strengths and weaknesses of each.

Most of the time, you will choose your protocol based on the parts you are using when designing your module. Other things to consider are the available pins, as well as your communication speed requirements. The following table can be used as a quick reference.


Protocol Number of Pins Required Maxium Speed
GPIO  1

 8 Kbit/s

 Can be up 180 MHz for Very High Speed mode
SPI  (MOSI, MISO, SCK + 1 GPIO pin)  25 MBit/s
I2C   2 (SCL and SDA)

 400 kbit/s Fast mode

 1 Mbit/s Fast mode plus or Fm+

 3.4 Mbit/s High Speed mode
UART  2 (TX - Transmit and RX - Receive)  8 Mbit/s

Protocol Selection Reference


A Note on Level Shifting

All of the diagrams and discussions that follow regarding communication protocols assume that the hardware modules you are communicating with operate at 3.3V. If you have a device on your custom module that operates at 5V, 1.8V, or any other non-3.3V voltage, be careful! Directly connecting components with different operating voltages can damage your device.

You can use devices which operate at different voltages by employing a technique called 'level shifting'. Sparkfun has a nice write-up and tutorial on voltage dividers and level shifting that you can use as a starting point.


Last modified: Tuesday, September 27, 2022, 3:02 PM