arduino (6) MPU9250


問題

不同廠家的的mpu9250的12c地址可能不一樣,需要看一下。

同樣的代碼可能不也能用。

https://blog.csdn.net/weixin_43263947/article/details/85109253

樹莓派連接MPU9250九軸加速度傳感器

 

 

 

 

3.3v或者5v

 2,I2C有效
在樹莓派里使用如下命令,打開設定菜單。

sudo raspi-config

在設定菜單中設定I2C有效

3,導入I2C工具庫
在樹莓派里使用如下命令,導入I2C工具庫。

sudo apt-get install i2c-tools

 然后樹莓派里使用如下命令,查看MPU9250是否連接成功。

 

sudo i2cdetect -y 1

  出現如下表示,代表MPU9250連接成功。

0x60:-- -- -- -- -- -- -- 68 -- --

  

查看具體12c通信位置-修改庫

sudo i2cdetect -l

  

 sudo i2cget -y 1 0x68 0x75

mpu6050 0x68 

第一批的mpu9250  0x71 

第二批的mpu9250  0x73 坑的一批

 

 

 

 

 

 

 

#include "MPU9250.h"

MPU9250 mpu;

void setup()
{
    Serial.begin(115200);

    Wire.begin();

    delay(2000);
    mpu.setup();
}

void loop()
{
    static uint32_t prev_ms = millis();
    if ((millis() - prev_ms) > 16)
    {
        mpu.update();
      //  mpu.print();

        Serial.print("roll  (x-forward (north)) : ");
        Serial.print(mpu.getRoll());
        Serial.print("pitch (y-right (east))    : ");
        Serial.print(mpu.getPitch());
        Serial.print("yaw   (z-down (down))     : ");
        Serial.println(mpu.getYaw());

        prev_ms = millis();
    }
}

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM