I have a doubt about the setting of I2C speed and the sample rate in a sensor like MPU6050. Is there a relationship between them ? How to set them correctly ?
This doubt derives from a thread I have read on this forum:
Your MPU allows a sample rate of 8kHz only for the gyrometer, the accelerometer allows only 1kHz.
Given you use 400kHz I2C speed, the highest data rate to read all values is theoretically 2.61kHz, 2.96kHz if you omit the temperature reading (15 bytes must be transmitted, needing 9 clocks each). That's a theoretical maximum that is practically never reached.
If you read only the gyro values (as the accelerometer values aren't that fast anyway) you may reach about 7kHz.
What do you want to do with these high speed readings? Do you really need them? What software do you use (standard libraries won't be near these maximum values)?
Gmork:
I am sorry I do not understand how do you have done that calculation: 400kHz ---> 2.61kHz or 2.96kHz, why 9 clocks each ? Thank you for the patience.
400 / 17 / 9 = 2.61
To read out all values you need to transfer 17 bytes over the I2C bus if you use sequential read and transmitting one byte needs 9 clock cycles (8 bits and the acknowledge signal)
I am using python and smbus library
Hmmh, so I guess you took the wrong forum. Python doesn't run on the Arduino. My calculations were for a microcontroler like the Arduino that has hardware support for I2C. Most embedded Linux systems do I2C using bit-banging so you won't reach the maximum bus capacity, probably won't even come near to it.