100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Programming

I2C and SPI Communication

How Arduino talks to sensors, displays, and other chips over two dominant synchronous serial buses: I2C's two-wire shared bus and SPI's fast four-wire full-duplex link.

Communication & LibrariesIntermediate10 min readJul 10, 2026
Analogies

Why Arduino Needs Dedicated Buses

A single Arduino has only a handful of I/O pins, yet a real project may need a temperature sensor, an OLED screen, a real-time clock, and an SD card all at once. Wiring each device with its own dedicated parallel lines would exhaust the pins instantly. I2C (Inter-Integrated Circuit) and SPI (Serial Peripheral Interface) solve this by letting many chips share the same small set of wires, each device addressed or selected in turn. Both are synchronous serial buses, meaning a shared clock line keeps sender and receiver in lockstep so no timing guesswork is required.

🏏

Cricket analogy: Like a single set of stumps shared by both batting ends: rather than building a fresh pitch per delivery, one shared strip serves every ball, just as one bus serves every chip.

I2C: Two Wires, Many Devices

I2C uses just two lines: SDA (serial data) and SCL (serial clock), plus a shared ground. On an Arduino Uno these are pins A4 (SDA) and A5 (SCL). Every device on the bus has a unique 7-bit address, so the master (the Arduino) begins a transaction by broadcasting the target address, and only the matching chip responds. Because the lines are open-drain, they need pull-up resistors (commonly 4.7 kΩ) to a positive rail; most breakout boards include these already. I2C is slower than SPI, typically 100 kHz standard or 400 kHz fast mode, but its two-wire simplicity makes it ideal for connecting many low-bandwidth sensors.

🏏

Cricket analogy: The umpire calling a specific batter's name before a review is like the master broadcasting a 7-bit address so only the addressed chip answers.

cpp
#include <Wire.h>

void setup() {
  Wire.begin();           // join the I2C bus as master
  Serial.begin(9600);
}

void loop() {
  // Request 1 byte from a DS3231 RTC at address 0x68 (seconds register)
  Wire.beginTransmission(0x68);
  Wire.write(0x00);       // point to register 0
  Wire.endTransmission();

  Wire.requestFrom(0x68, 1);
  if (Wire.available()) {
    byte seconds = Wire.read();
    Serial.print("Seconds (BCD): 0x");
    Serial.println(seconds, HEX);
  }
  delay(1000);
}

Stuck bus? Upload the classic I2C scanner sketch: loop addresses 1–126, call Wire.beginTransmission(addr) and Wire.endTransmission(), and print any address that returns 0. It confirms your wiring and reveals each device's real address before you write driver code.

SPI: Four Wires, Full Speed

SPI trades I2C's minimal wiring for raw speed and full-duplex data flow. It uses four signals: SCK (clock), MOSI (master out, slave in), MISO (master in, slave out), and one SS/CS (slave select) line per device. On an Uno these live on pins 13, 11, and 12, with any spare pin acting as a chip select. Instead of addressing by number, the master pulls a device's CS line low to activate it, then shifts bits out on MOSI while simultaneously reading bits back on MISO in the same clock cycles. Clock speeds of several megahertz make SPI the natural choice for SD cards, TFT displays, and high-rate sensors, at the cost of one extra pin per additional device.

🏏

Cricket analogy: Full-duplex SPI is like a quick single where both batters run in opposite directions at once, sending and receiving in the same instant.

I2C and SPI use different logic conventions and can conflict on voltage. Many modern breakouts run at 3.3 V; feeding them the Uno's 5 V logic can permanently damage them. Check each device's datasheet and add a level shifter when mixing 5 V and 3.3 V parts, especially on SPI lines like MOSI and SCK.

cpp
#include <SPI.h>

const int CS_PIN = 10;

void setup() {
  pinMode(CS_PIN, OUTPUT);
  digitalWrite(CS_PIN, HIGH);   // deselect device
  SPI.begin();
}

byte readRegister(byte reg) {
  SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0));
  digitalWrite(CS_PIN, LOW);    // select device
  SPI.transfer(reg | 0x80);     // 0x80 = read bit for many sensors
  byte value = SPI.transfer(0x00); // send dummy, receive data
  digitalWrite(CS_PIN, HIGH);   // deselect
  SPI.endTransaction();
  return value;
}

