• 已解决 73482 个问题
  • 已帮助 5993 位优秀工程师

mpu9250IP地址为什么显示0x75

xbk_949857 2022-07-01 浏览量:1525
void setup()
{
  Serial.begin(115200);
  
  Wire.begin(); 
  Wire.setClock(400000); 
  
  pinMode(myLed OUTPUT);
  digitalWrite(myLed HIGH); 

  pinMode(intPin1 INPUT); // interrupt
  pinMode(intPin2 INPUT);

  Serial.println("MPU9250 9-axis motion sensor...");
  uint8_t c = MPU9250.getMPU9250ID(MPU1);
  uint8_t d = MPU9250.getMPU9250ID(MPU2);
  if (c == 0x71)
  {
    Serial.println("MPU 1 is online");
    isOnline_1 = true;
  }
  if (d == 0x71)
  {
    Serial.println("MPU 2 is online");
    isOnline_2 = true;
  }
  if(!isOnline_1 && !isOnline_2)
  {
    Serial.print("Could not connect to MPU9250"); Serial.println(c HEX);
    while(1) ; 
  }
  // get sensor resolutions only need to do this once same for both MPU9250s for now获取传感器分辨率,只需要做一次,目前对于两个mpu9250都是一样的
  aRes = MPU9250.getAres(Ascale);
  gRes = MPU9250.getGres(Gscale);
  mRes = MPU9250.getMres(Mscale);

#if CALIBRATION_GYRO
    MPU9250.calibrateMPU9250(MPU1 gyroBias1 accelBias1); // Calibrate gyro and accelerometers load biases in bias registers
    Serial.println("MPU accel biases (g)"); Serial.println(accelBias1[0]10); Serial.println(accelBias1[1]10); Serial.println(accelBias1[2]10);
    Serial.println("MPU gyro biases"); Serial.println(gyroBias1[0]); Serial.println(gyroBias1[1]); Serial.println(gyroBias1[2]);
    Serial.println("Finished!! Please reset");
    while(1);
#endif
//update gyro bias reg
  if(isOnline_1)
  {
    MPU9250.GyroBiasWriteToReg(MPU1 gyroBias1);
    MPU9250.initMPU9250(MPU1 Ascale Gscale sampleRate); 
    byte e = MPU9250.getAK8963CID(MPU1);  // Read WHO_AM_I register for AK8963读取
    Serial.print("AK8963 1 "); Serial.print("I AM "); Serial.print(e HEX); Serial.print(" I should be "); Serial.println(0x48 HEX);
    MPU9250.initAK8963Slave(MPU1 Mscale Mmode magCalibration1); Serial.println("AK8963 1 initialized for active data mode...."); // Initialize device 1 for active mode read of magnetometer初始化设备1以读取磁力计的有源模式
  }
  if(isOnline_2)
  {
    MPU9250.GyroBiasWriteToReg(MPU2 gyroBias2);
    MPU9250.initMPU9250(MPU2 Ascale Gscale sampleRate); 
    byte e = MPU9250.getAK8963CID(MPU2);  // Read WHO_AM_I register for AK8963
    Serial.print("AK8963 2 "); Serial.print("I AM "); Serial.print(e HEX); Serial.print(" I should be "); Serial.println(0x48 HEX);
    MPU9250.initAK8963Slave(MPU2 Mscale Mmode magCalibration1); Serial.println("AK8963 2 initialized for active data mode...."); // Initialize device 2 for active mode read of magnetometer
  }
    
#if CALIBRATION_MAG
  MPU9250.magcalMPU9250(MPU1 magBias1 magScale1);
  Serial.println("AK8963 1 mag biases (mG)"); Serial.println(magBias1[0]); Serial.println(magBias1[1]); Serial.println(magBias1[2]); 
  Serial.println("AK8963 1 mag scale (mG)"); Serial.println(magScale1[0]); Serial.println(magScale1[1]); Serial.println(magScale1[2]); 
  while(1);
#endif
  
  attachInterrupt(digitalPinToInterrupt(intPin1) myinthandler1 RISING);  // define interrupt for intPin output of MPU9250 1定义MPU9250的intPin输出中断
  attachInterrupt(digitalPinToInterrupt(intPin2) myinthandler2 RISING);  // define interrupt for intPin output of MPU9250 2

  digitalWrite(myLed LOW); // turn off led when using flash memory使用闪存时关闭led灯
}

0 0 收起

我来回答

上传资料:
选择文件 文件大小不超过15M(格式支持:doc、ppt、xls、pdf、zip、rar、txt)
最佳答案
  • 都不是。

    mpu9250的地址是1101000或1101001,即0x68或0x69

    左移一位补0后的地址是11010000或11010010,即0xD0或0xD2

    • 发布于 2022-07-06
    • 举报
    • 评论 0
    • 0
    • 0

其他答案 数量:0

相关问题

问题达人换一批

mpu9250IP地址为什么显示0x75