i2c between two Arduinos and MPU6050 problem.

Hello all,

I have spent the last couple of days working with i2c between my Mega , and Uno blinking LEDs. I wish to move further, and learn how to move a potentiometer with the master (Mega), and have the values sent to the slave (Uno) so it will move a servo. Does anyone have ANY sample codes for this?

My main question is beacuse the master and slave communicate via SCL, SDA with pull up resistors. Is it possible to connect a MPU6050 (witch uses the SCL, and SDA to communicate ) to the slave, and read the values from the master?

If so how is this done?

And if anyone has any examples with i2c Master, and slave communication with sensors, motor controll or anything I can use to learn from. Please post.

Thank you all.

Does anyone have ANY sample codes for this?

Yes, Nick Gammon has:

Is it possible to connect a MPU6050 (witch uses the SCL, and SDA to communicate ) to the slave, and read the values from the master?

Yes, it is.

If so how is this done?

Connect SDA, SCL and GND on all three devices and take care that you have the pull-ups only once and that they go to the lowest supply voltage of all three devices. Choose the pull-ups so that the active device has to sink not more than 2mA.

The I2C bus can have only one Master (or one Master at a time).

When the Slave is retrieving data from the MPU-6050 (using I2C) and the Master requests data from the Slave at that very moment, there is a collision on the I2C bus. That is not allowed.

So the answer is "no", you can not use it like that.

When the Slave is retrieving data from the MPU-6050 (using I2C) and the Master requests data from the Slave at that very moment, there is a collision on the I2C bus. That is not allowed.

Reading the OP's sentence:

Is it possible to connect a MPU6050 (witch uses the SCL, and SDA to communicate ) to the slave, and read the values from the master?

I clearly see that the master reads the values not the slave. On which side of the bus the device is connected to the bus lines is not important, given the bus length does not exceed about half a meter.