问题描述
我一直在研究一些i2c示例.将其全部连接在一起,我发现我需要安装i2c-tools软件包,然后使用raspi-config启用I2C系统.
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.
connectionPi gpio命令具有i2cdetect命令的快捷方式,运行该命令即可提供
The wiringPi gpio command has a shortcut to the i2cdetect command and running it gives
在3周前一切正常,检测到68.我不明白是什么问题!!!谁能帮助我解决这个问题.
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.
推荐答案
I2C总线允许将多个设备连接到您的Raspberry Pi,每个设备都有唯一的地址,通常可以通过更改模块上的跳线设置来进行设置.能够查看已将哪些设备连接到Pi上,以确保一切正常,这是非常有用的.
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.
为此,值得在终端中运行以下命令来安装i2c-tools实用程序.
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
如果您不使用现代的Raspbian或想手工制作,可以!打开LXTerminal或控制台或ssh并输入以下命令:
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
然后使用Control-X Y保存文件
Then save the file with Control-X Y
根据您的发布,您可能还会有一个名为/etc/modprobe.d/raspi-blacklist.conf
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
如果您正在运行最新的Raspberry Pi(3.18内核或更高版本),则还需要更新/boot/config.txt file
.用sudo nano /boot/config.txt
进行编辑并添加文字
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
在底部.请注意,"i2c1"中的"1"不是L!
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
请注意,如果您使用的是最早的Raspberry Pis(256MB Raspberry Pi Model B)之一,则需要将命令更改为:
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
这篇关于I2C没有检测到?硬件或其他任何问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!