Little Bird Terminal Recordings real sessions you can scrub, not screenshots Import a recording
Enabling I2C on a Raspberry Pi 5 with raspi-config 0:13 · 98×30 · 5 views Download .cast Embed view

The scriptable way to enable I2C, captured on a real Raspberry Pi 5 Model B running Raspberry Pi OS Bookworm. If you are following along by hand you probably want the menu version instead, at /casts/ZeaglDboWNM — this one is the same job done in one line, which is what you need for a setup script or an image build. I2C is genuinely off at the start: line 6 of /boot/firmware/config.txt is commented out, there is no /dev/i2c-1, and GPIO 2 and 3 are not muxed to anything. The command sudo raspi-config nonint do_i2c 0 is exactly what Interface Options, I5 I2C, Yes runs underneath. raspi-config applies the device-tree parameter live as well as writing it to config.txt, so the bus appears immediately and no reboot is needed. Nothing is wired to the header here, so the closing i2cdetect scan is a working but empty bus.

Commands in this recording

  • 0:00 tr -d '\0' < /proc/device-tree/model; echo Which Raspberry Pi this actually is. The model string is NUL-terminated, hence the tr.
  • 0:01 grep PRETTY_NAME /etc/os-release Which OS release. Bookworm keeps its boot config in /boot/firmware, not /boot.
  • 0:02 sudo raspi-config nonint get_i2c raspi-config's own answer. 1 means disabled, 0 means enabled — the opposite of what you would guess.
  • 0:02 ls /dev/i2c-* Only i2c-13 and i2c-14, which are the Pi 5's internal display buses. The header bus, i2c-1, is missing.
  • 0:03 pinctrl get 2,3 Pins 3 and 5 on the header. Both read "none" — no peripheral is driving them yet.
  • 0:04 grep -n i2c /boot/firmware/config.txt Line 6 is there but commented out: #dtparam=i2c_arm=on. That comment is the whole reason I2C is off.
  • 0:05 sudo raspi-config nonint do_i2c 0 Enable it. Identical to Interface Options, I5 I2C, Yes in the menu, and silent when it works.
  • 0:06 sudo raspi-config nonint get_i2c Now 0. Worth asking, because do_i2c prints nothing at all on success.
  • 0:07 grep -n i2c /boot/firmware/config.txt Same line 6, comment gone: dtparam=i2c_arm=on. This is what survives a reboot.
  • 0:07 grep -n i2c /etc/modules raspi-config also makes sure i2c-dev loads at boot, which is what gives you the /dev nodes.
  • 0:08 ls -l /dev/i2c-1 The header bus, present without a reboot: raspi-config runs dtparam i2c_arm=on live as well as editing config.txt.
  • 0:09 pinctrl get 2,3 The same two pins, now SDA1 and SCL1 in alt mode a3 and pulled high. Physical proof the bus is live.
  • 0:10 lsmod | grep i2c i2c_designware_platform and its core have appeared since the earlier look — the Pi 5's header controller, loaded on demand.
  • 0:11 id -nG | tr ' ' '\n' | grep i2c /dev/i2c-1 is group i2c, so a user in that group talks to the bus without sudo. Log out and back in after being added.
  • 0:11 i2cdetect -y 1 Scan bus 1 for devices. All dashes because nothing is wired to the header here — a working, empty bus. Wire up a sensor and its address shows in the grid.

Embed this recording

Shared from Little Bird Electronics. The file at .cast is a plain asciicast v2 recording — it plays in the asciinema CLI too.