I2C is a method for communication between sensors, displays, etc. and a microcontroller. I2C is a bus that allows multiple devices to be connected over the same two lines (wires), SDA and SCL. Pullup resistors are required for each bus line, typically 4.7k. Each I2C device on the bus has a 7 bit address, which uniquely identifies it (max 128 addresses). 5V and 3.3V devices may be connected over I2C, provided the pullup resistors are connected to the 3.3V side. I2C level shifter boards are available. The number of nodes is limited by the address space, and by the total bus compacitance of 400 pF, resulting in a communication distance restriction of a few meters (use shielded cable, with shield grounded at one end). You can extend I2c over distances of up to 100 feet using a PCA9615 differential I2C bus extender
Typically specific pins on microcontrollers are allocated for I2C:
I2C | Arduino Uno |
Feather M0 Basic |
Feather 32u4 Basic |
Argon | Boron |
---|---|---|---|---|
SDA | A4 | #20 (SDA) | #2 | D0 (SDA) |
SCL | A5 | #21 (SCL) | #3 | D1 (SCL) |
SDA1 | D2 (D2) | |||
SCL1 | D3 (D3) |
Adafruit TCA9548A 1-to-8 I2C Multiplexer Breakout product $7/ea
Adafruit TCA9548A 1-to-8 I2C Multiplexer Breakout tutorial
Adafruit ISO1540 Bidirectional I2C Isolator - STEMMA QT / Qwiic
Adafruit List of I2C Addresses
Logic Signals | Master Aliases | Slave Aliases |
---|---|---|
Serial Clock (SCLK) | SCK/CLK | SCK/CLK |
Master Out Slave Input (MOSI) | SDO | SDI |
Master Input Slave Output (MISO) | SDI | SDO |
Slave Select (SS) / Chip Select (CS) | SS/CS | SS/CS |
Multiple slaves can share the SDI, SDO and SCK pins, but each slave must have a unique CS/SS pin. You can typically use any digital I/O pin for Save Select (SS / CS). In most cases, the CS/SS is held high when not in use. Master / slave distance can be extended with the use of transceivers like RS-485.
Adafruit SPI Protocol tutorial
SPI | Arduino Uno |
Feather M4 | Feather M0 | Feather 32u4 Basic |
Argon/Boron |
---|---|---|---|---|---|
SCLK (SCK/CLK) | #13 | #24 | #24 | #15 | D11 (D2) |
MOSI | #11 | #23 | #23 | #16 | D12 (D3) |
MISO | #12 | #22 | #22 | #14 | D13 (D20) |
SS (CS) [1] | #10 | #10 | #10 | #10 / A10 | A5 |
[1] Each SPI slave must have a unique CS/SS pin.
Uses a 4.7k pullup resistor.
Do you need help developing or customizing a IoT product for your needs? Send me an email requesting a free one hour phone / web share consultation.
The information presented on this website is for the author's use only. Use of this information by anyone other than the author is offered as guidelines and non-professional advice only. No liability is assumed by the author or this web site.