Arduino数据输出到excel

在用MPU6050的时候想要把加速度和角速度的信息做成图表,但SerialChart只能实时的显示图形但貌似不能一个个导出来,我在网上找了一下发现没有特别好的输出到excel的方法,翻出去后看到一篇英文博客在讲用一个叫PLX-DAQ的软件来输出,我下下来用了而且成功了!操作非常简单,在这里记录一下。

首先下载PLX-DAQ(附件在最后),安装好后是一个文件夹,里面有一个叫做Spreadsheet的excel文件。注意一定要用office的excel打开,wps那个不行。进去后让加载什么X控件,加载它,之后就是这么个东西。

很明显,串口和波特率设为和arduino的一样,右边是重置时间和清空列表。

在arduino setup()函数里写下这些

   Serial.print("DATA,TIME,TIMER,");
Serial.print(aax);Serial.print(",");
Serial.print(aaz);Serial.print(",");
Serial.print(ggx);Serial.print(",");
Serial.print(ggy);Serial.print(",");
Serial.println(ggz);

  • 7
    点赞
  • 52
    收藏
    觉得还不错? 一键收藏
  • 8
    评论
要将Arduino数据传输到MySQL,可以使用以下步骤: 1. 首先,需要编写一个Arduino程序来收集传感器数据并将其发送到计算机上运行的PHP脚本。可以使用Arduino的串行通信库来与计算机进行通信。可以使用以下代码示例从Arduino发送数据: ``` // Setup the serial port at 9600 baud void setup() { Serial.begin(9600); } // Read the sensor data and send it over serial void loop() { int sensorValue = analogRead(A0); Serial.println(sensorValue); delay(1000); } ``` 2. 在计算机上,需要编写一个PHP脚本来接收从Arduino发送的数据并将其插入到MySQL数据库中。可以使用以下代码示例来获取从Arduino发送的数据并将其插入到MySQL数据库中: ``` <?php // Connect to the MySQL database $servername = "localhost"; $username = "username"; $password = "password"; $dbname = "database"; $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // Get the data sent from the Arduino $data = $_GET['data']; // Insert the data into the MySQL database $sql = "INSERT INTO sensor_data (value) VALUES ('$data')"; if ($conn->query($sql) === TRUE) { echo "New record created successfully"; } else { echo "Error: " . $sql . "<br>" . $conn->error; } // Close the MySQL connection $conn->close(); ?> ``` 3. 最后,需要在Arduino程序中使用HTTP GET请求将传感器数据发送到PHP脚本。可以使用Arduino的Ethernet或WiFi库来进行HTTP请求。可以使用以下代码示例从Arduino发送HTTP GET请求: ``` #include <Ethernet.h> // Set the MAC address and IP address of the Arduino byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; IPAddress ip(192, 168, 1, 177); // Set the IP address of the server running the PHP script IPAddress server(192, 168, 1, 100); // Set the path to the PHP script char path[] = "/insert_data.php"; // Setup the Ethernet client EthernetClient client; void setup() { // Start the Ethernet connection Ethernet.begin(mac, ip); // Wait for the Ethernet connection to be established while (!Ethernet.ready()) { delay(1000); } } void loop() { // Read the sensor data int sensorValue = analogRead(A0); // Send an HTTP GET request to the PHP script with the sensor data if (client.connect(server, 80)) { client.print("GET "); client.print(path); client.print("?data="); client.print(sensorValue); client.println(" HTTP/1.1"); client.println("Host: 192.168.1.100"); client.println("Connection: close"); client.println(); } // Wait for a response from the server while (client.connected()) { if (client.available()) { char c = client.read(); Serial.print(c); } } // Wait for 1 second before sending the next request delay(1000); } ``` 使用以上步骤,就可以将Arduino数据传输到MySQL了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值