0

I've got a raspberry pi zero (with a fresh install of the current raspian OS) and I'm trying to find the i2c address of a connected display. When I try to scan for devices using i2cdetect -y 1 I get the following error:
bash: i2cdetect: command not found

I've tried the following:

  1. Confirmed that i2c tools and python3-smbus are installed with:
    1. sudo apt-get install i2c-tools
    2. sudo apt-get install python3-smbus
  2. Enabled i2c in sudo raspi-config
  3. Rebooting: Does not help.
1
  • 1
    "with a fresh install of the current raspian OS" What OS is installed (detail including version)? There never has been a "raspian" - current is Raspberry Pi OS Bookworm (but I wouldn't even try this on a Pi Zero). What is CONNECTED?
    – Milliways
    Commented Jul 30 at 0:59

2 Answers 2

0

Interesting... the i2ctools have always behaved a little strangely. For example, if you don't have i2c1 enabled, you get an error like this (on my RPi OS Lite 'bullseye'):

$ i2cdetect -y 1
Error: Could not open file `/dev/i2c-1' or `/dev/i2c/1': No such file or directory

OTOH, if I do have i2c1 enabled, I can run i2cdetect -y 1 without error. I know the error I listed above was not what you saw, but you may want to check that it's i2c1 you have enabled - just to make sure.

Beyond that, here's a couple of things you can try:

  • This will tell you where (if anywhere) i2cdetect is installed:
$ whereis i2cdetect
i2cdetect: /usr/sbin/i2cdetect /usr/share/man/man8/i2cdetect.8.gz
  • This will check your PATH - make sure whatever folder whereis found your i2cdetect in - is on your PATH:
$ $ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games 

Check those & get back to us w/ your findings.

1
  • 1
    thanks for the quick response. /usr/sbin was not in PATH; it's working now that I've added it. Commented Jul 30 at 12:40
2

Adding /user/sbin to the PATH is a better solution, but another option is this python code: python i2cdetect

1
  • 2
    Note that /usr/sbin is a default part of $PATH on pretty much every normal linux distro including Rpi OS -- something weird happened to you. Many common everyday commands are there (you will probably recognize a few things in ls /usr/sbin/). Possibly also worth noting that /sbin is on most contemporary distros (again including Rpi OS) a symlink to /usr/sbin so if one of those is enabled they both will work.
    – goldilocks
    Commented Aug 1 at 18:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.