相关资料链接

链接:https://pan.baidu.com/s/1eE0rkaSJsKJMU_RUorS5OA

提取码:3ujh

1.1 介绍:

本模块是一款高性能三轴加速度+三轴陀螺仪的六轴传感器模块,采用MPU6050芯片作为核心,MPU-6050 是6轴运动处理传感器。它集成了 3 轴MEMS陀螺仪,3 轴MEMS加速度计,以及一个可扩展的数字运动处理器 DMP。使用它就是为了得到待测物体(如四轴飞行器、平衡小车) x、y、z 轴的倾角(俯仰角 Pitch、翻滚角 Roll、偏航角 Yaw) 。我们通过 I2C 读取到 MPU6050 的六个数据(三轴加速度 AD 值、三轴角速度 AD 值)经过姿态融合后就可以得到 Pitch、Roll、Yaw 角。利用自带的数字运动处理器DMP,通过IIC接口,输出姿态解算后的数据。具有体积小,使用方便等特点。模块自带2个定位孔,方便你将模块固定在其他设备。

1.2 模块相关资料:

工作电压:

3.3V-5V(DC)

最大功率:

0.25W

通信方式:

标准IIC通信协议

数据:

芯片内置16bit AD转换器,16位数据输出

陀螺仪范围:

±250 500 1000 2000°/s

加速度范围:

±2±4±8±16g

陀螺仪运作电流:

5mA

尺寸:

31.6mmx23.7mm

原理:模块原理图如下,其中使用了SPX3810M稳压芯片,将5V电源转换为3.3V电压给MPU6050芯片供电,P-MOS管Q1、Q2作为电平转换电路,将芯片的IIC电平转化为5.0V电平,采用3.3V的单片机控制,如果不想要或者无法兼容5V电压,可将电平转换电路去掉,将IIC接口直接接单片机IIC引脚。

1.3实验器材:

控制板* 1

USB线*1

MPU6050*1

5P 转杜邦线母*1

1.4模块接线图:

1.5 实验代码:

/*

MPU6050传感器

https://sourl.cn/NbKeBf

*/

// I2Cdev and MPU6050 must be installed as libraries, or else the .cpp/.h files

// for both classes must be in the include path of your project

#include "I2Cdev.h"

#include "MPU6050.h"

// Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation

// is used in I2Cdev.h

#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE

#include "Wire.h"

#endif

// class default I2C address is 0x68

// specific I2C addresses may be passed as a parameter here

// AD0 low = 0x68 (default for InvenSense evaluation board)

// AD0 high = 0x69

MPU6050 accelgyro;

//MPU6050 accelgyro(0x69); // <-- use for AD0 high

int16_t ax, ay, az;

int16_t gx, gy, gz;

// uncomment "OUTPUT_READABLE_ACCELGYRO" if you want to see a tab-separated

// list of the accel X/Y/Z and then gyro X/Y/Z values in decimal. Easy to read,

// not so easy to parse, and slow(er) over UART.

#define OUTPUT_READABLE_ACCELGYRO

// uncomment "OUTPUT_BINARY_ACCELGYRO" to send all 6 axes of data as 16-bit

// binary, one right after the other. This is very fast (as fast as possible

// without compression or data loss), and easy to parse, but impossible to read

// for a human.

//#define OUTPUT_BINARY_ACCELGYRO

#define LED_PIN 13

bool blinkState = false;

