女人自慰AV免费观看内涵网,日韩国产剧情在线观看网址,神马电影网特片网,最新一级电影欧美,在线观看亚洲欧美日韩,黄色视频在线播放免费观看,ABO涨奶期羡澄,第一导航fulione,美女主播操b

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

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

3天內不再提示

怎樣將Arduino數據直接存儲到MySQL

454398 ? 來源:網絡整理 ? 作者:網絡整理 ? 2019-11-20 17:08 ? 次閱讀

步驟1:設置Arduino

怎樣將Arduino數據直接存儲到MySQL

刻錄以下內容

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服務器并將其配置為存儲數據

運行wamp服務器

打開MySQL控制臺

選擇數據庫

然后為您的數據創建表

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

使用desc your_table_name顯示表詳細信息

desc data;

這就是數據庫的全部內容,現在我們可以進行處理了……

第3步:設置處理IDE

下載并安裝Processing IDE 2.2.1

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

現在打開正在處理的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, “localhost”, 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’) 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步:執行程序。

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

select * from data;

查看數據插入器的數量可以使用下面的查詢。

select count(*) from data;

責任編輯:wv

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

    關注

    1

    文章

    849

    瀏覽量

    27518
  • Arduino
    +關注

    關注

    188

    文章

    6491

    瀏覽量

    190091
收藏 人收藏

    評論

    相關推薦
    熱點推薦

    MySQL數據庫是什么

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

    數據采集MYSQL和SQLSERVER數據庫可以實現哪些功能

    ,確保企業各項數據資產得到合理存儲與管理,方便隨時調取、搜索,有助于提升管理水平與工作效率。 1.實時監控與預警? 通過生產設備數據采集
    的頭像 發表于 05-07 15:32 ?125次閱讀

    NXP MCU RT1166如何使用JTAG/SWD工具數據存儲內部閃存中?

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

    從Delphi、C++ Builder和Lazarus連接到MySQL數據

    平臺。 基于 MyDAC 的應用程序可以直接連接到 MySQL 服務器或通過 MySQL 客戶端庫工作。MySQL 數據訪問組件旨在幫助程序
    的頭像 發表于 01-20 13:47 ?599次閱讀
    從Delphi、C++ Builder和Lazarus連接到<b class='flag-5'>MySQL</b><b class='flag-5'>數據</b>庫

    使用插件Excel連接到MySQL/MariaDB

    ,可以快速地數據MySQL 或 MariaDB 加載到 Excel,立即從數據庫刷新 Excel 工作簿中的數據,編輯這些
    的頭像 發表于 01-20 12:38 ?512次閱讀
    使用插件<b class='flag-5'>將</b>Excel連接到<b class='flag-5'>MySQL</b>/MariaDB

    適用于MySQL和MariaDB的Python連接器:可靠的MySQL數據連接器和數據

    和 Linux 的 wheel 包分發。 直接連接 該解決方案使您能夠通過 TCP/IP 建立與 MySQL 或者 MariaDB 數據庫服務器的直接連接,而無需
    的頭像 發表于 01-17 12:18 ?427次閱讀
    適用于<b class='flag-5'>MySQL</b>和MariaDB的Python連接器:可靠的<b class='flag-5'>MySQL</b><b class='flag-5'>數據</b>連接器和<b class='flag-5'>數據</b>庫

    MySQL數據庫的安裝

    MySQL數據庫的安裝 【一】各種數據庫的端口 MySQL :3306 Redis :6379 MongoDB :27017 Django :8000 flask :5000 【二】
    的頭像 發表于 01-14 11:25 ?479次閱讀
    <b class='flag-5'>MySQL</b><b class='flag-5'>數據</b>庫的安裝

    數據數據恢復—Mysql數據庫表記錄丟失的數據恢復流程

    Mysql數據庫故障: Mysql數據庫表記錄丟失。 Mysql數據庫故障表現: 1、
    的頭像 發表于 12-16 11:05 ?518次閱讀
    <b class='flag-5'>數據</b>庫<b class='flag-5'>數據</b>恢復—<b class='flag-5'>Mysql</b><b class='flag-5'>數據</b>庫表記錄丟失的<b class='flag-5'>數據</b>恢復流程

    MySQL數據遷移的流程介紹

    數據存儲在同一個數據庫中。當其他業務出現慢 SQL 等異常情況時,可能會直接影響到預約業務,從而降低系統整體的可靠性和穩定性。為了盡可能提高系統的穩定性和
    的頭像 發表于 11-25 09:20 ?439次閱讀
    <b class='flag-5'>MySQL</b><b class='flag-5'>數據</b>遷移的流程介紹

    香港云服務器怎么部署MySQL數據庫?

    在香港云服務器上部署MySQL數據庫的步驟如下: 步驟 1: 更新軟件包列表 首先,確保軟件包列表是最新的。在終端中執行以下命令: sudo apt update 步驟 2: 安裝 MySQL
    的頭像 發表于 11-14 16:15 ?461次閱讀

    IG902如何上傳數據MQTT云平臺EMQX ?

    /PLC%20Supervisor%E7%94%A8%E6%88%B7%E6%89%8B%E5%86%8C.html#mqtt 6.配置客戶端數據存儲Mysql 1)手動新建
    發表于 07-25 07:09

    在FX3S上如何通過USB和GPIF數據存儲eMMC中?

    我使用的是賽普拉斯 FX3S。 S0 端口連接了 eMMC,FX3S 還連接了 TI DSP(TMS320C28346ZFE)。 我想通過 USB 數據和/或文件從主機 PC 存儲
    發表于 07-23 07:57

    為什么無法在nodemcu和arduino mega之間交換數據

    您好,我正在嘗試通過 UART 在 arduino mega 和 nodemcu 之間交換數據(使用 arduino IDE 對兩者進行編程)。 我
    發表于 07-19 12:15

    格式化數據存儲char數組的最簡單方法是什么?

    os_printf文本格式化為 UART 輸出的函數。 格式化數據存儲 char 數組的最簡單方法是什么?
    發表于 07-11 08:01

    求助,在esp-idf中使用arduino作為組件后怎樣使用arduino的庫?

    在esp-idf中使用arduino作為組件后怎樣使用arduino的庫,例如我此時需要使用arduino的第三方庫blinker,怎樣使用
    發表于 06-12 07:21