I2C bus / SPI / 1-Wire

I2C Bus

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

Sparkfun I2C Tutorial

I2C over long wires

 

SPI

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.  

Arduino SPI reference

Sparkfun tutorial

Adafruit SPI Protocol tutorial

Adafruit SPI 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.

 

1-Wire

Uses a 4.7k pullup resistor.  

 

I2S Bus

 

 


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.  

Sensors

Sensor Calibration

Sensitivity, Resolution, Response Time, etc.

50000 PPM (5%) CO2 Sensors

MQ Gas Sensors

MQ Gas Sensors

MQ-6 LPG Gas Sensor

MQ-6 LPG Gas Sensor

MQ-7 carbon monoxide CO Gas Sensor

MQ-7 Carbon Monoxide Gas Sensor

Sensor to microcontroller / data acquisition device cables

Accelerometers

IMU / Gyroscope

Magnetometer

Audio

Thermocouple

AF Sensirion SHT40 Temperature & Humidity Sensor

Motion Sensors

object detection sensors

Object Detection Sensors

Strain Gauge

Color

Pressure

Liquid Flow Meter

Operational Amplifiers

Components

Tools

Basic Components

Suppliers

VAC

XBee I/O Line Passing

xBee wireless communication modules with Arduino

xBee wireless communication modules + Arduino

I2C bus / SPI / 1-Wire

UART TTL Serial RS-232

LoRa Communications

Triac

Light Emitting Diode (LED)

NeoPixels

4-20 mA Current Loops

Human Health & Electrical Power

HMI

imgAlt

Mobile Apps

Hall Effect Sensor

NTC Thermistor

Amplify an Analog Signal

Offset a input signal

Electric Motors

Laptop 12V Power Supply

MCP2515 CAN Bus Module

TJA1050 CAN Bus Module

1.2" 4-Digit 7-Segment LED Display

Batteries

2022 Character Display Comparison

Logic Level Converter

Circuit Protection

Diodes

PMOS / P-Channel MOSFET

Logic Level NMOS / N-Channel MOSFET

Voltage Measurement

Analog to Digital Conversion (ADC)

Variable output VDC

Turn On/Off Noisy DC Device

ADC Analog Input