在线观看www成人影院-在线观看www日本免费网站-在线观看www视频-在线观看操-欧美18在线-欧美1级

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

完善資料讓更多小伙伴認(rèn)識你,還能領(lǐng)取20積分哦,立即完善>

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

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

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

掃碼添加小助手

加入工程師交流群

步驟1:設(shè)置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:設(shè)置啟動MySQL

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

運(yùn)行wamp服務(wù)器

打開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顯示表詳細(xì)信息

desc data;

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

第3步:設(shè)置處理IDE

下載并安裝Processing IDE 2.2.1

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

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

然后將以下代碼復(fù)制并進(jìn)行處理,并自行命名

/*

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í)行程序。

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

select * from data;

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

select count(*) from data;

責(zé)任編輯:wv

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

    關(guān)注

    1

    文章

    854

    瀏覽量

    27837
  • Arduino
    +關(guān)注

    關(guān)注

    189

    文章

    6497

    瀏覽量

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

掃碼添加小助手

加入工程師交流群

    評論

    相關(guān)推薦
    熱點(diǎn)推薦

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

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

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

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

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

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

    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

    從Delphi、C++ Builder和Lazarus連接到MySQL數(shù)據(jù)

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

    使用插件Excel連接到MySQL/MariaDB

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

    適用于MySQL和MariaDB的Python連接器:可靠的MySQL數(shù)據(jù)連接器和數(shù)據(jù)

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

    MySQL數(shù)據(jù)庫的安裝

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

    數(shù)據(jù)數(shù)據(jù)恢復(fù)—Mysql數(shù)據(jù)庫表記錄丟失的數(shù)據(jù)恢復(fù)流程

    Mysql數(shù)據(jù)庫故障: Mysql數(shù)據(jù)庫表記錄丟失。 Mysql數(shù)據(jù)庫故障表現(xiàn): 1、
    的頭像 發(fā)表于 12-16 11:05 ?598次閱讀
    <b class='flag-5'>數(shù)據(jù)</b>庫<b class='flag-5'>數(shù)據(jù)</b>恢復(fù)—<b class='flag-5'>Mysql</b><b class='flag-5'>數(shù)據(jù)</b>庫表記錄丟失的<b class='flag-5'>數(shù)據(jù)</b>恢復(fù)流程

    MySQL數(shù)據(jù)遷移的流程介紹

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

    香港云服務(wù)器怎么部署MySQL數(shù)據(jù)庫?

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

    IG902如何上傳數(shù)據(jù)MQTT云平臺EMQX ?

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

    在FX3S上如何通過USB和GPIF數(shù)據(jù)存儲eMMC中?

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

    為什么無法在nodemcu和arduino mega之間交換數(shù)據(jù)

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

    格式化數(shù)據(jù)存儲char數(shù)組的最簡單方法是什么?

    os_printf文本格式化為 UART 輸出的函數(shù)。 格式化數(shù)據(jù)存儲 char 數(shù)組的最簡單方法是什么?
    發(fā)表于 07-11 08:01
    主站蜘蛛池模板: 欧美第一色 | 国产清纯白嫩大学生正在播放 | 天天添天天操 | 亚洲婷婷在线视频 | 亚洲色图吧 | 黄色三级在线观看 | 欧美日韩一卡2卡三卡4卡新区 | 国内精品手机在线观看视频 | 香蕉视频在线免费播放 | 国产亚洲第一 | 在线a人片免费观看不卡 | 年轻人影院www你懂的 | 色www永久免费 | 欧美一级日韩一级亚洲一级 | 在线播放一区二区三区 | аⅴ天堂中文在线网 | 亚洲综合丁香婷婷六月香 | 在线免费公开视频 | 亚洲看片 | 成人小视频在线 | 久久网综合 | 黄色网址你懂得 | 免费久久久久 | 国产叼嘿视频网站在线观看 | 亚洲精品91大神在线观看 | 国产精品午夜自在在线精品 | 91在线免费看 | 椎名空中文字幕一区二区 | 四虎电影免费观看网站 | 国产精品二区三区免费播放心 | 在线观看国产久青草 | 天天干夜夜欢 | 真实偷清晰对白在线视频 | 台湾香港澳门三级在线 | 性色在线观看 | 天天摸夜夜添夜夜添国产 | 黄色在线观看视频网站 | 国产yin乱大巴视频 国产爱v | 亚洲啊v在线 | 干成人网| 日韩a毛片 |