Mattéo Pozzo di Borgo
Microengineering — between electronics, embedded systems and fabrication.
← Project timeline
CPNV project

Exploring the I²C bus

A test bench, then a PCB designed in KiCad, to understand the I²C bus and the devices you can connect to it.

Period
Feb – Mar 2024
Context
Engineering preparatory year · CPNV — MCT (technical bridging year), electronics course, mid-sized project M2446 (capstone of the programming course)
Team
Pair project
Status
Completed
I²CArduinoC++KiCadOscilloscopeMCP23017RTC
Final I²C device on its PCB
The finished product on its PCB

Key points

  • Studied the I²C signal on the oscilloscope: SDA / SCL lines, frames and addresses
  • Tested several devices: display, temperature sensor, EEPROM memory, output expander chips
  • Went from a breadboard prototype to a PCB designed in KiCad
  • Six-program menu, I²C address scanner and an audible alarm if a slave stops responding

Context and goal

Each pair was given a topic to wrap up the programming course; ours was the I²C bus. The goal: understand in depth how it works — the protocol, addressing and the components you can connect to it.

What I did

  • Studied the I²C signal on the oscilloscope: SDA and SCL lines, frames, addresses
  • Built and debugged the device on a breadboard (test bench)
  • Tested several I²C devices: a display, a temperature sensor, an EEPROM memory and expander chips to drive outputs
  • Designed and produced the PCB in KiCad, learning the whole manufacturing chain along the way
  • Wrote the entire Arduino program; a pair project with Guilhem Rozier Vilardell

Tech

Arduino · C++ · KiCad · oscilloscope · display, temperature sensor, EEPROM, I/O expanders

Specifications

The shield plugs onto an Arduino MEGA 1280. It brings together, on a single I²C bus, an MCP23017 I/O expander, a temperature sensor, a real-time clock and an extension connector. A display, four buttons and a small speaker make up the interface.

I²C bus diagram: the Arduino MEGA connected via SDA and SCL to the MCP23017 (0x27), the MCP9808 (0x18), the DS3231 (0x68) and the extension connector; the SSD1351 display uses SPI
RequiredDelivered
Menu: temperature, time, MCP23017 I/O, memorySix-program menu
Control every MCP23017 output (8 inputs, 8 outputs)Done
Test every I²C address and list the slavesScanner for addresses 1 to 126
Alarm if a slave does not respond (880 Hz, 3 s)Alarm alternating between 800 Hz and 100 Hz while the bus is incomplete
TC74 sensorMCP9808 in the final version
External 24LC01 memory, reset to FFh at start-upArduino's internal EEPROM, reset to 0

The external memory was not part of the final validation, as the program header states.

The program

You scroll through the six programs with UP and DOWN, enter with ENTER and leave with EXIT: temperature, time and date, MCP23017 control, memory, I²C scanner and free text saved to memory.

In parallel, every 500 ms, the program rescans all 126 addresses. If it finds fewer than three slaves, the speaker sounds; when a device is plugged in or removed, it gives a rising or falling beep. At start-up, holding UP and DOWN for more than 2 s erases the whole memory.

The I²C bus on the oscilloscope

In our study, we measured the SDA (data) and SCL (clock) lines on the oscilloscope, using test points designed into the board. You can see the start condition (SDA goes low while SCL is high), the slave address, the data and the stop condition.

We can also estimate, in theory, how long a scan takes. At 100 kHz, the Arduino's default frequency, one bit lasts 1 / 100,000 = 10 µs. Testing an address takes about 11 bits (start, 7 address bits, read/write, acknowledge, stop), i.e. 11 × 10 µs = 110 µs. A full scan therefore takes 126 × 110 µs ≈ 13.9 ms and, repeated every 500 ms, it occupies the bus about 13.9 / 500 ≈ 2.8 % of the time.

Oscilloscope capture of the SDA and SCL lines during an I²C transfer

Result

A finished device on a PCB, with a display, onto which more devices can be added along the I²C chain.

What I took away

Going from code to the real signal seen on the oscilloscope, then from a breadboard prototype to a manufactured PCB. It gave me a complete view of an electronic system, from design to fabrication.