I2c connection timing out

Board: PYNQ-Z2
PYNQ Version: 3.0.1
Bitstream: base.bit

I am trying to talk to a device or I2C. The device is the LIS3DH accelerometer from Adafruit.

I can communicate with the device using a basic arduino through the arduino ide.

However, when I try connecting to my PYNQ board using the arduino pins, I cannot get it to communicate.

First, when trying to use the linux command i2cdetect (through the terminal connected to the PYNQ board) I get the following:

i2cdetect -y 0

00:
10:
20:
30: cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
--
40:
50: cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
--
60:
70:

i2cdetect -y 1

00:
10:
20:
30: -- -- -- -- -- -- -- --
40:
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60:
70:

Alternatively, I try to use SMBus through a Jupyter notebook (need to install smbus2 library in python on the board first)

from smbus2 import SMBus

with SMBus(0) as bus:
    data = bus.read_byte_data(0x18, 0x0F)
    print(f"Device ID: 0x{data:02X} (should be 0x33 for LIS3DH)")

Results:

I get the following error:

TimeoutError: [Errno 110] Connection timed out

And it is linked to the read line.

Also, when I do this I see the message cdns-i2c e0004000.i2c: timeout waiting on completion appear in the terminal connected to the PYNQ board.

So it is essentially the same error.

Is the I2C connection on the arduino part of the PYNQ board not enabled by default in the base.bit overlay? If not, how do I enable it. Or is there an alternative way to do this using the PMOD pins or something else that I can get working with the base overlay?

Hi @nmercer,

Welcome to the PYNQ community.

The Arduino pins are not mapped to the PS, so, you will not be able to control them directly.

Please, check the IOP libraries.

You can also check the GitHub - Xilinx/PYNQ_Peripherals to see how to create your own driver.

Mario

Would you mind sharing your Block Diagram?

I am using the base overlay, so unfortunately there is not block diagram to share.

Edit: I just noticed that you were not replying to me. Sorry for that.

I was replying to you. Do you absolutely need to use the base overlay? otherwise Id say look into the AXI IIC ip.

I was hoping to use the base overlay. But if I can’t do I2C using the base overlay, then I guess I will have to create a custom overlay with the AXI IIC.
Thanks

i think using the axi iic might be a good way to go. Let me know if you need additional help.