Choosing Between Them

Reach for I2C when pin count matters more than speed: multiple slow sensors, an RTC, and a small OLED can all coexist on the same two wires. Reach for SPI when throughput dominates, such as streaming to an SD card or refreshing a color display, and you can spare a chip-select pin per device. Many projects blend both: an ESP32 might drive a fast SPI display while polling a bank of I2C environmental sensors. Understanding each bus's trade-offs lets you allocate the microcontroller's limited pins deliberately instead of running out halfway through a build.

🏏

Cricket analogy: Choosing I2C vs SPI is like picking a spinner for control or a pace bowler for speed: match the tool to what the situation demands.

  • I2C uses two wires (SDA, SCL) with 7-bit addressing and open-drain pull-ups, ideal for many slow devices.
  • SPI uses four wires (SCK, MOSI, MISO, CS) with one chip-select per device and runs at megahertz speeds full-duplex.
  • On an Uno, I2C is on A4/A5 and hardware SPI is on pins 11/12/13 plus a chosen CS pin.
  • The Wire library drives I2C; the SPI library drives SPI, using beginTransaction to set speed and mode.
  • Watch voltage levels: many breakouts are 3.3 V and need level shifting from the Uno's 5 V logic.
  • Use an I2C scanner to discover device addresses and confirm wiring before writing drivers.
  • Blend both buses in one project: SPI for high-bandwidth peripherals, I2C for banks of low-rate sensors.

Practice what you learned

Was this page helpful?

Topics covered

#Programming#ArduinoProgrammingStudyNotes#I2CAndSPICommunication#I2C#SPI#Communication#Arduino#StudyNotes#SkillVeris#ExamPrep

Frequently Asked Questions

21 categories · pick one to explore

