[solved] IMU/ Depth Sensor code



I recently got the IMU/Pressure sensor for openrov.

Is there some simple test code I can use to get the IMU data? I found an arduino sketch for the pressure sensor which works great! Thanks for that.

I have an onboard raspberry pi and arduino nano, so I cannot use the software available directly. I tried to strip the parts of the sketch for the pressure sensor/IMU from the available code. But I realized the stripped sketch is too big for arduino nano.

Any thoughts?


You will see the MPI9150 code in the arduino library. There are a few dependencies and I have not checked to see how much ram it takes up right now.

The library that we currently incorporate: https://github.com/zeran/MPU9150Lib

The leanest library I have seen: http://playground.arduino.cc/Main/MPU-9150



We use a MPU9150Lib arduino library to use the pressure sensor. An example for my test jig that talks to the IMU can be found here.

The library is available here I believe, or you can get it off the ROV beagle bone.

This may still be too big for your arduino nano in which case you may have to write a mini version of it that takes out the extra features! I was having problems doing more than just initializing the IMU with my smaller arduino as well because the sketch would become too big.

Good luck,



Thanks Matt. Your code was very helpful.I have switched to arduino uno, to get things working.

I still get the error:

mpu_init failed with code: -1

Is there a way to get the IMU to work? Thanks.


Some of the IMUs had an issue where the flipped between the primary and secondary address. Essentially, after you need to check the return value of the MPU.init() method. If it is -1, then you need to use MPU.Device() to switch to the other address and then call init again. That has been consistently working.

Let us know if that helps fix the issue.



Thanks Brian, that fixed the issue.