I2C not detecting ? issues in hardware or any other?

时间秒杀一切 提交于 2019-12-04 14:05:32

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!