91欧美超碰AV自拍|国产成年人性爱视频免费看|亚洲 日韩 欧美一厂二区入|人人看人人爽人人操aV|丝袜美腿视频一区二区在线看|人人操人人爽人人爱|婷婷五月天超碰|97色色欧美亚州A√|另类A√无码精品一级av|欧美特级日韩特级

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內(nèi)不再提示

怎樣將Arduino數(shù)據(jù)直接存儲到MySQL

454398 ? 來源:網(wǎng)絡整理 ? 作者:網(wǎng)絡整理 ? 2019-11-20 17:08 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

步驟1:設置Arduino

怎樣將Arduino數(shù)據(jù)直接存儲到MySQL

刻錄以下內(nèi)容

void setup()

{

Serial.begin(9600);

}

void loop()

{

int i=0,j=0;

i=analogRead(A0);

j=analogRead(A1);

Serial.print(i);

Serial.print(“,”);

Serial.println(i);

}

步驟2:設置啟動MySQL

為MySQL安裝Wamp服務器并將其配置為存儲數(shù)據(jù)

運行wamp服務器

打開MySQL控制臺

選擇數(shù)據(jù)庫

然后為您的數(shù)據(jù)創(chuàng)建表

create table data(sno int(4) primary key auto_increment,LDR int(4),TEMP int(4));

使用desc your_table_name顯示表詳細信息

desc data;

這就是數(shù)據(jù)庫的全部內(nèi)容,現(xiàn)在我們可以進行處理了……

第3步:設置處理IDE

下載并安裝Processing IDE 2.2.1

將上述給定的ZIP壓縮到MyDocuments/Processing/Libraries中

現(xiàn)在打開正在處理的IDE和檢查庫是否已正確安裝(如上圖所示)

然后將以下代碼復制并進行處理,并自行命名

/*

ARDUINO TO MYSQL THROUGH PROCESSING

Read Serial messages from Arduino then write it in MySQL.

Author : J.V.JohnsonSelva September 2016

*/

import de.bezier.data.sql.*; //import the MySQL library

import processing.serial.*; //import the Serial library

MySQL msql; //Create MySQL Object

String[] a;

int end = 10; // the number 10 is ASCII for linefeed (end of serial.println), later we will look for this to break up individual messages

String serial; // declare a new string called ‘serial’ 。 A string is a sequence of characters (data type know as “char”)

Serial port; // The serial port, this is a new instance of the Serial class (an Object)

void setup() {

String user = “root”;

String pass = “”;

String database = “iot_database”;

msql = new MySQL( this, “l(fā)ocalhost”, database, user, pass );

port = new Serial(this, Serial.list()[0], 9600); // initializing the object by assigning a port and baud rate (must match that of Arduino)

port.clear(); // function from serial library that throws out the first reading, in case we started reading in the middle of a string from Arduino

serial = port.readStringUntil(end); // function that reads the string from serial port until a println and then assigns string to our string variable (called ‘serial’)

serial = null; // initially, the string will be null (empty)

}

void draw()

{

while (port.available() 》 0)

{

//as long as there is data coming from serial port, read it and store it

serial = port.readStringUntil(end);

}

if (serial != null)

{

//if the string is not empty, print the following

//Note: the split function used below is not necessary if sending only a single variable. However, it is useful for parsing (separating) messages when

//reading from multiple inputs in Arduino. Below is example code for an Arduino sketch

a = split(serial, ‘,’); //a new array (called ‘a(chǎn)’) that stores values into separate cells (separated by commas specified in your Arduino program

println(a[0]); //print LDR value

println(a[1]); //print LM35 value

function();

}

}

void function()

{

if ( msql.connect() )

{

msql.query( “insert into data(LDR,Temp)values(”+a[0]+“,”+a[1]+“)” );

}

else

{

// connection failed !

}

msql.close(); //Must close MySQL connection after Execution

}

第4步:執(zhí)行程序。

通過單擊“運行”按鈕運行程序,請關閉彈出窗口。關閉窗口將停止執(zhí)行,并在下面的查詢中查看在MySQL中存儲數(shù)據(jù)。..

