Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I2C not detecting ? issues in hardware or any other?

Tags:

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.

like image 530
Jerwin Prabu Avatar asked Mar 20 '17 13:03

Jerwin Prabu


1 Answers

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
like image 60
Sirajo Abubaka Zauro Avatar answered Sep 24 '22 10:09

Sirajo Abubaka Zauro