MPU 9150 Code on Github - Interrupt Pin usage

Hi all,

I’m using Kris Winers code (great work, helped me a lot!) for my MPU9150 and have a question:

What is the interrupt pin really used for?
It is defined in line 211 and set to low in line 262 but afterwards not really used, attached as interrupted or anything like that. It is mentioned again in the comment (line 377)…but I don’t really get it:

 // If intPin goes high or data ready status is TRUE, all data registers have new data
  if (readByte(MPU9150_ADDRESS, INT_STATUS) & 0x01) {  // On interrupt, check if data ready interrupt

Thanks for any help in advance and all the best
Tim

ps: Just for ease: Attached is the respective section of the MPU9150 register map

This is the normal way (used in i2cdevlib with dmp):
The 'dmp' is programmed at a sample rate of 100Hz, the interrupt causes an interrupt in the Arduino (attachInterrupt() is used) and then the Arduino reads data from the sensor.

Another use is by setting a threshold which causes an interrupt.

In Kris Winers code, the Arduino does not get an interrupt. The 'intPin' is not used yet. However, the sensor interrupt is set for a motion threshold. Instead of using an Arduino interrupt, the interrupt status inside the sensor is read by polling with "readByte ( MPU9150_ADDRESS, INT_STATUS )".

You could connect the interrupt output of the sensor to an Arduino pin, and poll that pin. Or connect it to an external Arduino interrupt pin and use attachInterrupt() and a interrupt handler.

Thank a lot for your answer!

I think I don't need an interrupt, so its perfect for me and I will delete the respective lines (211 & 262). I will just read the sensor on a regular basis since I also have to log some other sensor values to an SD card "inbetween".

I will possibly run into a FIFO overflow, but I think I can reset the FIFO and ignore the warning. As far as I understood: the Madgwick Filter should be OK also at low rates (~10Hz).

Thanks again!

As long as you do nothing funny in the sketch, then polling should work for low sample rates.

Perhaps the sensor interrupt register is only polled for new data. The motion interrupt is perhaps not used (I didn't check the datasheet).
The baudrate is 38400, but when SerialDebug is active there are many Serial prints. That slows down the sketch and lowers the maximum data rate.