Uno Master I2C Pi Slave

I have an application in which I wish to run an Arduino Uno as an I2C master to both another Uno and a Raspberry Pi running python. I am successful sending to the Uno but not to the Pi which raises a Remote I/O Error on the first read. I have included a bi-directional logic level converter to step down the voltage on SDA and SCL.

An I2cdetect -y 1 on the Pi detects the slave Uno, so it would appear that the I2C connections are correct

The Arduino code:

#include <Wire.h>

#define PI_ADDRESS 0x08
#define UNO_ADDRESS 0x04

void setup(){
Serial.begin(9600);
Wire.begin(0x00);

}

void loop(){
sendData(UNO_ADDRESS, 1);
delay(1000);
sendData(PI_ADDRESS, 1);
delay(1000);
sendData(UNO_ADDRESS, 0);
delay(1000);
sendData(PI_ADDRESS, 0);
delay(1000);
}

void sendData(int Address, byte sendByte){
Wire.beginTransmission(Address);
Wire.write(sendByte);
Wire.endTransmission(true);
Serial.println(sendByte);
}

And the python code

#!/usr/bin/env python
from time import sleep
import smbus
bus = smbus.SMBus(1)
address = 0x08

sleep (2)

while 1:
data = bus.read_byte(address)
print(data)
sleep(0.5)

Execution results in an IOError: [Errno 121] Remote I/O Error

Any insights that you might have would be appreciated

Can you find an example of someone that has the Raspberry Pi working as a I2C Slave ?
There are a few efforts and some have it working, but I think that the Raspberry Pi should be the Master.

If you connect the Arduino with a USB cable to the Raspberry Pi, then you can use the Serial port. The I2C bus is not a good bus between processors.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.