zoukankan      html  css  js  c++  java
  • 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();
        }
    }
    

      

  • 相关阅读:
    windows10装机小记
    Linus Benedict Torvalds hate FUD
    营销文章good
    商城趣聊4
    商城趣聊3
    商城趣聊2
    商城趣聊1
    temp
    学习代码检视方法 (摘自某图片)
    xilinx sdk闪退问题
  • 原文地址:https://www.cnblogs.com/kekeoutlook/p/12323271.html
Copyright © 2011-2022 走看看