Hello to all members of the community,
I am using MPU 9250 connected to Arduino Uno board for a inertial navigation project and have been trying to test out if we can find out what values we get out of this sensor. I am running Basic I2C example given with the library for test purpose but have been unable to connect to said sensor. My connections are as seen in the attachments. Any help for this issue here would be appreciated. I am a newb so please describe in layman's terms... Cheers!
Edit: I am using a baud rate of 9600 instead of 115200 as stated in attachment. I get strange Characters with latter baud rate.
MPU9250 IMU(Wire,0x68);
int status;
void setup() {
// serial to display data
Serial.begin(115200);
while(!Serial) {}
// start communication with IMU
status = IMU.begin();
if (status < 0) {
Serial.println("IMU initialization unsuccessful");
Serial.println("Check IMU wiring or try cycling power");
Serial.print("Status: ");
Serial.println(status);
while(1) {}
}
}
void loop() {
// read the sensor
IMU.readSensor();
// display the data
Serial.print(IMU.getAccelX_mss(),6);
Serial.print("\t");
Serial.print(IMU.getAccelY_mss(),6);
Serial.print("\t");
Serial.print(IMU.getAccelZ_mss(),6);
Serial.print("\t");
Serial.print(IMU.getGyroX_rads(),6);
Serial.print("\t");
Serial.print(IMU.getGyroY_rads(),6);
Serial.print("\t");
Serial.print(IMU.getGyroZ_rads(),6);
Serial.print("\t");
Serial.print(IMU.getMagX_uT(),6);
Serial.print("\t");
Serial.print(IMU.getMagY_uT(),6);
Serial.print("\t");
Serial.print(IMU.getMagZ_uT(),6);
Serial.print("\t");
Serial.println(IMU.getTemperature_C(),6);
delay(100);
}
And here is my Error:
IMU initialization unsuccessful
Check IMU wiring or try cycling power
Status: -1
The first thing that I do when I have trouble with an I2C device is to run the I2C scanner sketch to confirm the I2C address and communication with the I2C bus.
Make sure that the serial monitor baud rate is set to 115200.
// I2C scanner by Nick Gammon. Thanks Nick.
#include <Wire.h>
void setup() {
Serial.begin (115200); //***** make sure serial monitor baud matches *****
// Leonardo: wait for serial port to connect
while (!Serial)
{
}
Serial.println ();
Serial.println ("I2C scanner. Scanning ...");
byte count = 0;
Wire.begin();
for (byte i = 1; i < 120; i++)
{
Wire.beginTransmission (i);
if (Wire.endTransmission () == 0)
{
Serial.print ("Found address: ");
Serial.print (i, DEC);
Serial.print (" (0x");
Serial.print (i, HEX);
Serial.println (")");
count++;
delay (1); // maybe unneeded?
} // end of good response
} // end of for loop
Serial.println ("Done.");
Serial.print ("Found ");
Serial.print (count, DEC);
Serial.println (" device(s).");
} // end of setup
void loop() {}
I hope you are right but I have seen many tutorials that are using 5V arduino supply with IMU 9250. Please get me back on that. Would be of great help!
The modules often have a 5V to 3.3V regulator, but most do not have 5V to 3.3V level shifters for the I/O.
If you are extremely careful and make certain that the pullups on the I2C bus are connected ONLY to 3.3V, and that the IMU inputs are never exposed to 5V, then this can be made to work.
Many people fail at this point, which is why we strongly recommend to use 3.3V Arduinos with 3.3V sensors.