Pololu Robotics & Electronics
My account Comments or questions? About Pololu Contact Ordering information Distributors

Can't get MinIMU-9 v3 running with Arduino Mega 2560


Hi! I’m using “Pololu MinIMU-9 + Arduino AHRS” examples and I can’t see the information I should see on the Arduino Serial Monitor. My wiring is
Arduino - IMU
5V - VIN
SDA (Pin 20) - SDA
SCL (Pin 21)- SCL
I plugged the IMU to an Arduino Uno and it works just fine with the correct wiring. The problem is when a plug it to the Mega 2560, it gets stuck when it has to read a value from the IMU. I tried another program “ascii_graph” from the resources and when I got: “Failed to autodetect gyro type!”. How do I help Mega 2560 to detect the IMU’s compass and gyro types?



I am sorry you are having trouble reading your MinIMU-9 with your Arduino Mega. Instead of testing with the AHRS code, can you try running just the “Serial.ino” sketch from the LSM303 and L3G Arduino libraries? Can you also post pictures that clearly show your board and its connections?



Hi Jonathan!
I ran the “Serial.ino” sketch from L3G library and I got “Failed to autodetect gyro type!” as shown in the image. I also uploaded my wiring.

Thanks for the time you are taking to help me out.


Can you verify that you can communicate with other I2C devices on that Arduino Mega I2C bus? For example, could you try the LSM303 library’s “Serial.ino” sketch to communicate with the accelerometer/magnetometer?

Also, can you try manually initializing the gyro with a call that both specifies the device and SA0 state? For example, the MinIMU-9 v3 uses the L3DG20H, so you should replace



gyro.init(L3G::device_D20H, L3G::sa0_high)

in Serial.ino.



Hi Jonathan!

Sorry for taking too long to answer. First, using your advice, I have verified that I can communicate with the other I2C devices of the MiniIMU-9 v3 using LSM303 library’s “Serial.ino” by replacing



compass.init(LSM303::device_D, LSM303::sa0_high);

as shown in the next figure

Second, I also got the gyroscope running using L3G library’s “Serial.ino” making the changes you suggested:

Finally for “MinIMU9AHRS.ino”, analogously, replacing


from method Accel_Init() in “I2C.ino” file with

compass.init(LSM303::device_D, LSM303::sa0_high);



from method Gyro_Init() also in “I2C.ino” file with

gyro.init(L3G::device_D20H, L3G::sa0_high);

I finally got “MinIMU9AHRS.ino” running using the connections mentioned before as shown next

Thank you very much for the time you took to help me out with my project : ).


Great! I am glad things are working now; thanks for following up.