Dedicated bus technologies are useful to connect peripheral to the host microcontroller. When dealing with digital sensors instead of analog sensors, these data buses are almost mandatory. In the microcontroller world, there are usually 3 types of buses: 1-wire, I2C and SPI.
1-Wire is a device communications bus system designed by Dallas Semiconductor Corp. that provides low-speed (16.3 kbit/s) data, signaling, and power over a single conductor. It is typically used to communicate with very simple and low-speed devices such as simple digital sensors.
More details on the 1-wire protocol on the wikipedia page.
I2C bus #
I2C (Inter-Integrated Circuit) is one of the most popular communication protocol used in embedded systems. It has been designed by Philips for simple audio-video appliances controlled by the microcontroller.
There are many chips that can be connected to the processor with this interface which uses SDA (data) and SCL (clock) pins:
- EEPROM memory chips
- RAM memory chips
- AD/DA converters
- Real-time clocks
- OLED screens
In an I2C bus, each device (slave) has an assigned address to allow the master (microcontroller) to indicate which I2C slave it is communicating with.
Note that on many microcontrollers, SDA and SCL lines are usually mapped to pre-defined pins. For instance, on Arduino boards using the ATmega328P microcontroller, SDA is usually pin A4 and SCL is usually pin A5. You need to check the board’s schematic!
Being a low-speed bus technology, it is possible to use other pins for SDA and SCL lines provided that the software library allows so.
More details on the I2C bus and the wikipedia page.
SPI bus #
SPI (Serial Peripheral Interface) is a synchronous serial interface and protocol that can transmit data with speed up to 20Mbps.
To communicate SPI uses three lines common to all of the connected devices, and one enabling line for every slave element.
More details on the SPI bus on the wikipedia page.
SPI bus is usually for high-speed devices such as SD card reader, radio modules,… that need faster communications with the host microcontroller. Below is an example of a LoRa radio module using the SPI bus.
Note that on many microcontrollers, MISO, MOSI and SCK lines are mapped to pre-defined pins. SS line can be freely chosen although there can be a default pin for that purpose. You need to check the board’s schematic!
2021 - Congduc Pham