I2C VS SPI
What is it?
This is the way that systems communicate with each other. For embedded systems, when you want to connect an MCU Board to another system through wiring, it is important to pick a protocol that facilitates communication effectively for your project.
I2C
connects lower peripheral devices (accelerometers, gyroscopes, LCD displays etc) with minimal wires.
uses SDA and SCL ports on the MCU Board.
SDA -> serial data -> allows for information to pass between the primary device and the secondary device (like a sensor, other mcu etc). this is how commands pass and outputs pass between the devices.
SCL -> serial clock -> carries the clock signal
its pretty slow and bare minimum. this works best for designs that are simple.
examples of projects that work with i2c best!
soil moisture sensor -> using the soil moisture sensor and an arduino (or any board of your choosing)
weather display on an LCD
using a potentiometer to increase the light or dimness of an led or audio
if you want to connect multiple secondary devices, you would need a I/O bus to so that you wouldn’t need more pins of the primary device.
a popular one is MCP 23017
SPI:
better for high speed data transfer like SD Cards and displays.
Uses a lot more wires.
uses MOSI, MISO, SCK, and CS line on the MCU Board.
MOSI -> carries info from the primary device to secondary device
MISO -> carries info from secondary device to primary (vice versa of above^)
SCK -> sends the clock signal
CS -> identifies the secondary device. each device has its own lines.
examples of projects that work with spi best!
camera project -> displaying on a TFT display
complicated robots -> needs high accuracy accelerometers, gyroscopes etc
weather monitoring -> data collection and storing data on an sd card
if you want to connect multiple secondary devices, you would need a I/O bus to so that you wouldn’t need more pins of the primary device.
a popular one is MCP 23S17