Where can I get free study notes for programming and tech subjects?
SkillVeris offers completely free study notes covering programming and tech subjects, with no signup fees or paywalls. The notes are structured by course and topic, written for quick understanding, and enriched with the Learn Through Hobbies analogy method, so you can revise concepts through cricket, music, gaming, cooking and more.
Are SkillVeris study notes good for exam revision?
Yes, the study notes are designed for efficient revision: each topic answers its heading immediately, keeps explanations concise, and links to related glossary terms and cheat sheets. Students preparing for university exams or certification tests use them as quick revision notes because they distil concepts without the padding of full textbooks.
What subjects do the free study notes cover?
The study notes span the platform's main domains, including AI and machine learning, Python and programming, web development, DevOps, cloud, security and databases. Coverage mirrors the 37 live courses, so notes exist for the topics you are actually studying, and new note sets are added as courses launch.
How are SkillVeris study notes different from regular textbooks?
The notes are answer-first, concise and free, whereas textbooks are long and often expensive. Each section explains one concept directly, then reinforces it through selectable hobby analogies like cricket or cooking. Notes also cross-link to the glossary, blog and cheat sheets, letting you jump to related material instantly instead of flipping pages.
Can I use the developer study material without creating an account?
The study notes are free to access, and SkillVeris does not charge anything for its developer study material at any point. Browsing notes is straightforward from the Study Notes section, and if you want progress tracking, certificates and AI Mentor conversations tied to your learning, a free account unlocks those extras.
Do the study notes explain concepts with analogies?
Yes, this is a signature SkillVeris feature. Study notes use the Learn Through Hobbies method, explaining technical concepts through analogies from twelve domains including cricket, music, gaming, photography, travel, movies, fitness, chess, cooking, finance, business and sports. You can switch the analogy domain instantly to whichever hobby makes the concept click.
Are the revision notes suitable for last-minute exam preparation?
Yes, revision notes on SkillVeris work well for last-minute preparation because every section states the answer in its first sentences, so skimming is genuinely effective. Pair them with the relevant cheat sheet for formulas and syntax, and use the glossary for any unfamiliar term you meet while cramming.
Is there free study material for AI and machine learning?
Yes, SkillVeris provides free study notes across its AI and ML catalogue, covering Python for AI, deep learning frameworks like PyTorch and TensorFlow, Hugging Face Transformers, Large Language Models, RAG, AI agents and MLOps. All of it is free, making it a strong resource for Indian students and global learners alike.
Can beginners understand the study notes, or are they for experts?
Beginners can absolutely use them. The notes are written in plain language, define terms as they appear, and lean on hobby analogies to make abstract ideas concrete. Difficulty scales with the underlying course level, so beginner-course notes stay gentle while advanced-course notes go deeper, and the glossary supports you throughout.
How do study notes connect with SkillVeris courses?
Study notes are organised by course and topic, so they map directly to the structured courses and their 24–40-lesson curriculum. Many learners study a lesson first, then use the matching notes for revision before module assessments and the final exam, where 80 percent is required to pass and earn the certificate.
Are there study notes for Python specifically?
Yes, Python is well covered through notes tied to the Python-focused courses, including Python for AI and ML. Topics span fundamentals through applied machine learning usage. You can reinforce the notes with Python practice in Code Lab, which runs code in your browser with no installation required.
Do the study notes include code examples?
Yes, study notes include code examples wherever a concept is best shown in code, alongside explanations, key points and analogies. Reading a snippet in the notes and then reproducing it yourself in Code Lab is an effective loop, since Code Lab lets you run code in the browser across six languages.
How often is new study material added to SkillVeris?
Study material grows alongside the course catalogue. Whenever new courses join the platform's 37 live courses, matching study notes, glossary entries and cheat sheets are added so the resources stay in sync. Existing notes are also refined over time, so it is worth revisiting topics you studied earlier.
Can I use SkillVeris notes to prepare for technical interviews?
Yes, the notes make excellent interview revision because they compress each concept into direct, answer-first explanations, which mirrors how you should answer interview questions. Combine them with the SkillVeris interview questions feature, which includes readiness scoring, to test whether your revision has actually made you interview-ready.
Are the study notes mobile-friendly for studying on the go?
Yes, the study notes are built to load fast and read comfortably on mobile devices, so you can revise during a commute or between classes. Sections are short and answer-first, which suits small screens, and analogy switching works on mobile too, letting you study anywhere without carrying books.
What is the difference between study notes and cheat sheets?
Study notes explain concepts in depth with context, examples and analogies, making them ideal for learning and revision. Cheat sheets are compact quick-reference summaries of syntax, commands and key facts, ideal once you already understand a topic. Most learners study the notes first, then keep the cheat sheet handy while coding.
Do study notes help if I am stuck on a course lesson?
Yes, reading the matching study notes often clarifies a lesson because the same concept is explained from a different angle, frequently with a different analogy. If you are still stuck, ask the AI Mentor, which answers 24/7 at Quick, Detailed or Deep-dive depth until the idea genuinely makes sense.
Is there free study material for DevOps and cloud topics?
Yes, SkillVeris carries free study notes for DevOps and cloud topics as part of its coverage across 37 live courses. The material suits learners following the DevOps Engineer or Cloud Engineer paths, and it links to related glossary terms and cheat sheets so you can revise the whole toolchain in one place.
Can school or college students in India use these notes for projects?
Yes, students across India and worldwide use SkillVeris notes for coursework, projects and exam preparation, and everything is free, which matters for student budgets. The notes explain concepts clearly enough to cite in project reports, and Code Lab lets you prototype the project code directly in your browser.
How should I combine study notes with other SkillVeris resources?
A proven loop: learn from a course lesson, revise with the matching study notes, look up unfamiliar terms in the glossary, keep the cheat sheet open while practising in Code Lab, and quiz yourself with interview questions. The AI Mentor fills any remaining gaps 24/7, at whatever depth you need.

What Learners Say

Real journeys from the SkillVeris community — swipe for more.

SkillVeris taught me Python through Cricket. Now I’m building real projects and feeling confident!
Arjun S. · B.Tech Student
The best platform for hobby-based learning. Concepts finally stick.
Priya R. · Data Analyst
I went from zero coding to a portfolio of projects — all by learning through my love for gaming. Landed my first internship!
Kabir M. · CS Undergraduate
Trending Topics50 popular tags — tap to explore
Trending CoursesAll 37 free courses — tap to browse