Raspberry Pi User Help

I2C instabillity between a pair of Raspberry Pi

I have a connected a Raspberry Pi Zero (1.3, no W, running Raspbian 10 (buster) lite) as an I2C slave (clock:GPIO18,data:GPIO19) to a Raspberry Pi 3b (running Ubuntu 20.04.1) as an I2C master(clock:GPIO3,data:GPIO2).

  • The wiring is Dupont style connectors of approximately 20cm length connected directly between the GPIO headers.
  • The only configuration done is to uncomment the dtparam=i2c_arm=on in the config.txt of the boot/firmware directory on both the raspberry pi 3B and the Zero.
  • Packages installed are python3-pigpio and dependencies on the Pi Zero, and python3-smbus on the Pi 3b.

There is barely any load on either of the nodes:

samveen@pi3:~$ cat /proc/loadavg
0.00 0.00 0.00 1/171 2538
pi@pi0:~$ cat /proc/loadavg
0.20 0.21 0.18 1/81 720

The connection works when tested with the python3-pigpio I2C slave example and a simple python3-smbus script on the master:

    #!/usr/bin/env python3
    import smbus
    import time

    DEVICE_BUS = 1
    DEVICE_ADDR = 0x09
    bus = smbus.SMBus(DEVICE_BUS)

    def sendData(slaveAddress,reg,data):
        intsOfData = list(map(ord, data))
        bus.write_i2c_block_data(DEVICE_ADDR, reg, intsOfData)

    for c in '0123456789abcdef01234567890abcdef0':
        print("sending {} bytes".format(len(message)))


  • The communication is rock solid up while message length is 16 bytes or less.
  • Messages longer than 16 bytes do not deliver reliably: the first 16 bytes get delivered fine, but anything past that is non-deterministically received. Out of the 32 messages sent per run of the above script, the best run had only 3 of the 16 longer-that-16-byte messages received correctly.


  • What can I do to improve the I2C communication between the 2, so that I have completely reliable messaging?


Leave a Reply

Your email address will not be published. Required fields are marked *