Closed iFrostizz closed 3 years ago
@iFrostizz what model of Arduino?
Nano V3
Le 1 juil. 2019 20:04, Willus notifications@github.com a écrit :
@iFrostizzhttps://github.com/iFrostizz what model of Arduino?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/bolderflight/MPU9250/issues/54?email_source=notifications&email_token=AMHGCYMY5ZTJZQDIY6AM523P5JBLVA5CNFSM4H4TYTM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODY642MI#issuecomment-507366705, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMHGCYIJC6XALVYXT2RECUTP5JBLVANCNFSM4H4TYTMQ.
Don't work on Arduino Uno too
Le 1 juil. 2019 20:04, Willus notifications@github.com a écrit :
@iFrostizzhttps://github.com/iFrostizz what model of Arduino?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/bolderflight/MPU9250/issues/54?email_source=notifications&email_token=AMHGCYMY5ZTJZQDIY6AM523P5JBLVA5CNFSM4H4TYTM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODY642MI#issuecomment-507366705, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMHGCYIJC6XALVYXT2RECUTP5JBLVANCNFSM4H4TYTMQ.
Are you using pullup resistors? What address is your I2C scan showing?
I'm not using any resistor, shall I ? Got the 0x68 address on the I2C scanner
Le 2 juil. 2019 00:45, Brian Taylor notifications@github.com a écrit :
Are you using pullup resistors? What address is your I2C scan showing?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/bolderflight/MPU9250/issues/54?email_source=notifications&email_token=AMHGCYMLVCGKQG2FZDZGTKDP5KCJFA5CNFSM4H4TYTM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODY7RUXQ#issuecomment-507451998, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMHGCYK4A2TBT2UOQHKIOC3P5KCJFANCNFSM4H4TYTMQ.
My MPU isn't recognised by any library
@iFrostizz Is this issue resolved? If not, what IMU board are you using (some have on-board pull up resistors, you have to have pull up resistors for I2C to work).
Not solved yet I have a MPU9250 but I can read from gyro (only x and y) and accelerometer (x, y, z) using registers
So, you can read from the MPU9250 without the library, but when you use the library it doesn't work? That sounds odd, are you getting valid data when you talk straight to the MPU9250 with your code and what is your exact setup?
Can you past your working and not working code along with a picture of your setup?
I know ahah The only way to read data is to plug my sensor to 3,3V (I forgot if it works also in 5V) The data seems valid. I couldn't confirm for accelerometer, but I mapped raw gyro data to degrees and it seems pretty nice.
I'm sorry, I don't have my code since I don't have my pc right now, I'll provide you my code later
Here is the working code:
float gx, gy, gz, ax, ay, az;
void I2Cread(uint8_t Address, uint8_t Register, uint8_t Nbytes, uint8_t* Data) { // Set register address Wire.beginTransmission(Address); Wire.write(Register); Wire.endTransmission();
// Read Nbytes Wire.requestFrom(Address, Nbytes); uint8_t index=0; while (Wire.available()) Data[index++]=Wire.read(); }
// Write a byte (Data) in device (Address) at register (Register) void I2CwriteByte(uint8_t Address, uint8_t Register, uint8_t Data) { // Set register address Wire.beginTransmission(Address); Wire.write(Register); Wire.write(Data); Wire.endTransmission(); }
void setup() { Wire.begin();
I2CwriteByte(MPU9250_ADDRESS,29,0x06); // Set accelerometers low pass filter at 5Hz I2CwriteByte(MPU9250_ADDRESS,26,0x06); // Set gyroscope low pass filter at 5Hz
I2CwriteByte(MPU9250_ADDRESS,27,GYRO_FULL_SCALE_1000_DPS); // Configure gyroscope range I2CwriteByte(MPU9250_ADDRESS,28,ACC_FULL_SCALE_4_G); // Configure accelerometers range I2CwriteByte(MPU9250_ADDRESS,0x37,0x02); // Set by pass mode for the magnetometer }
void loop() {
uint8_t Buf[14]; I2Cread(MPU9250_ADDRESS,0x3B,14,Buf);
// Gyroscope gx= (-(Buf[2]<<8 | Buf[3])) / 131.0; gy= (-(Buf[0]<<8 | Buf[1])) / 131.0; gz= (Buf[4]<<8 | Buf[5]) / 131.0;
// Accelerometer ax= (-(Buf[8]<<8 | Buf[9])) / 16384.0; ay= (-(Buf[10]<<8 | Buf[11])) / 16384.0; az= (Buf[12]<<8 | Buf[13]) / 16384.0;
gx = constrain(gx, -63.0, 63.0); gy = constrain(gy, -63.0, 63.0); gz = constrain(gz, -63.0, 63.0);
gx = (gx90.0)/63.0; gy = (gy90.0)/63.0; gz = (gz*90.0)/63.0; Serial.println (gx); Serial.print (" "); Serial.print (gy); Serial.print (" "); Serial.print (gy); Serial.print (" | ");
// Accelerometer Serial.print (ax); Serial.print (" "); Serial.print (ay); Serial.print (" "); Serial.print (az); Serial.println (" | ");
delay(100);
}
Do you have any idea ?
Have you tried the basic I2C example? The library wraps the reads and writes inside readSensor().
Does this code build for you (was it copied and pasted in?), as I suspect this: gx = (gx90.0)/63.0; gy = (gy90.0)/63.0;
won't build (looks to be missing a multiply between the variable and 90).
Is this using an Arduino Nano or Teensy board? Could you also provide a link to where you got your MPU9250 board (do you know the size of the pull up resistors on it)?
Your code doesn't specify the I2C clock speed, could you try setting it using Wire.setClock()
to 400000
(400K). I believe Arduino defaults to 100K, this library here tries to run at 400K. I would then test this library with the _i2cRate
variable turned down to 100K. If these changes make a difference, you probably need to swap your pull up resistors this is a useful article on I2C resistor sizing. If this is a homemade bare board, you have to have I2C pull up resistors for the protocol to work.
Yes, tried it but doesn't work. I have a cheap Chinese module: https://s.click.aliexpress.com/e/UytSxxK
I bought a more expensive one but didn't received
I wrote this code but it's not really precise ... Just to visualise
Can't try the I2C clock now, I'll try it back home
For the multiplication: It's a fail in the copy/paste
Just got a new MPU board Now, I can sometimes read values, but if I move a little bit the wires, it stops
I also met the issue
For these sort of issues, I'll need information on the microcontroller used, the sensor breakout, and the wiring connections between the microcontroller and the sensor.
Thanks for your replying. I changed the sensor and that one worked for me.
i was using Arduino Mega, and the sensor mpu9250/6500 as his. Since i replaced it with another one, it worked
Arduino --> MPU9250 5V --> VCC GND --> GND A4 --> SDA A5 --> SCL
IMU initialization unsuccessful Check IMU wiring or try cycling power Status: -1
Sensor recognized in the I2C scanner