项目(一)ES32获取mpu9250数据网页交互显示 (程序1) esp32获取mpu9250数据

项目(一)ES32获取mpu9250数据网页交互显示 (程序1) esp32获取mpu9250数据,第1张

概述、   、 /************************************************************MPU9250_Basic Basic example sketch for MPU-9250 DMP Arduino Library Jim Lindblom @ SparkFun Electronicsoriginal creation date

 

/************************************************************mpu9250_Basic Basic example sketch for mpu-9250 DMP Arduino library Jim lindblom @ SparkFun Electronicsoriginal creation date: November 23,2016https://github.com/sparkfun/SparkFun_mpu9250_DMP_Arduino_libraryThis 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.12SparkFun 9DoF Razor IMU M0Supported Platforms:- ATSAMD21 (Arduino Zero,SparkFun SAMD21 Breakouts)*************************************************************/#include <SparkFunmpu9250-DMP.h>#define SerialPort Serialmpu9250_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 | UPDATE_TEMP);    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); // long imu_temperature=imu.temperature;    SerialPort.println();  SerialPort.print("Time: " + String(imu.time) + " ms");  SerialPort.print("Accel: " + String(accelX) + "," +              String(accelY) + "," + String(accelZ) + " g");  SerialPort.print("  ");  SerialPort.print("Gyro: " + String(gyroX) + "," +              String(gyroY) + "," + String(gyroZ) + " dps");  SerialPort.print("  ");  SerialPort.print("Mag: " + String(magX) + "," +              String(magY) + "," + String(magZ) + " uT");  SerialPort.print("  ");//  SerialPort.print("temperature: " +imu_temperature);}
总结

以上是内存溢出为你收集整理的项目(一)ES32获取mpu9250数据网页交互显示 (程序1) esp32获取mpu9250数据全部内容,希望文章能够帮你解决项目(一)ES32获取mpu9250数据网页交互显示 (程序1) esp32获取mpu9250数据所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1066838.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-26
下一篇2022-05-26

发表评论

登录后才能评论

评论列表(0条)

    保存