Lesson plan

Talk to chips: I2C, SPI and UART lesson plan

The three buses every sensor, screen and radio speaks, on the Uno: serial between two boards, I2C scans and shared buses, SPI screens and an SD card, the logic analyzer, and a weather station that uses them all.

5 chapters, 7 lessons, about 4 hours, on the Arduino Uno R3. Every lesson runs in the browser, with nothing to install.

The unit

Objectives and materials

By the end, students can

  • What a bus is, and two boards talking over one wire.
  • Addresses, pull-ups, and two chips of every kind on two wires.
  • A clock, a data line and a chip select: screens and an SD card.
  • Read a real transfer, bit by bit, on the logic analyzer.
  • A weather station that reads, sends, shows and logs on all three buses.

Materials for the whole unit

  • Arduino Uno R3 x 2
  • Character LCD with I2C backpack
  • Four-digit display, TM1637
  • Full-size breadboard
  • Half breadboard
  • I2C multiplexer, TCA9548A
  • IPS display, ST7789
  • LED
  • Logic analyzer, four channels
  • LoRa module, SX1278 (Ra-02) x 2
  • microSD card module
  • OLED display, 128x64 x 2
  • Potentiometer
  • Pressure, humidity and temperature, BME280 x 2
  • Real-time clock, DS3231
  • Resistor x 2
  • Temperature sensor, DS18B20
  • TFT display, 1.8 inch ST7735

Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.

Chapter 1. About 40 min

Buses and UART

What a bus is, and two boards talking over one wire.

LessonTimeWhat students do
What a bus is, and UART between two boardsTwo Unos on one wire and a shared ground: what a bus is, how a UART frame is timed with no clock wire, and how the receiving board filters the messages it cares about.40 min
  1. Run it: two boards, one wire
  2. So what is a bus?
  3. A frame with no clock
  4. Turn the throttle
  5. Talk to the dash yourself
  6. Filtering: everyone hears everything

Materials

  • Arduino Uno R3 x 2
  • Character LCD with I2C backpack
  • Half breadboard
  • Potentiometer

Check for understanding

Each student finishes "What a bus is, and UART between two boards" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Filtering: everyone hears everything".

Chapter 2. About 1 h 10 min

I2C: two wires, many chips

Addresses, pull-ups, and two chips of every kind on two wires.

LessonTimeWhat students do
I2C: who is on the bus?Two wires, many chips: seven-bit addresses, the acknowledge bit, why I2C needs pull-up resistors, and the scanner sketch every maker runs first on a new board.35 min
  1. Run the scanner
  2. Nobody drives high: the pull-ups
  3. Addresses and the ninth bit
  4. Move the OLED
  5. How fast is a scan?
A BME280 and an SSD1306 sharing the busA weather sensor and a screen on the same two wires, then two of each with the same addresses, kept apart by a TCA9548A multiplexer. Read a real sensor and draw on a real screen.35 min
  1. Run it: indoor and outdoor
  2. The clash, and the switchboard
  3. Make it freeze outside
  4. A screen is just memory
  5. Make it yours

Materials

  • Arduino Uno R3
  • Character LCD with I2C backpack
  • Half breadboard
  • I2C multiplexer, TCA9548A
  • Logic analyzer, four channels
  • OLED display, 128x64 x 2
  • Pressure, humidity and temperature, BME280 x 2

Check for understanding

Each student finishes "A BME280 and an SSD1306 sharing the bus" on their own, without opening the hints. The simulator checks 5 of its 5 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Make it yours".

Chapter 3. About 1 h

SPI: fast and simple

A clock, a data line and a chip select: screens and an SD card.

LessonTimeWhat students do
SPI: two color screens, one clockFour wires and a chip select: how SPI clocks bytes out with no addresses, why a screen with no CS pin needs its own wires, and the clock modes that trip everybody up once.25 min
  1. Run it
  2. No addresses, just a wire
  3. A screen with no CS pin
  4. Clock modes, and DC
Logging to an SD card, three buses on one boardA microSD card on SPI, a DS3231 clock on I2C and a DS18B20 on 1-Wire: every five seconds a dated line goes into a CSV file you can open in a spreadsheet.35 min
  1. Run it
  2. The first line
  3. Chip select at work
  4. Read the file back
  5. Warm it up

Materials

  • Arduino Uno R3
  • Full-size breadboard
  • Half breadboard
  • IPS display, ST7789
  • LED
  • microSD card module
  • Real-time clock, DS3231
  • Resistor x 2
  • Temperature sensor, DS18B20
  • TFT display, 1.8 inch ST7735

Check for understanding

Each student finishes "Logging to an SD card, three buses on one board" on their own, without opening the hints. The simulator checks 5 of its 5 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Warm it up".

Chapter 4. About 35 min

See the bus

Read a real transfer, bit by bit, on the logic analyzer.

LessonTimeWhat students do
See the bus on the logic analyzerClip a logic analyzer on SDA and SCL and read a real I2C transfer bit by bit: START, address, ACK, data, STOP. Then meet a bus that looks like I2C and is not.35 min
  1. Run it
  2. Catch some traffic
  3. Read one transfer
  4. Numbers in BCD
  5. A bus that only looks like I2C

Materials

  • Arduino Uno R3
  • Four-digit display, TM1637
  • Half breadboard
  • Logic analyzer, four channels
  • Real-time clock, DS3231

Check for understanding

Each student finishes "See the bus on the logic analyzer" on their own, without opening the hints. The simulator checks 5 of its 5 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "A bus that only looks like I2C".

Chapter 5. About 40 min

Boss project

A weather station that reads, sends, shows and logs on all three buses.

LessonTimeWhat students do
Boss: a weather station on three busesA BME280 node reads the weather over I2C and sends it over an SPI radio; a gateway shows it on an I2C screen and logs every reading over UART. Every bus in the course, in one build.40 min
  1. Run the station
  2. A reading, sent and acknowledged
  3. The log
  4. Change the weather
  5. On the screen
  6. Make it your station

Materials

  • Arduino Uno R3 x 2
  • Character LCD with I2C backpack
  • LoRa module, SX1278 (Ra-02) x 2
  • Pressure, humidity and temperature, BME280

Check for understanding

Each student finishes "Boss: a weather station on three buses" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Make it your station".

Your class

Teach this unit as a class

Start a class from this course and its 7 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.

The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.