<tfoot id='jtuR6'></tfoot>
    1. <i id='jtuR6'><tr id='jtuR6'><dt id='jtuR6'><q id='jtuR6'><span id='jtuR6'><b id='jtuR6'><form id='jtuR6'><ins id='jtuR6'></ins><ul id='jtuR6'></ul><sub id='jtuR6'></sub></form><legend id='jtuR6'></legend><bdo id='jtuR6'><pre id='jtuR6'><center id='jtuR6'></center></pre></bdo></b><th id='jtuR6'></th></span></q></dt></tr></i><div id='jtuR6'><tfoot id='jtuR6'></tfoot><dl id='jtuR6'><fieldset id='jtuR6'></fieldset></dl></div>

        <small id='jtuR6'></small><noframes id='jtuR6'>

      1. <legend id='jtuR6'><style id='jtuR6'><dir id='jtuR6'><q id='jtuR6'></q></dir></style></legend>
        • <bdo id='jtuR6'></bdo><ul id='jtuR6'></ul>

      2. 树莓派 i2c 读/写错误

        时间:2023-12-03
            <i id='8Bi0F'><tr id='8Bi0F'><dt id='8Bi0F'><q id='8Bi0F'><span id='8Bi0F'><b id='8Bi0F'><form id='8Bi0F'><ins id='8Bi0F'></ins><ul id='8Bi0F'></ul><sub id='8Bi0F'></sub></form><legend id='8Bi0F'></legend><bdo id='8Bi0F'><pre id='8Bi0F'><center id='8Bi0F'></center></pre></bdo></b><th id='8Bi0F'></th></span></q></dt></tr></i><div id='8Bi0F'><tfoot id='8Bi0F'></tfoot><dl id='8Bi0F'><fieldset id='8Bi0F'></fieldset></dl></div>
              <tbody id='8Bi0F'></tbody>
            <tfoot id='8Bi0F'></tfoot>
              <bdo id='8Bi0F'></bdo><ul id='8Bi0F'></ul>
              <legend id='8Bi0F'><style id='8Bi0F'><dir id='8Bi0F'><q id='8Bi0F'></q></dir></style></legend>

              • <small id='8Bi0F'></small><noframes id='8Bi0F'>

                • 本文介绍了树莓派 i2c 读/写错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  像许多人一样,我使用 Pi 已经有一段时间了,但从未真正用它做过任何事情.我终于有时间连接一个 MPU6050 IMU 来玩了.它使用 i2c 进行通信,所以我遵循了 Adafruit 的指南关于启用此处显示的 i2c

                  然后下载官方的 Adafruit 库:

                  • C++
                  • Python

                  使用$ sudo raspi-config检查树莓派的I2C是否启用,并确保I2C地址正确,另外使用$ i2cdetect -y 1检查,像这样:

                  尝试:总线 = Adafruit_I2C(地址=0)打印(默认 I2C 总线是可访问的")除了:print("访问默认I2C总线时出错")mcp = 无对于我在范围内(0x00,0x28):尝试:mcp = Adafruit_MCP230XX(address=i, num_gpios=16)休息除了:经过

                  Like many people, I've had a Pi for a while but never really done anything with it. I've finally got round to hooking up an MPU6050 IMU to play around with. It uses i2c for communication so I followed the guide by Adafruit regarding enabling i2c shown here Adafruit i2c.

                  I then hooked up the MPU6050 to the i2c bus, and using i2cdetect -y 1 I was able to see a device at 0x68.

                  However, when trying to read or write from the device I got a permission denied error, so I followed this post to solve that problem /dev/i2c-x permission. It told me to modify /lib/udev/rules.d/60-i2c-tools.rules with

                  KERNEL=="i2c-0"     , GROUP="i2c", MODE="0660"
                  KERNEL=="i2c-[1-9]*", GROUP="i2c", MODE="0666"
                  

                  This worked, but then when actually trying to read or write using C++, I get "Input/output error". Similarly, using smbus in Python I get [Errno 5] Input/output error When connected to an Arduino I can get this device to work perfectly.

                  I've exhausted every forum post I can find. Hopefully I've just done something stupid. Anyone got any ideas?

                  Original model B RPi running Raspbian, if that's of any help.

                  Cheers

                  解决方案

                  In normal cases you don't really need to change the /lib/udev/rules.d/60-i2c-tools.rules file, so I would recommend resinstalling raspbian.

                  Connect the MPU6050 to the correct pins:

                  Then download an official Adafruit library:

                  • C++
                  • Python

                  Check if the Raspberry Pi's I2C is enabled with $ sudo raspi-config and make sure the I2C address is correct, besides checking it with $ i2cdetect -y 1, like this:

                  try:
                    bus = Adafruit_I2C(address=0)
                    print("Default I2C bus is accessible")
                  except:
                    print("Error accessing default I2C bus")
                  
                  mcp = None
                  
                  for i in range(0x00, 0x28):
                      try:
                          mcp = Adafruit_MCP230XX(address=i, num_gpios=16)
                          break
                      except:
                          pass
                  

                  这篇关于树莓派 i2c 读/写错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:OpenCV 是在没有 CUDA 视频解码支持的情况下构建的 下一篇:返回 C++ 引用变量的做法是否邪恶?

                  相关文章

                    <bdo id='wH4zG'></bdo><ul id='wH4zG'></ul>

                • <i id='wH4zG'><tr id='wH4zG'><dt id='wH4zG'><q id='wH4zG'><span id='wH4zG'><b id='wH4zG'><form id='wH4zG'><ins id='wH4zG'></ins><ul id='wH4zG'></ul><sub id='wH4zG'></sub></form><legend id='wH4zG'></legend><bdo id='wH4zG'><pre id='wH4zG'><center id='wH4zG'></center></pre></bdo></b><th id='wH4zG'></th></span></q></dt></tr></i><div id='wH4zG'><tfoot id='wH4zG'></tfoot><dl id='wH4zG'><fieldset id='wH4zG'></fieldset></dl></div>
                  <tfoot id='wH4zG'></tfoot>

                  <legend id='wH4zG'><style id='wH4zG'><dir id='wH4zG'><q id='wH4zG'></q></dir></style></legend>

                      <small id='wH4zG'></small><noframes id='wH4zG'>