kriswiner/MPU9250

No response from magnetometer

Closed this issue · 11 comments

Hi Kris
I’m working on a open source tracking device “DroneID”, for trafic management of drones in Denmark DroneID_report. I have som trouble with a MPU-9250 sensor. I’ve tried to implement your solution, but went back to basics just to get started. The problem is that I don’t get any response from the magnetometer. There is no problem getting data from the other sensors in the chip, but when i get to the last line of the code below, I get an error.

Inspired by lucidarme

bool error = false;
// Set accelerometers low pass filter at 5Hz
data_test = 0x06;
error |= i2c_write(0x68,29,1,&data_test);
// Set gyroscope low pass filter at 5Hz
error |= i2c_write(0x68,26,1,&data_test);
// Configure gyroscope range
data_test = 0x10;
error |= i2c_write(0x68,27,1,&data_test);
// Configure accelerometers range
data_test = 0x08;
error |= i2c_write(0x68,28,1,&data_test);
// Set by pass mode for the magnetometers
data_test = 0x02;
error |= i2c_write(0x68,0x37,1,&data_test);

// Request continuous magnetometer measurements in 16 bits
data_test = 0x01
error |= i2c_write(0x0C,0x0A,1,&data_test);

Do you have any idea of what could be wrong?

Kind regards
Martin Skriver

0x01 is not a valid entry, please see the data sheet.

void initAK8963(float * destination)
{
  // First extract the factory calibration for each magnetometer axis
  uint8_t rawData[3];  // x/y/z gyro calibration data stored here
  writeByte(AK8963_ADDRESS, AK8963_CNTL, 0x00); // Power down magnetometer  
  delay(10);
  writeByte(AK8963_ADDRESS, AK8963_CNTL, 0x0F); // Enter Fuse ROM access mode
  delay(10);
  readBytes(AK8963_ADDRESS, AK8963_ASAX, 3, &rawData[0]);  // Read the x-, y-, and z-axis calibration values
  destination[0] =  (float)(rawData[0] - 128)/256. + 1.;   // Return x-axis sensitivity adjustment values, etc.
  destination[1] =  (float)(rawData[1] - 128)/256. + 1.;  
  destination[2] =  (float)(rawData[2] - 128)/256. + 1.; 
  writeByte(AK8963_ADDRESS, AK8963_CNTL, 0x00); // Power down magnetometer  
  delay(10);
  // Configure the magnetometer for continuous read and highest resolution
  // set Mscale bit 4 to 1 (0) to enable 16 (14) bit resolution in CNTL register,
  // and enable continuous mode data acquisition Mmode (bits [3:0]), 0010 for 8 Hz and 0110 for 100 Hz sample rates
  writeByte(AK8963_ADDRESS, AK8963_CNTL, Mscale << 4 | Mmode); // Set magnetometer data resolution and sample ODR
  delay(10);
}

Thank you for your fast respond. 0x01 was my panic attempt to try something new :) I tried implementing the code, but it didn’t change anything. It seems like there is no node with addr 0x0C on the bus.
Do you think it can it be a hardware problem? It is just strange since there is no problem getting data from node addr 0x68.

Kind regards

Thanks Kris
I'll try working with it tomorrow and get back with the result.

Still no response fra AK8963C.
I attached the MPU9250 part of the diagram that we used in the DroneID. I have seen diagrams of the sensor where pin 1 is open. We added 3 V to the pin. Is that correct?

image

Kind regards

I had a problem with the I2C but it is working now.
Thank you very much, I owe you a beer ;)

I had a problem with the I2C but it is working now. Thank you very much, I owe you a beer ;)

hello ! i have a very similar problem to what you had an my I2C doesn't connect to 0x0C address to get data can you help me out and tell me what did you do to solve this please!

I'm using a Raspberry Pi with a MPU9250, and I'm having similar problem. Everything works fine (if I add in python a try/except block) except for the magnetometer. Im running the command i2cdetect -y 1 to scan the addresses. The 0x68 of the accel/gyro is appearing, but the 0x0c is not showing up. Could someone help me? I know this is not talking about python, but...