select * from data;

查看數(shù)據(jù)插入器的數(shù)量可以使用下面的查詢。

select count(*) from data;

責任編輯:wv

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權轉載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學習之用,如有內(nèi)容侵權或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報投訴
  • MySQL
    +關注

    關注

    1

    文章

    909

    瀏覽量

    29589
  • Arduino
    +關注

    關注

    190

    文章

    6526

    瀏覽量

    197006
收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評論

    相關推薦
    熱點推薦

    恒訊科技解析:如何安裝MySQL并創(chuàng)建數(shù)據(jù)

    庫管理系統(tǒng)(RDBMS),使用結構化查詢語言(SQL)高效地組織和管理數(shù)據(jù)。它是全球最受歡迎的開源數(shù)據(jù)庫系統(tǒng)之一,廣泛應用于網(wǎng)頁開發(fā)、電子商務和商業(yè)應用。 常見用例? MySQL 是多種應用的可靠選擇,包括: 網(wǎng)絡應用:管理用戶
    的頭像 發(fā)表于 01-14 14:25 ?186次閱讀

    工業(yè)數(shù)據(jù)中臺支持接入MySQL數(shù)據(jù)庫嗎

    工業(yè)數(shù)據(jù)中臺完全支持接入MySQL數(shù)據(jù)庫 ,且通過數(shù)據(jù)同步、集成與治理等技術手段,能夠充分發(fā)揮MySQL
    的頭像 發(fā)表于 12-04 11:23 ?387次閱讀
    工業(yè)<b class='flag-5'>數(shù)據(jù)</b>中臺支持接入<b class='flag-5'>MySQL</b><b class='flag-5'>數(shù)據(jù)</b>庫嗎

    mysql數(shù)據(jù)恢復—mysql數(shù)據(jù)庫表被truncate的數(shù)據(jù)恢復案例

    某云ECS網(wǎng)站服務器,linux操作系統(tǒng),部署了mysql數(shù)據(jù)庫。工作人員在執(zhí)行數(shù)據(jù)庫版本更新測試時,錯誤地本應在測試庫執(zhí)行的sql腳本在生產(chǎn)庫上執(zhí)行了,導致部分表被truncate
    的頭像 發(fā)表于 09-11 09:28 ?888次閱讀
    <b class='flag-5'>mysql</b><b class='flag-5'>數(shù)據(jù)</b>恢復—<b class='flag-5'>mysql</b><b class='flag-5'>數(shù)據(jù)</b>庫表被truncate的<b class='flag-5'>數(shù)據(jù)</b>恢復案例

    如何觸摸校準存儲 SPI 閃存?

    觸摸校準存儲 SPI 閃存
    發(fā)表于 09-04 07:06

    MySQL數(shù)據(jù)備份與恢復策略

    數(shù)據(jù)是企業(yè)的核心資產(chǎn),MySQL作為主流的關系型數(shù)據(jù)庫管理系統(tǒng),其數(shù)據(jù)的安全性和可靠性至關重要。本文深入探討
    的頭像 發(fā)表于 07-14 11:11 ?754次閱讀

    企業(yè)級MySQL數(shù)據(jù)庫管理指南

    在當今數(shù)字化時代,MySQL作為全球最受歡迎的開源關系型數(shù)據(jù)庫,承載著企業(yè)核心業(yè)務數(shù)據(jù)存儲與處理。作為數(shù)據(jù)庫管理員(DBA),掌握
    的頭像 發(fā)表于 07-09 09:50 ?744次閱讀

    遠程訪問內(nèi)網(wǎng)MySQL數(shù)據(jù)庫?這個方案更簡單

    各位開發(fā)者朋友們,是否還在為無法隨時隨地訪問內(nèi)網(wǎng)MySQL數(shù)據(jù)庫而煩惱?今天分享一個超實用的方法,通過容器部署 MySQL 結合 ZeroNews 內(nèi)網(wǎng)穿透,讓你在任何地方都能安全訪問和管理數(shù)
    的頭像 發(fā)表于 07-04 18:06 ?888次閱讀
    遠程訪問內(nèi)網(wǎng)<b class='flag-5'>MySQL</b><b class='flag-5'>數(shù)據(jù)</b>庫?這個方案更簡單

    憶聯(lián) Docker+MySQL 流控方案:打造安全高效存儲底座,釋放 AI 極致性能

    探討基于Docker部署的MySQL數(shù)據(jù)庫在AI應用中的關鍵作用。通過憶聯(lián)PCIe5.0企業(yè)級SSD(UH812a)實測驗證,展示了Namespace技術與QoS優(yōu)化策略如何實現(xiàn)存儲資源的精細化管理
    的頭像 發(fā)表于 06-26 13:53 ?470次閱讀
    憶聯(lián) Docker+<b class='flag-5'>MySQL</b> 流控方案:打造安全高效<b class='flag-5'>存儲</b>底座,釋放 AI 極致性能

    MySQL數(shù)據(jù)庫采集網(wǎng)關是什么?有什么功能?

    MySQL數(shù)據(jù)庫采集網(wǎng)關是一種用于連接、采集、處理并傳輸數(shù)據(jù)MySQL數(shù)據(jù)庫的中間設備或軟件系
    的頭像 發(fā)表于 05-26 15:20 ?682次閱讀

    PLC數(shù)據(jù)中臺對接到MySQL數(shù)據(jù)庫并對接到生產(chǎn)看板

    工廠數(shù)據(jù)庫系統(tǒng)能夠存儲產(chǎn)品訂單信息、生產(chǎn)設備能力、原材料庫存等數(shù)據(jù)。這些數(shù)據(jù)接入MES或ERP等系統(tǒng),能夠實現(xiàn)生產(chǎn)管理的可視化應用?;谶@
    的頭像 發(fā)表于 05-26 11:20 ?549次閱讀
    PLC<b class='flag-5'>數(shù)據(jù)</b>中臺對接到<b class='flag-5'>MySQL</b><b class='flag-5'>數(shù)據(jù)</b>庫并對接到生產(chǎn)看板

    MySQL數(shù)據(jù)庫是什么

    MySQL數(shù)據(jù)庫是一種 開源的關系型數(shù)據(jù)庫管理系統(tǒng)(RDBMS) ,由瑞典MySQL AB公司開發(fā),后被Oracle公司收購。它通過結構化查詢語言(SQL)進行
    的頭像 發(fā)表于 05-23 09:18 ?1245次閱讀

    利用dockerfile搭建mysql主從集群和redis集群

    ==MySQL主從同步(Replication)是一種實現(xiàn)數(shù)據(jù)冗余和高可用性的技術,通過數(shù)據(jù)庫(Master)的變更操作同步一個或多個
    的頭像 發(fā)表于 05-14 11:38 ?2140次閱讀
    利用dockerfile搭建<b class='flag-5'>mysql</b>主從集群和redis集群

    數(shù)據(jù)采集MYSQL和SQLSERVER數(shù)據(jù)庫可以實現(xiàn)哪些功能

    ,確保企業(yè)各項數(shù)據(jù)資產(chǎn)得到合理存儲與管理,方便隨時調(diào)取、搜索,有助于提升管理水平與工作效率。 1.實時監(jiān)控與預警? 通過生產(chǎn)設備數(shù)據(jù)采集
    的頭像 發(fā)表于 05-07 15:32 ?597次閱讀

    #### KEPServerEX 數(shù)據(jù)存儲插件\\-2

    ,同類型的/同設備的參數(shù)可以設置成一樣的,這樣存儲數(shù)據(jù)庫之后,能夠更方便的在數(shù)據(jù)庫中進行檢索。 默認“數(shù)據(jù)項ID”是整形
    發(fā)表于 04-09 16:09

    NXP MCU RT1166如何使用JTAG/SWD工具數(shù)據(jù)存儲內(nèi)部閃存中?

    我需要使用 JTAG 數(shù)據(jù)存儲內(nèi)部閃存中。我能夠使用 JTAG/SWD 工具 ARM J-Link 將它們存儲在 FlexSPI1 連接
    發(fā)表于 04-01 06:54