void setup() {

// join I2C bus (I2Cdev library doesn't do this automatically)

#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE

Wire.begin();

#elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE

Fastwire::setup(400, true);

#endif

// initialize serial communication

Serial.begin(9600);

// initialize device

Serial.println("Initializing I2C devices...");

accelgyro.initialize();

// verify connection

Serial.println("Testing device connections...");

Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");

// use the code below to change accel/gyro offset values

/*

Serial.println("Updating internal sensor offsets...");

// -76 -2359 1688 0 0 0

Serial.print(accelgyro.getXAccelOffset()); Serial.print("\t"); // -76

Serial.print(accelgyro.getYAccelOffset()); Serial.print("\t"); // -2359

Serial.print(accelgyro.getZAccelOffset()); Serial.print("\t"); // 1688

Serial.print(accelgyro.getXGyroOffset()); Serial.print("\t"); // 0

Serial.print(accelgyro.getYGyroOffset()); Serial.print("\t"); // 0

Serial.print(accelgyro.getZGyroOffset()); Serial.print("\t"); // 0

Serial.print("\n");

accelgyro.setXGyroOffset(220);

accelgyro.setYGyroOffset(76);

accelgyro.setZGyroOffset(-85);

Serial.print(accelgyro.getXAccelOffset()); Serial.print("\t"); // -76

Serial.print(accelgyro.getYAccelOffset()); Serial.print("\t"); // -2359

Serial.print(accelgyro.getZAccelOffset()); Serial.print("\t"); // 1688

Serial.print(accelgyro.getXGyroOffset()); Serial.print("\t"); // 0

Serial.print(accelgyro.getYGyroOffset()); Serial.print("\t"); // 0

Serial.print(accelgyro.getZGyroOffset()); Serial.print("\t"); // 0

Serial.print("\n");

*/

// configure Arduino LED for

pinMode(LED_PIN, OUTPUT);

}

void loop() {

// read raw accel/gyro measurements from device

accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);

// these methods (and a few others) are also available

//accelgyro.getAcceleration(&ax, &ay, &az);

//accelgyro.getRotation(&gx, &gy, &gz);

#ifdef OUTPUT_READABLE_ACCELGYRO

// display tab-separated accel/gyro x/y/z values

Serial.print("a/g:\t");

Serial.print(ax); Serial.print("\t");

Serial.print(ay); Serial.print("\t");

Serial.print(az); Serial.print("\t");

Serial.print(gx); Serial.print("\t");

Serial.print(gy); Serial.print("\t");

Serial.println(gz);

#endif

#ifdef OUTPUT_BINARY_ACCELGYRO

Serial.write((uint8_t)(ax >> 8)); Serial.write((uint8_t)(ax & 0xFF));

Serial.write((uint8_t)(ay >> 8)); Serial.write((uint8_t)(ay & 0xFF));

Serial.write((uint8_t)(az >> 8)); Serial.write((uint8_t)(az & 0xFF));

Serial.write((uint8_t)(gx >> 8)); Serial.write((uint8_t)(gx & 0xFF));

Serial.write((uint8_t)(gy >> 8)); Serial.write((uint8_t)(gy & 0xFF));

Serial.write((uint8_t)(gz >> 8)); Serial.write((uint8_t)(gz & 0xFF));

#endif

// blink LED to indicate activity

blinkState = !blinkState;

digitalWrite(LED_PIN, blinkState);

}

程序编译前需要导入库文件,否则编译不通过,具体操作参考

资料的第四小节:库文件的添加(若前面已添加,无需重复)

1.6实验结果

按照上图接好线,烧录好代码,上电后,通电后,我们可在软件串口监视器中看到相对应数值,如下图。

