报一个错,找不到min函数

#define min(X,Y) ((X) < (Y) ? (X) : (Y))

手动添加

 

之后不报错了

 

、最原始的采集

/************************************************************
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 | 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);
}

  

增加数据库交互,增加wifi连接

修改自己的数据库地址

#include <Arduino.h>

#include <WiFi.h>
#include <WiFiMulti.h> #include <HTTPClient.h> #include <SparkFunMPU9250-DMP.h> #define USE_SERIAL Serial
#define SerialPort Serial WiFiMulti wifiMulti; MPU9250_DMP imu; const char* ssid = "love";
const char* password = "love123456"; // 1 WIFI连接初始化
void wifi_int(){
USE_SERIAL.println();
USE_SERIAL.println();
USE_SERIAL.println(); WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
} Serial.println("");
Serial.println("WiFi connected.");
Serial.println("IP address: ");
Serial.println(WiFi.localIP()); // wifiMulti.addAP("love", "love123456");
} // 2 传感器初始化
void IMU_int(){
// 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 } //3 发送数据给服务器 数据库
void send_imu_http(float accelX,float accelY , float accelZ, float gyroX , float gyroY, float gyroZ,float magX,float magY,float magZ,float imu_temperature){
HTTPClient http;
USE_SERIAL.print("[HTTP] begin...\n");
// String http_msg="http://45.76.105.89/IMU/msql_inset.php?ax=1.0&ay=2.0&az=3.0&gx=4.0&gy=5.0&gz=6.0&mx=7.0&my=8.0&mz=9.0&temperature=10.0"; // -1 修改自己的服务器
String http_msg=String("")+"http://45.76.105.89/IMU/msql_inset.php?"
+"ax="+accelX+"&ay="+accelY+"&az="+accelZ
+"&gx="+gyroX+"&gy="+gyroY+"&gz="+ gyroZ
+"&mx="+magX+"&my="+magY+"&mz="+magZ
+"&temperature="+imu_temperature; http.begin(http_msg); //HTTP
USE_SERIAL.print("[HTTP] GET...\n");
// start connection and send HTTP header
int httpCode = http.GET();
// httpCode will be negative on error
if(httpCode > 0) {
// HTTP header has been send and Server response header has been handled
USE_SERIAL.printf("[HTTP] GET... code: %d\n", httpCode); // file found at server
if(httpCode == HTTP_CODE_OK) {
String payload = http.getString();
USE_SERIAL.println(payload);
}
} else {
USE_SERIAL.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
}
http.end(); } // 4 主函数 初始化
void setup() { USE_SERIAL.begin(115200);//串口初始化 wifi_int();// wifi连接初始化 IMU_int();// 传感器初始化 mpu9250 } // 5 主函数 无限循环
void loop() { delay(9000);// 延迟9秒 程序运行约1秒 加起来10秒循环一次 // 读取传感器数据
if ( imu.dataReady() )
{
imu.update(UPDATE_ACCEL | UPDATE_GYRO | UPDATE_COMPASS | UPDATE_TEMP);// // 原始数据转换
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();
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); //发送给服务器数据库
send_imu_http(accelX,accelY,accelZ,gyroX,gyroY,gyroZ,magX,magY,magZ,23.5);
} }

  

数据库php代码

<?php

//   http://45.76.105.88/IMU/msql_inset.php?ax=1.0&ay=2.0&az=3.0&gx=4.0&gy=5.0&gz=6.0&mx=7.0&my=8.0&mz=9.0&temperature=10.0
echo "设备请求插入新数据:<br>";
// 1获取请求参数
echo "服务器时间:".date('Y-m-d H:i:s')."<br>";// 当前时间 echo "加速度 ";
echo "ax: ";echo $_GET["ax"]." ";//
echo "ay: ";echo $_GET["ay"]." ";//
echo "az: ";echo $_GET["az"]." ";// echo "陀螺仪 ";
echo "gx: ";echo $_GET["gx"]." ";//
echo "gy: ";echo $_GET["gy"]." ";//
echo "gz: ";echo $_GET["gz"]." ";// echo "磁力计 ";
echo "mx: ";echo $_GET["mx"]." ";//
echo "my: ";echo $_GET["my"]." ";//
echo "mz: ";echo $_GET["mz"]." ";// echo "温度 ";
echo $_GET["temperature"]; echo "<br>"; // 2交互数据库 // 2-1连接
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "IMU";// 数据库
$tablename = "IMU";// 数据库
//创建数据库连接
$conn = new mysqli($servername, $username, $password, $dbname);
//检测是否连接成功
if ($conn->connect_error) {
die("数据库连接失败: " . $conn->connect_error."<br>");
}
echo "数据库连接成功<br> "; // 2-2插入 $sql="INSERT INTO ".$tablename." (ax,ay,az,gx,gy,gz,mx,my,mz,temperature) VALUES (".$_GET["ax"].",".$_GET["ay"].",".$_GET["az"].",".$_GET["gx"].",".$_GET["gy"].",".$_GET["gz"].",".$_GET["mx"].",".$_GET["my"].",".$_GET["mz"].",".$_GET["temperature"].");"; if ($conn->query($sql) === TRUE) {
echo "新记录插入成功" . "<br>";
} else {
echo "数据库插入失败: " . $sql . "<br>" . $conn->error;
} // 2-4关闭结束 $conn->close();
//echo "数据库关闭<br>"; ?>

  

项目(1-2)ES32获取mpu9250传入数据库的更多相关文章

  1. 项目(1-1)ES32获取mpu9250数据网页交互显示

    教程 https://www.hackster.io/donowak/esp32-mpu9250-3d-orientation-visualisation-467dc1 项目地址 https://gi ...

  2. 大项目之网上书城(八)——数据库大改&添加图书

    目录 大项目之网上书城(八)--数据库大改&添加图书 主要改动 1.数据库新增表 代码 2.数据库新增触发器 3.其他对BookService和BookDao的修改 代码 4.addBook. ...

  3. AngularJS进阶(三十一)AngularJS项目开发技巧之获取模态对话框中的组件ID

    AngularJS项目开发技巧之获取模态对话框中的组件ID 需求 出于项目开发需求,需要实现的业务逻辑是:药店端点击查看"已发货""已收货"订单详情时,模块弹出 ...

  4. 项目管理---git----快速使用git笔记(四)------远程项目代码的首次获取

    使用git最常见的场景是 你需要参与到一个项目中,而这个项目的代码,同事已经上传到github或者https://coding.net了. 这时候他会给你一个项目代码的远程仓库链接. 例如: http ...

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

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

  6. mysql 获取所有的数据库名字

    mysql 获取所有的数据库名字 一.如果使用的是mysqli: $con = @mysqli_connect("localhost", "root", &qu ...

  7. WebRTC从摄像头获取图片传入canvas

    WebRTC从摄像头获取图片传入canvas 前面我们已经能够利用WebRTC的功能,通过浏览器打开摄像头,并把预览的图像显示在video元素中. 接下来我们尝试从视频中截取某一帧,显示在界面上. h ...

  8. C#Winform从页面获取数据,传入数据库

    环境: 1.SQLite数据库新建数据表,设置相应的字段.(其他数据库形式都相似,using相应数据库的包即可) 2.页面有两个textBox:textBox1.textBox2, 3.一个保存按钮: ...

  9. android项目 之 记事本(11) ----- 加入数据库

    本文是自己学习所做笔记.欢迎转载.但请注明出处:http://blog.csdn.net/jesson20121020 通过之前的10节,已实现了记事本的大部分功能,有加入拍照.加入照片,加入录音,加 ...

随机推荐

  1. php redis扩展安装步骤

    因为redis不是php技术自带的技术,因此我们如果要通过php程序来操作redis,需要redis设计者提供对应的操作接口(函数类)我们使用phpredis.tar.gz文件在源码编译生成一个red ...

  2. golang socket与Linux socket比较分析

    在posix标准推出后,socket在各大主流OS平台上都得到了很好的支持.而Golang是自带runtime的跨平台编程语言,Go中提供给开发者的socket API是建立在操作系统原生socket ...

  3. 『2019 SummerCamp 总结』

    做题 对于习题方面,我们感觉一个暑假还是留下了不少的题要写,大部分应该是讲师讲课的例题,还有少部分考试题.考试题没有订正完是因为还有算法不会,或是因为题太毒瘤了不会.同时,也发现自己还是有很多应该学的 ...

  4. MOOC 编译原理笔记(一):编译原理概述以及程序设计语言的定义

    编译原理概述 什么是编译程序 编译程序指:把某一种高级语言程序等价地转换成另一张低级语言程序(如汇编语言或机器代码)的程序. 高级语言程序-翻译->机器语言程序-运行->结果. 其中编译程 ...

  5. C# 填充客户端提交的值到T对象

    /// <summary>      /// 填充客户端提交的值到 T 对象  如appinfo = AppConvert.To<Appinfo>(context.Reques ...

  6. C#采集UVC摄像头画面并支持旋转和分辨率切换

    在项目中,我们会需要控制uvc摄像头,采集其实时画面,或者对其进行旋转.目前市面上大多数USB摄像头都支持UVC协议.那么如何采集呢?当然是采用SharpCamera!因为SharpCamera支持对 ...

  7. 第一章 Maven 安装配置

    Maven基于(POM)项目对象模型,通过一小段描述信息来管理项目的构建.文档.和报告的项目管理软件,类似于php 的管理构建工具composer. 有关详细的Maven学习,可以参考学习https: ...

  8. 【转载】 C#中ArrayList使用GetRange方法获取某一段集合数据

    在C#的编程开发中,ArrayList集合是一个常用的非泛型类集合,可以使用GetRange方法来获取集合中指定索引位置开始的一整段集合数据组成一个新的集合,GetRange方法的签名为virtual ...

  9. [echart] webpack中安装和使用

    安装echart npm install echarts --save 全量引入 可以直接在项目代码中 require('echarts') 得到 ECharts. 官方示例 var echarts ...

  10. springboot脚手架liugh-parent源码研究参考

    1. liugh-parent源码研究参考 1.1. 前言 这也是个开源的springboot脚手架项目,这里研究记录一些该框架写的比较好的代码段和功能 脚手架地址 1.2. 功能 1.2.1. 当前 ...