I2C beetween Due and Uno and Mega

I have an Uno as master and a Mega as slave.
Everything works with Wire.h, when I connect
UNO A4 <=> MEGA 20 SDA
UNO A5 <=> MEGA 21 SCL

I want to add a Due as a slave,
But I am worried with the DUE I2C interface (Sam3x8e) which is different from Uno, and these
'integrated pull-ups' (Arduino Due I2C bus lock up - #2 by ard_newbie)

Is it safe to wire it like this?
DUE 20 <=> UNO A4 <=> MEGA 20 SDA
DUE 21 <=> UNO A5 <=> MEGA 21 SCL

My Uno master starts with:

 Wire.begin(0);
 Wire.onReceive(receiveEvent);

and mega starts with :

#define SLAVE_ADDR 5
Wire.begin(SLAVE_ADDR);
Wire.onReceive(receiveEvent);

can I start due with

#define SLAVE_ADDR 6
Wire.begin(SLAVE_ADDR);
Wire.onReceive(receiveEvent);

I send and recive with uno

 Wire.beginTransmission(SLAVE_ADDR);
 Wire.write((byte *)&txData, sizeof(txData));
 Wire.endTransmission(true);

Wire.readBytes((byte *)&rxData, sizeof(rxData));

and mega

Wire.beginTransmission(0);
Wire.write((byte *)&txData, sizeof(txData));
Wire.endTransmission(true);

Wire.readBytes((byte *)&rxData, sizeof(rxData));

Can I just change the SLAVE_ADDR for my due slave to communicate with uno ?
I am a beginner enthusiast, please keep it simple when explaining :slight_smile:

You'll need I2C level shifters between the 3.3V and 5V controllers.

Addresses below 8 are reserved, use higher addresses.

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