5

I have been working through some i2c examples. Plugging it all together and I find that I need to install the i2c-tools package, then use raspi-config to enable the I2C system.

The wiringPi gpio command has a shortcut to the i2cdetect command and running it gives

enter image description here

Before 3 weeks everything working properly, detected 68. I didn't understand what is the problem !!! Can anyone one help me to solve this issue.

Jerwin Prabu
  • 336
  • 1
  • 3
  • 16

2 Answers2

5

The I2C bus allows multiple devices to be connected to your Raspberry Pi, each with a unique address, that can often be set by changing jumper settings on the module. It is very useful to be able to see which devices are connected to your Pi as a way of making sure everything is working.

To do this, it is worth running the following commands in the Terminal to install the i2c-tools utility.

sudo apt-get install -y python-smbus
sudo apt-get install -y i2c-tools

If you're not using a modern Raspbian or you want to do it by hand, you can! Open LXTerminal or console or ssh and enter the following command:

sudo nano /etc/modules

and add these two lines to the end of the file:

i2c-bcm2708
i2c-dev

Then save the file with Control-X Y

Depending on your distribution, you may also have a file called /etc/modprobe.d/raspi-blacklist.conf

If you do not have this file then there is nothing to do, however, if you do have this file, you need to edit it and comment out the lines below:

blacklist spi-bcm2708
blacklist i2c-bcm2708

.. by putting a # in front of them.

Open an editor on the file by typing:

sudo nano /etc/modprobe.d/raspi-blacklist.conf

If you are running a recent Raspberry Pi (3.18 kernel or higher) you will also need to update the /boot/config.txt file. Edit it with sudo nano /boot/config.txt and add the text

dtparam=i2c1=on
dtparam=i2c_arm=on

at the bottom. note that the "1" in "i2c1" is a one not an L!

Once this is all done, reboot!

Now when you log in you can type the following command to see all the connected devices

sudo i2cdetect -y 1

Note that if you are using one of the very first Raspberry Pis (a 256MB Raspberry Pi Model B) then you will need to change the command to:

sudo i2cdetect -y 0
ipatch
  • 3,933
  • 8
  • 60
  • 99
  • Ya exactly @Sirajo that is working fine. Now it displayed I2C address 0x68. – Jerwin Prabu Mar 12 '18 at 08:05
  • If you try that that will work fine, otherwise you have to check your hardware interface and wire connection. – Sirajo Abubaka Zauro Mar 12 '18 at 08:08
  • @SirajoAbubakaZauro, unfortunately, I do not have raspi-blacklist.conf file. Is there any other way around? It is weird in my case that I can read in data from sensors, but detect no i2c address... – ycenycute Mar 12 '19 at 19:05
  • @TracyYang Rasbian removed the whole default raspi-blacklist.conf file sometime ago. Instead of editing the /boot/config.txt and adding line: `dtparam=spi=on`. So after reboot you can see `/dev/spidev0.0` – Sirajo Abubaka Zauro Apr 12 '19 at 05:54
0

Try sudo i2cdetect -y 1 or sudo i2cdetect -y 0 (if you using old Raspberry Pi) and run it on root. Open terminal and run command sudo su, then run sudo i2cdetect -y 1

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 06 '22 at 03:36