教程 https://www.hackster.io/donowak/esp32-mpu9250-3d-orientation-visualisation-467dc1

项目地址 https://github.com/DominikN/ESP32-MPU9250-web-view/blob/master/html.h

硬件地址

ESP32 <-> MPU9250

P22   <-> SCL
P21 <-> SDA
P19 <-> INT GND <-> GND

版型1(中国深圳常买到)

版型2(日本开发板)

https://www.switch-science.com/catalog/3210

电路图

https://s3-ap-northeast-1.amazonaws.com/switch-science.public/schematic/ESPr_Developer_32/ESPr_Developer_32.pdf

软件

配置Arduino IDE

要运行该项目,首先需要配置Arduino IDE:

1.为ESP32安装Husarnet软件包:

  • 打开 File -> Preferences
  • 在字段中,其他Board Manager URL 添加以下链接:https://files.husarion.com/arduino/package_esp32_index.json
  • 打开 Tools -> Board: ... -> Boards Manager ...
  • 搜索 esp32-husarnet by Husarion
  • 单击安装按钮

2.选择ESP32开发板:

  • 打开 Tools -> Board
  • 选择“ESP32 Arduino(Husarnet)”部分下的ESP32开发模块

3.安装ArduinoJson库:(可不安装)

  • 打开 Tools -> Manage Libraries...
  • 搜索 ArduinoJson
  • 选择版本 5.13.3
  • 单击安装按钮

4.安装arduinoWebSockets库(Husarnet fork):(可不安装)

  • 下载https://github.com/husarnet/arduinoWebSockets作为ZIP文件(这是由Links2004(Markus)提供的arduinoWebSockets的Husarnet兼容分支)
  • 打开Sketch -> Include Library -> Add .ZIP Library ...选择刚下载的arduinoWebSockets-master.zip 文件,然后单击打开按钮

5.安装SparkFun_MPU-9250-DMP_Arduino_Library:(必须安装)

基本读取示例

