Enable and verify Raspberry Pi I2C bus i2c-1 for 3.3V sensors
Enable i2c-1 on Raspberry Pi OS, wire 3.3V sensors to GPIO 2 and 3, and verify the bus with i2cdetect.
18 Nov 2025, 06:53 UTC

Useful answer
If your I2C sensor is wired to GPIO 2 and GPIO 3 but the bus does not appear, the most likely cause is that Raspberry Pi OS disables the i2c-1 controller by default. Enable it with a device-tree parameter in the firmware boot configuration, reboot, then confirm the bus with i2cdetect. Keep every signal at 3.3V logic; the Raspberry Pi GPIO pins are not 5V tolerant.
How the I2C bus is exposed
I2C is a two-wire serial bus: SDA carries data and SCL carries the clock. Devices use 7-bit addresses, and the open-drain lines rely on pull-up resistors to return to a high logic level. On Raspberry Pi OS, the user-accessible bus is normally /dev/i2c-1, mapped to GPIO 2 (SDA) and GPIO 3 (SCL). The i2c-0 bus is typically reserved for HAT EEPROM or camera detection and should not be repurposed for general sensors.
Worked configuration: enable i2c-1
Run these commands on the Raspberry Pi itself. You need root privileges, so use sudo. The exact boot partition path depends on the OS release.
1. Identify the mounted boot configuration file
mount | grep boot ls /boot/firmware
On Raspberry Pi OS Bookworm and later, the firmware configuration is usually /boot/firmware/config.txt. On earlier releases, it is typically /boot/config.txt. Editing the wrong path leaves I2C disabled after reboot with no warning.
2. Back up and edit the configuration
sudo cp /boot/firmware/config.txt /boot/firmware/config.txt.bak sudo nano /boot/firmware/config.txt
Add or uncomment this line:
dtparam=i2c_arm=on
Save and exit. If you are on an earlier release and /boot/firmware does not exist, use /boot/config.txt instead.
3. Reboot
sudo reboot
4. Install userspace tools and verify
sudo apt update sudo apt install i2c-tools
After the Pi restarts, check that the device node exists:
ls /dev/i2c*
Expected result: /dev/i2c-1 is listed. If the directory is empty, the kernel module may not be loaded:
sudo modprobe i2c-dev lsmod | grep i2c_dev
To make the module load automatically, create /etc/modules-load.d/i2c.conf containing i2c-dev.
Now scan the bus:
sudo i2cdetect -y 1
A working bus prints an address grid. Connected devices appear as their 7-bit hexadecimal addresses. A UU entry means a kernel driver has already claimed that address, which is normal for some onboard devices. An error such as "No such file or directory" usually means i2c-dev is not loaded or /dev/i2c-1 does not exist.
Wiring and electrical limits
- All Raspberry Pi I2C signals are 3.3V logic. Do not connect a 5V sensor directly to GPIO 2 or GPIO 3; use a bidirectional level shifter and connect the grounds.
- The Pi's internal pull-ups are weak. For long wires, multiple devices, or unreliable detection, add external pull-up resistors from SDA and SCL to 3.3V, commonly 2.2 kΩ to 4.7 kΩ.
- Do not use
i2c-0for user peripherals on models where it serves HAT detection; this can break overlay loading.
Common mistakes and rollback
- Wrong config path: editing
/boot/config.txton a Bookworm system that boots from/boot/firmware/config.txtsilently does nothing. Confirm the mounted path first. - Missing sudo:
i2cdetectrequires root access to the device node. - 5V damage: connecting 5V logic directly to a GPIO pin can damage the board.
Because editing config.txt changes system state, rollback is straightforward: restore the backup, remove the dtparam=i2c_arm=on line, save, and reboot.
sudo cp /boot/firmware/config.txt.bak /boot/firmware/config.txt sudo reboot
Practical verification
After reboot, run ls /dev/i2c-1 and sudo i2cdetect -y 1. If the device node exists and the command prints an address grid instead of an error, the bus is active. If a sensor does not appear, check its address in the datasheet, confirm pull-ups are present, and verify the wiring is at 3.3V logic.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.