Arduino 使用 MPU6050三轴加速传感器相关推荐

  1. 咸鱼ZTMS实例—三轴加速传感器

    咸鱼ZTMS实例-三轴加速传感器 MMA7660FC 加速度传感器基本使用 MMA7660FC MMA7660FC可在六个方向定制垂直水平座向 集成了众多智能的运动功能,如方向.震动和敲击检测集成了众 ...

  2. Arduino驱动MPU-6050三轴加速度+三轴陀螺仪模块

    目录 简介 模块引脚说明 接线 Arduino例程代码 总结 原文链接:https://www.yourcee.com/newsinfo/2926294.html 简介 点击图片购买 MPU-6050 ...

  3. 国产完美替换MLX90393三轴霍尔传感器

          前情提要: MLX90393这两年都缺货,公司要求我们找替代.于是就找到了这个,目前我们公司测试已经通过了.分享给你们吧,希望大家一起摆脱卡脖子的状态. 一.功能描述 QX5701是一款数 ...

  4. stm32 MPU6050 6轴姿态传感器的介绍与DMP的应用

    最近应用到三轴姿态传感器,因为之前有MPU6050(6轴传感器,这是6轴的), 进行搭配使用,通过三轴姿态传感器进行舵机的角度调整.(内容来源学习正点原子的教程) 同步B站也已经发布过原子官方教程.让 ...

  5. 溢出检测单符号位法_设计经验:如何用三轴加速度传感器检测倾斜角?

    本文介绍了三轴加速度传感器的特性,并通过一个典型的应用--检测倾斜角--对单轴.双轴和三轴加速度传感器进行了比较,并给出了选型建议. 在前两篇文章中,我们介绍了单/双轴加速度传感器在来检测倾斜角上的应 ...

  6. 三轴加速度传感器和六轴惯性传感器_美泰产品推介MSV3100A三轴加速度传感器

    1 产品介绍 MSV3100A三轴加速度传感器 MSV3100A是一款三轴向模拟输出的MEMS加速度传感器.传感器由三个相互正交的微加速度计和信号变换电路组成.能够承受高达10,000g的冲击载荷和恒 ...

  7. mpu6050三轴加速度数据,三轴角速度数据显示

    一.实验效果 显示mpu6050三轴加速度原始数据,三轴角速度原始数据. 硬件:stm32f427vit6单片机 .mpu6050模块 软件:STM32CubeIDE 1.8.0 C语言 二.硬件连接 ...

  8. ADI Blackfin DSP处理器-BF533的开发详解59:DSP控制ADXL345三轴加速度传感器的应用2(含源码)

    硬件准备 ADSP-EDU-BF533:BF533开发板 AD-HP530ICE:ADI DSP仿真器 软件准备 Visual DSP++软件 硬件链接 MEMS三轴加速度传感器 我做了一个三轴加速度 ...

  9. ADI Blackfin DSP处理器-BF533的开发详解58:DSP控制ADXL345三轴加速度传感器的应用(含源码)

    硬件准备 ADSP-EDU-BF533:BF533开发板 AD-HP530ICE:ADI DSP仿真器 软件准备 Visual DSP++软件 硬件链接 MEMS三轴加速度传感器 我做了一个三轴加速度 ...

最新文章

  1. 删除linux系统中的ifcfg-eth0.bak
  2. python如何做一个数据库_Python创建一个新的Django项目(连接到MySQL数据库),python,新建,mysql...
  3. Exchange 2016 (登陸賬號匯出電子郵件地址)
  4. Java内存模型深度解析:final--转
  5. 滚动字幕Marquee
  6. 对css类名className的一些操作的函数
  7. 表的连接方式:NESTED LOOP、HASH JOIN、SORT MERGE JOIN【转】
  8. python+selenium+unittest测试框架3-项目构建和发送邮件
  9. pip 升级 pip
  10. oracle如何储存超长汉子_oracle Clob 存储超长字符
  11. [hiho1160] 攻城略地
  12. java case 语句_Java switch case 语句
  13. SQL查询时间段方法
  14. Python运行报错most recent call last
  15. 【转】Power System 中基于 VIOS 的虚拟以太网实现
  16. NetDevOps的理解与学习路线
  17. 删除数据后如何及时释放存储空间
  18. mac电脑循环次数多少算新_mac电池循环次数怎么计算?新版mac怎么查看剩余电量?...
  19. 没有图片显示默认图片
  20. 谈谈我做拼音搜索的一点经验

热门文章

  1. ics公司计算机服务,AI人工智能
  2. 密码学系列(二):专有名词缩写【持更】
  3. 【名企招聘】4月29日19点,巨杉数据库-带着岗位来招人啦
  4. Altium Designer20 出现Failed to add class member:xxx 和 Unknown Pin 错误解决办法
  5. 面试官让我用Flex写色子布局,我直接给写了6个
  6. red hat linux 5.8下载地址,Red Hat Enterprise Linux (RHEL) 5.8 DVD ISO下载
  7. 上海宝付解读10年后AI取代程序员
  8. 小程序template模板 为知你客服传入微信头像和昵称
  9. Excel 共享冲突错误无法保存,已解决
  10. python打包成exe导入文件_Pyinstaller(python打包为exe文件)