/************************************************************
MPU9250_Basic
Basic example sketch for MPU-9250 DMP Arduino Library
Jim Lindblom @ SparkFun Electronics
original creation date: November 23, 2016
https://github.com/sparkfun/SparkFun_MPU9250_DMP_Arduino_Library This example sketch demonstrates how to initialize the
MPU-9250, and stream its sensor outputs to a serial monitor. Development environment specifics:
Arduino IDE 1.6.12
SparkFun 9DoF Razor IMU M0 Supported Platforms:
- ATSAMD21 (Arduino Zero, SparkFun SAMD21 Breakouts)
*************************************************************/
#include <SparkFunMPU9250-DMP.h> #define SerialPort Serial MPU9250_DMP imu; void setup()
{
SerialPort.begin(115200); // Call imu.begin() to verify communication with and
// initialize the MPU-9250 to it's default values.
// Most functions return an error code - INV_SUCCESS (0)
// indicates the IMU was present and successfully set up
if (imu.begin() != INV_SUCCESS)
{
while (1)
{
SerialPort.println("Unable to communicate with MPU-9250");
SerialPort.println("Check connections, and try again.");
SerialPort.println();
delay(5000);
}
} // Use setSensors to turn on or off MPU-9250 sensors.
// Any of the following defines can be combined:
// INV_XYZ_GYRO, INV_XYZ_ACCEL, INV_XYZ_COMPASS,
// INV_X_GYRO, INV_Y_GYRO, or INV_Z_GYRO
// Enable all sensors:
imu.setSensors(INV_XYZ_GYRO | INV_XYZ_ACCEL | INV_XYZ_COMPASS); // Use setGyroFSR() and setAccelFSR() to configure the
// gyroscope and accelerometer full scale ranges.
// Gyro options are +/- 250, 500, 1000, or 2000 dps
imu.setGyroFSR(2000); // Set gyro to 2000 dps
// Accel options are +/- 2, 4, 8, or 16 g
imu.setAccelFSR(2); // Set accel to +/-2g
// Note: the MPU-9250's magnetometer FSR is set at
// +/- 4912 uT (micro-tesla's) // setLPF() can be used to set the digital low-pass filter
// of the accelerometer and gyroscope.
// Can be any of the following: 188, 98, 42, 20, 10, 5
// (values are in Hz).
imu.setLPF(5); // Set LPF corner frequency to 5Hz // The sample rate of the accel/gyro can be set using
// setSampleRate. Acceptable values range from 4Hz to 1kHz
imu.setSampleRate(10); // Set sample rate to 10Hz // Likewise, the compass (magnetometer) sample rate can be
// set using the setCompassSampleRate() function.
// This value can range between: 1-100Hz
imu.setCompassSampleRate(10); // Set mag rate to 10Hz
} void loop()
{
// dataReady() checks to see if new accel/gyro data
// is available. It will return a boolean true or false
// (New magnetometer data cannot be checked, as the library
// runs that sensor in single-conversion mode.)
if ( imu.dataReady() )
{
// Call update() to update the imu objects sensor data.
// You can specify which sensors to update by combining
// UPDATE_ACCEL, UPDATE_GYRO, UPDATE_COMPASS, and/or
// UPDATE_TEMPERATURE.
// (The update function defaults to accel, gyro, compass,
// so you don't have to specify these values.)
imu.update(UPDATE_ACCEL | UPDATE_GYRO | UPDATE_COMPASS);
printIMUData();
}
} void printIMUData(void)
{
// After calling update() the ax, ay, az, gx, gy, gz, mx,
// my, mz, time, and/or temerature class variables are all
// updated. Access them by placing the object. in front: // Use the calcAccel, calcGyro, and calcMag functions to
// convert the raw sensor readings (signed 16-bit values)
// to their respective units.
float accelX = imu.calcAccel(imu.ax);
float accelY = imu.calcAccel(imu.ay);
float accelZ = imu.calcAccel(imu.az);
float gyroX = imu.calcGyro(imu.gx);
float gyroY = imu.calcGyro(imu.gy);
float gyroZ = imu.calcGyro(imu.gz);
float magX = imu.calcMag(imu.mx);
float magY = imu.calcMag(imu.my);
float magZ = imu.calcMag(imu.mz); SerialPort.println("Accel: " + String(accelX) + ", " +
String(accelY) + ", " + String(accelZ) + " g");
SerialPort.println("Gyro: " + String(gyroX) + ", " +
String(gyroY) + ", " + String(gyroZ) + " dps");
SerialPort.println("Mag: " + String(magX) + ", " +
String(magY) + ", " + String(magZ) + " uT");
SerialPort.println("Time: " + String(imu.time) + " ms");
SerialPort.println();
}

  

更多程序

http上传程序

项目(1-1)ES32获取mpu9250数据网页交互显示的更多相关文章

  1. easyui panel异步获取后台数据在前台显示

    我在使用easyui的时候,想做一个向下图所示的效果,这个panel的样式已经做好了,想从后台异步获取json数据,然后填入到文本框中,不知道哪位大神能给点指导?万分感谢! 放入表单中,使用form对 ...

  2. 项目(1-2)ES32获取mpu9250传入数据库

    . 报一个错,找不到min函数 #define min(X,Y) ((X) < (Y) ? (X) : (Y)) 手动添加 之后不报错了 .最原始的采集 /******************* ...

  3. 用非GUI模式执行测试,jp@gc - PerfMon Metrics Collector会出现无法获取正确数据的解决办法

    用非GUI模式执行测试,jp@gc - PerfMon Metrics Collector会出现无法获取正确数据(实际显示的是Response Times Over Time),解决办法:在GUI模式 ...

  4. JaveWeb 公司项目(3)----- 通过Thrift端口获取数据库数据

    前面两篇博客的内容主要是界面搭建的过程,随着界面搭建工作的完成,网页端需要加入数据,原先的B/S架构中C#通过Thrift接口获取数据,所以在网页端也沿用这个设计 首先,新建一个Maven下的Web项 ...

  5. java的IO流包装不当导致从网页获取的数据出现乱码

    从网页上获取数据时必须要注意字符集的问题.处理不慎确实苦不堪言. 例如通过URL连接时,将字节流InputStream包装成字符流(以便直接存为String)时,一定要注意加上charsetName这 ...

  6. python获取数据网页数据并创建文件夹保存(基于python3.6)

    from urllib.parse import urljoin import urllib.request from bs4 import BeautifulSoup import os impor ...

  7. Flutter实战视频-移动电商-09.首页_项目结构建立和获取数据

    09.首页_项目结构建立和获取数据 在config下创建service_url.dart 用来配置我们后端接口的配置文件 一个变量存 接口地址,一个接口方法地址 所有后天请求数据的方法都放在这个文件夹 ...

  8. [iOS微博项目 - 2.6] - 获取微博数据

    github: https://github.com/hellovoidworld/HVWWeibo   A.新浪获取微博API 1.读取微博API     2.“statuses/home_time ...

  9. [转]WEB页获取串口数据

    本文转自:https://www.cnblogs.com/rockyhm/p/3434200.html 最近做一个B/S的项目,需要读取电子秤的值,之前一直没做过,也没有经验,于是在网上找到很多  大 ...

