I want to receive data from MPU-6050 which connect to arduino through I2C. Is it possible to use arduino timer1 interrupt to getting data from this sensor for example every 100 ms?
I read somewhere that is not possible to use "Wire.h" inside the interrupt.
There is an INT-pin (open drain) with the MPU6050 Module. This pin goes high whenever a new data is available in the sensor. You can run TC1 of the MCU for the generation 100 ms Time Tick (TT). At the end of 100 ms TT, you can check if INT has gone HIGH and then read data from the sensor. After reading data, reset the INT-pin issuing software command to the relevant register of the sensor. Or, you can use the INT-pin to interrupt the MCU and then read the data from the sensor.
GolamMostafa:
There is an INT-pin (open drain) with the MPU6050 Module. This pin goes high whenever a new data is available in the sensor. You can run TC1 of the MCU for the generation 100 ms Time Tick (TT). At the end of 100 ms TT, you can check if INT has gone HIGH and then read data from the sensor. After reading data, reset the INT-pin issuing software command to the relevant register of the sensor. Or, you can use the INT-pin to interrupt the MCU and then read the data from the sensor.
So you mean there is no way to use timer interrupt to connect to mpu and read data? Because I need both interrupt pins (2,3) of Uno for other sensors. Also, because I want to measure the viberation of motor, there is always new data and I don't need all of them.