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.
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.
Buses and UART
What a bus is, and two boards talking over one wire.
| Lesson | Time | What 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 |
|
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".
I2C: two wires, many chips
Addresses, pull-ups, and two chips of every kind on two wires.
| Lesson | Time | What 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 |
|
| 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 |
|
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".
SPI: fast and simple
A clock, a data line and a chip select: screens and an SD card.
| Lesson | Time | What 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 |
|
| 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 |
|
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".
See the bus
Read a real transfer, bit by bit, on the logic analyzer.
| Lesson | Time | What 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 |
|
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".
Boss project
A weather station that reads, sends, shows and logs on all three buses.
| Lesson | Time | What 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 |
|
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".
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.