随机推荐

  1. DDR3(5):读写仲裁

    上一讲我们完成了读的控制,但是并不知道是否设计成功,必须读写结合才行.DDR3 的 app 端的命令总线是读写复用的,因此可能会存在读写冲突的时刻,为了解决此问题,必须进行分时读写,也就是我们说的仲裁 ...

  2. python装饰器的使用场景(转)

    原文:https://www.cnblogs.com/wupeiqi/articles/4980620.html 1.必备 1 2 3 4 5 6 7 8 9 10 11 12 13 14 #### ...

  3. 『选课 树形dp 输出方案』

    这道题的树上分组背包的做法已经在『选课 有树形依赖的背包问题』中讲过了,本篇博客中主要讲解将多叉树转二叉树的做法,以便输出方案. 选课 Description 学校实行学分制.每门的必修课都有固定的学 ...

  4. 什么是k8s

    •Kubernetes介绍 1.背景介绍 云计算飞速发展 - IaaS - PaaS - SaaS Docker技术突飞猛进 - 一次构建,到处运行 - 容器的快速轻量 - 完整的生态环境 2.什么是 ...

  5. React 父/子窗体参数传递

    1.父窗体 import Modal from './Modal' onModalRef = ref => { this.modal = ref } onCallback = msg => ...

  6. .NET中的异步编程——常见的错误和最佳实践

    在这篇文章中,我们将通过使用异步编程的一些最常见的错误来给你们一些参考. 背景 在之前的文章<.NET中的异步编程——动机和单元测试>中,我们开始分析.NET世界中的异步编程.在那篇文章中 ...

  7. 【3.1】学习C++之再逢const

    随着学习的深入,就会发现曾经学的const还有更深入的用法,现在就对const的未总结的用法进行总结. 本文就是针对const在类中的情况进行的总结. 有时我们会遇到下面这种将类的成员变量用const ...

  8. prometheus被OOM杀死

    参考https://www-01.ibm.com/support/docview.wss?uid=ibm10882172 提升内存配置 2.5版本后新增--query.max-samples 这个参数 ...

  9. 【转载】UiPath,UiPath教程,UiPath视频教程 RPA

    第一课-UiPath简介 第二课-变量和数据类型第1部分-基础讲解 第二课-变量和数据类型第2部分-实例讲解 第二课-流程控制第1部分-ifelse语句讲解 第二课-流程控制第3部分-高级流程控制语句 ...

  10. 使用MQ消息队列的优缺点

    前言 公司的项目一直都是在使用MQ的,但是由于使用的功能很简单,所以一直都是知其然不知其所以然,作为一个程序猿有必要了解每一个使用的技术,为什么使用它?它的优点是什么?缺点是什么?等等... 使用mq ...