1

I bought this Pi hat for integrating an Arduino with the Pi and exposing all the GPIO pins through nice GVS headers, and overall I'm very happy with it. However, I'm noticing a weird problem.

Without the hat, I wired a BN005 9DOF IMU directly to the Pi, and was able to poll the motion data from the Pi perfectly using this Python code. Yet when I attach the hat and wire the sensor through the I2C 5-pin header, I get the error:

Traceback (most recent call last):
  File "BNO055.py", line 303, in <module>
    if bno.begin() is not True:
  File "BNO055.py", line 199, in begin
    if self.readBytes(BNO055.BNO055_CHIP_ID_ADDR)[0] != BNO055.BNO055_ID:
  File "BNO055.py", line 280, in readBytes
    return self._bus.read_i2c_block_data(self._address, register, numBytes)
IOError: [Errno 5] Input/output error

I can confirm the sensor is detected by running i2cdetect -y 1, which shows:

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- 28 29 2a 2b 2c 2d 2e 2f 
30: 30 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --        

Why is the hat preventing the I2C connection?

The hat appears to have a total of 3 ways to connect via I2C.

  1. A 5-pin header labeled Pi-IIC, which the schematic shows goes directly to the Pi's SDA/SCL pins.
  2. A 4-pin header labeled Pi-ID_IIC that the schematic shows goes to some sort of on-board EEPROM.
  3. The Arduino Leonardo's SDA/SCL pins.

I've tried re-wiring the sensor to all of them, and I get the same error each time.

I read about a bug in the Pi's I2C implementation which doesn't support clock stretching, which the BN005 makes use of. A workaround I've read about is to reduce the Pi's I2C clockspeed down to 50k. However, even though the sensor still works with the hatless Pi, it still doesn't work with the hat.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.