瑚琦 姜敏 盧定凡
摘 要:我國(guó)水產(chǎn)養(yǎng)殖規(guī)模越來越大,種類越來越多,而傳統(tǒng)水產(chǎn)養(yǎng)殖環(huán)境下存在水溫參數(shù)自動(dòng)監(jiān)測(cè)系統(tǒng)投資大、實(shí)時(shí)性差等問題。提出基于Android系統(tǒng)、WiFi模塊和云平臺(tái)實(shí)現(xiàn)遠(yuǎn)程實(shí)時(shí)監(jiān)測(cè)養(yǎng)殖環(huán)境水溫的系統(tǒng)。系統(tǒng)主控模塊ESP8266和智能手機(jī)通過云服務(wù)器進(jìn)行數(shù)據(jù)傳輸,溫度傳感器DS18B20實(shí)時(shí)捕獲水溫,將參數(shù)通過云平臺(tái)傳輸協(xié)議轉(zhuǎn)發(fā)給遠(yuǎn)程云服務(wù)器,使用智能手機(jī)作為移動(dòng)終端實(shí)時(shí)監(jiān)測(cè)與調(diào)節(jié)水溫。該系統(tǒng)具有搭建成本低、可靠穩(wěn)定、方便簡(jiǎn)單易上手等優(yōu)點(diǎn)。
關(guān)鍵詞:Android;ESP8266;云平臺(tái);水溫遠(yuǎn)程監(jiān)測(cè)系統(tǒng);無線網(wǎng)絡(luò)
DOI:10. 11907/rjdk. 182839 開放科學(xué)(資源服務(wù))標(biāo)識(shí)碼(OSID):
中圖分類號(hào):TP319文獻(xiàn)標(biāo)識(shí)碼:A 文章編號(hào):1672-7800(2019)009-0108-04
Real-time Monitoring of Water Temperature in
Aquaculture Systems Based on Cloud Platform
HU Qi,JIANG Min,LU Ding-fan,CAI Wen-long
(School of Optical-Electrical and Computer Engineering,University of Shanghai for Science and Technology,Shanghai 200093,China)
Abstract:In view of the current large-scale aquaculture production in China, the types are becoming more and more abundant, and the traditional monitoring system of water temperature parameters in the traditional aquaculture environment has large investment and poor real-time performance. A system for remotely monitoring and regulating the temperature range of the aquaculture environment based on the android platform, WIFI module and cloud is put forward. The main control module ESP8266 and the smart phone in the system transmit data through the cloud server. The temperature sensor DS18B20 captures the water temperature in real time, passes the parameters and forwards it to the remote cloud serve through the cloud platform transmission protocol and the wireless network channel. Finally, the smartphone can be used as a mobile terminal to monitor and adjust the water temperature in real time. The system has the advantages of low construction cost, reliability, stability, convenience and ease of use.
Key Words: Android; ESP8266; cloud platform; remote monitoring system of water temperature; wireless network
0 引言
隨著經(jīng)濟(jì)的發(fā)展,水產(chǎn)食品需求不斷攀升,水產(chǎn)養(yǎng)殖業(yè)已成為我國(guó)當(dāng)前農(nóng)業(yè)經(jīng)濟(jì)的主要增長(zhǎng)點(diǎn)之一。資料表明魚類等水生生物不能像人類那樣通過新陳代謝活動(dòng)保持自身溫度的恒定,而只能與水溫保持相對(duì)穩(wěn)定(魚的最佳生理代謝溫度是15-25℃,而熱帶淡水魚的適宜溫度一般為24-28℃)[1-2]。當(dāng)溫度低于4℃或高于35℃時(shí),魚會(huì)產(chǎn)生生理不適甚至死亡。水溫的變化還會(huì)引起水體環(huán)境改變,間接對(duì)魚類產(chǎn)生影響[3-4],因此水溫的合理控制是養(yǎng)殖成功的關(guān)鍵因素之一。
國(guó)外早在2012年就將無線傳感器網(wǎng)絡(luò)技術(shù)應(yīng)用于水溫監(jiān)控,建立了水產(chǎn)養(yǎng)殖和銷售可追溯系統(tǒng),該系統(tǒng)可根據(jù)水溫水質(zhì)等數(shù)據(jù)進(jìn)行預(yù)警預(yù)報(bào),避免經(jīng)濟(jì)損失[5-6]。我國(guó)的監(jiān)測(cè)系統(tǒng)綜合成本高,應(yīng)用在小規(guī)模養(yǎng)殖區(qū)域,無線、ZigBee等傳輸技術(shù)還沒有大規(guī)模應(yīng)用,經(jīng)濟(jì)效益較差[7]。
本文提出基于物聯(lián)網(wǎng)技術(shù)的水產(chǎn)養(yǎng)殖環(huán)境參數(shù)監(jiān)控系統(tǒng),可以遠(yuǎn)程實(shí)時(shí)監(jiān)測(cè)與自動(dòng)控制水溫,技術(shù)成本低 [8]。將養(yǎng)殖現(xiàn)場(chǎng)以5m×5m的面積劃分為一個(gè)節(jié)點(diǎn),硬件系統(tǒng)分布式放置在各個(gè)節(jié)點(diǎn)中,各設(shè)備端將采集到的溫度數(shù)據(jù)通過傳輸協(xié)議匯總至云平臺(tái)服務(wù)器,移動(dòng)終端或PC平臺(tái)可遠(yuǎn)程實(shí)時(shí)監(jiān)測(cè),調(diào)節(jié)各養(yǎng)殖范圍的溫度,保證水溫環(huán)境適宜,現(xiàn)場(chǎng)監(jiān)視屏可直觀顯示各節(jié)點(diǎn)水溫。
1 系統(tǒng)總體設(shè)計(jì)
系統(tǒng)主要由溫度傳感器模塊、云平臺(tái)傳輸協(xié)議模塊、WiFi主控模塊、手機(jī)端控制模塊組成,按功能分為信息采集、信息記錄及云端上傳、信息實(shí)時(shí)監(jiān)測(cè)與遠(yuǎn)程控制3部分 [9]。
(1)信息采集:通過外置的溫度傳感器像人類器官一樣將感受到的溫度信息采集起來。
3.2 移動(dòng)終端軟件設(shè)計(jì)
WiFi模塊將采集到的溫度數(shù)據(jù)打包,通過網(wǎng)絡(luò)傳輸?shù)綑C(jī)智云平臺(tái)的遠(yuǎn)程服務(wù)器上,APP終端通過與遠(yuǎn)程服務(wù)器通信獲得水溫監(jiān)測(cè)數(shù)據(jù)。云平臺(tái)服務(wù)器需對(duì)新建工程進(jìn)行項(xiàng)目配置,建立數(shù)據(jù)點(diǎn),然后綁定APP。下面給出APP端發(fā)送數(shù)據(jù)給云端和APP從云端接收數(shù)據(jù)的主要函數(shù)及解釋。
(1)發(fā)送數(shù)據(jù):給設(shè)備發(fā)送控制指令,參數(shù)data為要發(fā)給設(shè)備的操作指令,sn為控制指令序號(hào),用于對(duì)應(yīng)控制指令應(yīng)答數(shù)據(jù)。
public void write(Concurrent HashMap
(2)接收反饋數(shù)據(jù):當(dāng) SDK 遇到無法解析的數(shù)據(jù)時(shí),會(huì)作為透?jìng)鲾?shù)據(jù)處理,此時(shí)錯(cuò)誤碼為GIZ_SDK_SUCCESS[18]。函數(shù)中的參數(shù)解釋如下:device:回復(fù)狀態(tài)的設(shè)備對(duì)象;result:GIZ_SDK_SUCCESS表示成功,其它為失敗;data:設(shè)備上報(bào)的數(shù)據(jù)內(nèi)容;sn:控制指令的應(yīng)答序號(hào),此應(yīng)答序號(hào)與 APP 發(fā)送控制指令序號(hào)一致。
public void didReceiveData(GizWifiErrorCode result,GizWifiDevice device,
Concurrent HashMap
將智能設(shè)備通過WiFi連接到云端后,就可用生成的APP實(shí)時(shí)查看水溫狀態(tài),控制目標(biāo)設(shè)備。圖7、圖8分別是云后臺(tái)的數(shù)據(jù)記錄和本監(jiān)測(cè)系統(tǒng)APP開發(fā)的界面,圖中的temp表示監(jiān)測(cè)到的水溫,是只讀狀態(tài)。auto_mode為自動(dòng)手動(dòng)切換模式,0表示自動(dòng)調(diào)整,設(shè)備端將自動(dòng)根據(jù)環(huán)境數(shù)據(jù)判斷是否調(diào)高或調(diào)低水溫;1為手動(dòng)模式,由用戶決定是否調(diào)節(jié)水溫[19]。heating_switch為手動(dòng)模式下控制水溫加熱裝置的開關(guān)。
4 結(jié)語(yǔ)
隨著機(jī)械設(shè)施和生產(chǎn)系統(tǒng)的精密化,對(duì)物理設(shè)備的設(shè)計(jì)、制造、維護(hù)等提出了更高要求[20]。本文溫度調(diào)控系統(tǒng)可實(shí)現(xiàn)水產(chǎn)養(yǎng)殖環(huán)境的水溫遠(yuǎn)程精確測(cè)量與調(diào)節(jié),解決了以往監(jiān)測(cè)水溫人力資源浪費(fèi)、設(shè)備維護(hù)成本高且性能不穩(wěn)定、數(shù)據(jù)傳輸速度慢等問題,利用無線遠(yuǎn)程技術(shù)極大提高了監(jiān)測(cè)效率[21]。其它指標(biāo)如水體PH值、光照強(qiáng)度、水中含氧量等數(shù)據(jù)采集都可通過這種方法實(shí)現(xiàn),該監(jiān)測(cè)系統(tǒng)實(shí)用性強(qiáng)。
參考文獻(xiàn):
[1] 駱東松, 韓雪晴. 基于機(jī)智云平臺(tái)的滾動(dòng)軸承在線監(jiān)測(cè)系統(tǒng)[J]. 單片機(jī)與嵌入式系統(tǒng)應(yīng)用,2016(7):68-71.
[2] 李小勇,于群,趙紅玉,等. 南疆地區(qū)的大規(guī)模農(nóng)田遠(yuǎn)程監(jiān)測(cè)系統(tǒng)設(shè)計(jì)[J]. 單片機(jī)與嵌入式系統(tǒng)應(yīng)用,2016(6):54-57.
[3] DHOLU M,MRS ?K A. Ghodinde internet of things (iot) for precision agriculture application[C]. Proceedings of the 2nd International Conference on Trends in Electronics and Informatics,2018:339-342.
[4] LI Y Q, HE J Z. Design of indoor environment monitoring system based on WiFi[C]. Advanced Information Management Communicates Electronic and Automation Control Conference,2018:1842-1845.
[5] TANMAY B,NIKITA,PUSHPENDRA KUMAR P. Development of IoT based smart security and monitotoring device for agriculturre[C]. IEEE 6th International conference-cloud system and big data Engineering,2016.
[6] SHOPAN DEY,AYON ROY,SANDIP DAS. Home automation using internet of thing[C]. Ubiquitous Computing Electronics & Mobile Communication Conference(UEMCON) IEEE Annual,2016:256-259.
[7] SARASWATI SAHA,ANUPAM MAJUMDAR. Data centre temperature monitoring with esp8266 based wireless sensor network and cloud based dashboard with real time alert system[C]. Devices for Integrated Circuit. IEEE,2017:307-310.
[8] 朱文錦,冉綱軍. 水產(chǎn)養(yǎng)殖環(huán)境參數(shù)自動(dòng)監(jiān)控系統(tǒng)研究[J]. 淡水漁業(yè),2001(1):60-61.
[9] 汪傳生,方德光,張金秀,等. 開源硬件Arduino與樂聯(lián)網(wǎng)的農(nóng)業(yè)環(huán)境實(shí)時(shí)監(jiān)測(cè)系統(tǒng)[J]. 單片機(jī)與嵌入式系統(tǒng)應(yīng)用,2018(5):49-52.
[10] 曹豐年,李穎,張曉蕊,等. 基于WiFi技術(shù)的智能家居系統(tǒng)設(shè)計(jì)[J]. 軟件導(dǎo)刊,2017(8):67-72.
[11] 戴磊,李華,金翰林. 基于ESP8266的一種WiFi控制插座設(shè)計(jì)[J]. 裝備制造技術(shù),2017(4):12-14.