韓團軍
關(guān)鍵詞: 監(jiān)測系統(tǒng); 實時采集; ZigBee; WiFi; 環(huán)境監(jiān)測; CC2430
中圖分類號: TN926+.23?34 ? ? ? ? ? ? ? ? ? ?文獻標(biāo)識碼: A ? ? ? ? ? ? ? ? ? ? ?文章編號: 1004?373X(2019)02?0014?04
Research on mountainous farmland environmental monitoring
system based on WiFi and ZigBee
HAN Tuanjun
(School of Physics & Telecommunications Engineering, Shaanxi University of Technology, Hanzhong 723000, China)
Abstract: A mountainous farmland environmental monitoring system based on WiFi and ZigBee is designed according to the environmental characteristics and application requirements of mountainous areas, so as to solve the limitations of the traditional mountainous farmland environmental monitoring system. The temperature?humidity sensor, illumination sensor and CO2 sensor are selected for the system to conduct real?time acquisition of environmental parameters. The CC2430 radio frequency chip is adopted to complete the function of the ZigBee protocol. Data transmission and connection to the upper computer are realized by combining with the WiFi protocol. The Web server is used for the personal computer to display, process and store data. The experimental results show that the system can realize accurate detection of environmental parameters, which can expand its application range.
Keywords: monitoring system; real?time acquisition; ZigBee; WiFi; environment monitoring; CC2430
隨著我國對農(nóng)業(yè)生產(chǎn)環(huán)境要求不斷提升和農(nóng)業(yè)信息化水平的提高,實現(xiàn)山區(qū)農(nóng)業(yè)環(huán)境參數(shù)實時監(jiān)測,智能傳輸和數(shù)據(jù)處理具有重要的戰(zhàn)略應(yīng)用價值。傳統(tǒng)的無線監(jiān)測網(wǎng)絡(luò)采用單一的無線傳輸模式,由于監(jiān)測點環(huán)境廣泛性和特殊性,這種監(jiān)測方法無法解決使用時的耗能和傳輸速率問題,而且安裝不變[1?3]。
為了解決以上問題,結(jié)合山區(qū)地貌的實際環(huán)境本文提出基于WiFi與ZigBee技術(shù)的環(huán)境監(jiān)測系統(tǒng)。該方法是將ZigBee技術(shù)的低功耗、可自組網(wǎng)和多跳傳輸?shù)奶攸c和具有易于和工業(yè)以太網(wǎng)相互融合傳輸速率比較高的WiFi技術(shù)相結(jié)合??梢詫崿F(xiàn)在低功耗和減少傳感器數(shù)量基礎(chǔ)上對當(dāng)?shù)丨h(huán)境的精確測量[4?6]。
該系統(tǒng)是通過無線傳感器節(jié)點完成對當(dāng)?shù)丨h(huán)境參數(shù)的采集并將采集到的參數(shù)通過ZigBee協(xié)議傳輸?shù)絑igBee?WiFi網(wǎng)關(guān)。由于ZigBee技術(shù)無法與外網(wǎng)直接融合,所以必須使用WiFi技術(shù)作為中轉(zhuǎn),ZigBee?WiFi網(wǎng)關(guān)作用就是實現(xiàn)協(xié)議之間的轉(zhuǎn)換。
通過協(xié)議網(wǎng)關(guān)轉(zhuǎn)換,參數(shù)就可以在ZigBee和WiFi之間進行傳輸和應(yīng)用。上位機接收、存儲和顯示通過ZigBee傳輸?shù)絑igBee?WiFi網(wǎng)關(guān)的傳感器節(jié)點采集到的數(shù)據(jù)[7?9]。整個系統(tǒng)的硬件框圖如圖1所示。
智能傳感器節(jié)點的硬件結(jié)構(gòu),ZigBee路由節(jié)點硬件的關(guān)鍵是選擇能耗和成本比較合適的微處理器芯片,為了增加節(jié)點數(shù)據(jù)的處理和存儲能力,采用TI公司片上系統(tǒng)CC2430通信模塊。該模塊能夠滿足以ZigBee為基礎(chǔ)的2.4 GHz ISM波段的應(yīng)用。該芯片集成了一個2.4 GHz DSSS的收發(fā)器和高性能的8051控制器,支持多種ZigBee協(xié)議。傳感器節(jié)點如圖2所示。當(dāng)?shù)貐^(qū)的溫濕度數(shù)據(jù)由SHT71傳感器采集,ISL29010完成地區(qū)的光照數(shù)據(jù)、濕溫度數(shù)據(jù)與光照數(shù)據(jù)通過I2C協(xié)議與CC2430進行通信。CO2氣體濃度采集選用紅外原理的B530傳感器,其原理是根據(jù)CO2對一定波段紅外輻射的吸收作用,使得指定測量范圍內(nèi)輻射能量減弱程度來決定CO2的濃度。土壤的濕度由FDS100傳感器進行采集。溫度采用DS18B20進行測量,CO2和土壤的溫濕度參數(shù)都是通過CC2430的P0端口進行采集電壓信號的變化。CC2430完成數(shù)據(jù)的打包與判斷,通過差分信號輸入到圖2中天線模塊;天線模塊對CC2430輸出的差分信號通過放大進行發(fā)射,同時將接收網(wǎng)關(guān)傳回的信號傳入CC2430模塊中[10?14]。
2.1 ?WiFi模塊的設(shè)計
硬件中WiFi模塊是針對ZigBee?WiFi設(shè)計的,其作用是完成數(shù)據(jù)從ZigBee模式向WiFi模式的轉(zhuǎn)換和WiFi模塊對信號的收發(fā)。WiFi模塊和CC2430通過串口進行通信,WiFi模塊通過串口接收CC2430上傳的當(dāng)?shù)丨h(huán)境參數(shù)的采集信息,并通過WiFi協(xié)議和工業(yè)以太網(wǎng)進行通信;同時上位機控制指令通過WiFi模塊發(fā)送給網(wǎng)關(guān)節(jié)點,其指令通過CC2430進行處理后通過ZigBee協(xié)議傳送到相應(yīng)的智能采集節(jié)點。WiFi模塊采用ESP8266,特點是具有尺寸小、硬件接口多、功耗低、傳輸數(shù)據(jù)量大、速度快、通信協(xié)議簡單、操作方便等眾多優(yōu)點,最重要的是內(nèi)嵌TCP/IP協(xié)議,使網(wǎng)絡(luò)數(shù)據(jù)傳輸更方便。單片機通過USART串口和該模塊進行通信,發(fā)送AT命令即可輕松完成配置,全雙工通信的性能使得終端和底層硬件實現(xiàn)完美結(jié)合,有效地提高了數(shù)據(jù)的實時性。設(shè)計中將WiFi模塊與單片機的串口2相連如圖3所示。
2.2 ?ZigBee模塊的設(shè)計
設(shè)計ZigBee模塊時,傳感器節(jié)點的硬件連接可以通過I2C串口數(shù)字模式讀取數(shù)據(jù),這種設(shè)計方法不僅可以節(jié)省處理器接口資源而且連線方便。其中傳感器引腳一般接CC2430芯片的P06和P07接口。具體電路如圖4所示。
系統(tǒng)的軟件設(shè)計包括ZigBee?WiFi網(wǎng)關(guān)程序和智能采集節(jié)點的程序。
1) 數(shù)據(jù)采集節(jié)點程序。該節(jié)點程序主要完成地區(qū)的數(shù)據(jù)采集。系統(tǒng)上電后先是各個節(jié)點初始化同時網(wǎng)絡(luò)進行自檢,網(wǎng)絡(luò)建立成功后,當(dāng)監(jiān)聽到網(wǎng)關(guān)指令系統(tǒng)時按照設(shè)定的時間進行周期性的數(shù)據(jù)采集和信號傳輸,如果沒有新的指令系統(tǒng)處于監(jiān)聽狀態(tài),等候網(wǎng)關(guān)有新命令傳達。具體流程圖如圖5所示。
2) ZigBee?WiFi網(wǎng)關(guān)節(jié)點程序。ZigBee?WiFi網(wǎng)關(guān)節(jié)點程序是建立在應(yīng)用層上的協(xié)議轉(zhuǎn)換器,完成整個區(qū)域內(nèi)數(shù)據(jù)傳輸?shù)目刂埔约癦igBee和WiFi兩個相對獨立網(wǎng)絡(luò)之間的傳輸中的協(xié)議轉(zhuǎn)換。通過網(wǎng)關(guān)節(jié)點可以使傳感器節(jié)點的數(shù)據(jù)在不存儲的情況下發(fā)送給上位機,也可以使上位機的指令發(fā)送給指定的節(jié)點。網(wǎng)關(guān)節(jié)點流程圖如圖6所示。
為了方便讀取數(shù)據(jù),設(shè)計Web服務(wù)器環(huán)境遠程監(jiān)測軟件,采用B/S結(jié)構(gòu)的Web服務(wù)器。通過系統(tǒng)測試,該系統(tǒng)可以穩(wěn)定實現(xiàn)環(huán)境參數(shù)測量,檢測軟件,用戶界面上能穩(wěn)定顯示當(dāng)前地區(qū)的數(shù)據(jù)結(jié)果,用戶顯示界面如圖7所示。
通過對系統(tǒng)進行軟硬件設(shè)計,通過實驗環(huán)境測試系統(tǒng)可以穩(wěn)定對山區(qū)環(huán)境參數(shù)進行測量。測量數(shù)據(jù)通過ZigBee網(wǎng)絡(luò)傳到ZigBee?WiFi無線網(wǎng)關(guān),再通過WiFi技術(shù)將數(shù)據(jù)轉(zhuǎn)發(fā)給上位機應(yīng)用軟件。表1為系統(tǒng)中某一智能傳感器節(jié)點發(fā)回的當(dāng)?shù)貐^(qū)在1 h內(nèi)每隔10 min的環(huán)境參數(shù)數(shù)據(jù)。
根據(jù)現(xiàn)代農(nóng)業(yè)對環(huán)境的要求和山區(qū)環(huán)境的特點,設(shè)計基于WiFi與ZigBee的山區(qū)農(nóng)田環(huán)境監(jiān)測系統(tǒng)。該系統(tǒng)能對山區(qū)環(huán)境實時監(jiān)測,并可以通過ZigBee?WiFi網(wǎng)關(guān)實現(xiàn)測量參數(shù)的無線傳輸,且方便接入上位機。通過LabVIEW實現(xiàn)上位機對測量參數(shù)的實時處理和顯示。測量結(jié)果表明,該系統(tǒng)成本較低、功耗小,能夠滿足山區(qū)農(nóng)業(yè)環(huán)境的實時監(jiān)測要求,具有一定的農(nóng)業(yè)推廣應(yīng)用價值。
參考文獻
[1] 韓泊,苗長云,戈立軍.基于ZigBee的人體心電信號無線監(jiān)測系統(tǒng)的設(shè)計[J].計算機測量與控制,2014,22(7):2067?2069.
HAN Bo, MIAO Changyun, GE Lijun. Wireless human body ECG monitoring system based on ZigBee [J]. Computer measurement & control, 2014, 22(7): 2067?2069.
[2] 韓瀟,徐曉輝,宋濤,等.基于WiFi的無線傳感器網(wǎng)絡(luò)安全性研究[J].中國農(nóng)機化學(xué)報,2015,36(5):231?233.
HAN Xiao, XU Xiaohui, SONG Tao, et al. Security research of wireless sensor networks based on WiFi [J]. Journal of Chinese agricultural mechanization, 2015, 36(5): 231?233.
[3] 鄭爭兵.面向有毒氣體監(jiān)測的無線傳感器網(wǎng)絡(luò)系統(tǒng)的實現(xiàn)[J].計算機與應(yīng)用化學(xué),2015,32(5):631?633.
ZHENG Zhengbing. Implementation of wireless sensor network system for poisonous gases monitoring [J]. Computers and applied chemistry, 2015, 32(5): 631?633.
[4] 仲偉波,王婷婷,張澤武.基于ZigBee與WiFi的環(huán)境智能傳感系統(tǒng)研制[J].農(nóng)機化研究,2012,34(12):186?189.
ZHONG Weibo, WANG Tingting, ZHANG Zewu. Intelligent environmental sensing system based on ZigBee and WiFi [J]. Journal of agricultural mechanization research, 2012, 34(12): 186?189.
[5] 周聰聰,涂春龍,高云,等.腕戴式低功耗無線心率監(jiān)測裝置的研制[J].浙江大學(xué)學(xué)報(工學(xué)版),2015,49(4):798?805.
ZHOU Congcong, TU Chunlong, GAO Yun, et al. Low power, wireless, wrist?worn device for HR monitoring based on double channels of pulse sensing [J]. Journal of Zhejiang University (Engineering science), 2015, 49(4): 798?805.
[6] 梅志堅,馬婭婕,肖凡男.基于ZigBee和GPRS的大氣污染監(jiān)測系統(tǒng)設(shè)計[J].武漢科技大學(xué)學(xué)報,2015,38(1):63?66.
MEI Zhijian, MA Yajie, XIAO Fannan, et al. Design of air pollution monitoring system based on ZigBee and GPRS [J]. Journal of Wuhan University of Science and Technology, 2015, 38(1): 63?66.
[7] 張西良,丁飛,張世慶.現(xiàn)代溫室分布式無線數(shù)據(jù)采集系統(tǒng)的設(shè)計[J].儀表技術(shù)與傳感器,2007(4):40?41.
ZHANG Xiliang, DING Fei, ZHANG Shiqing. Design of modern greenhouse distributed wireless data acquisition system [J]. Instrument technique and sensor, 2007(4): 40?41.
[8] 賈艷玲,劉思遠.基于ZigBee技術(shù)的葡萄園智能灌溉系統(tǒng)設(shè)計[J].江蘇農(nóng)業(yè)科學(xué),2015,43(6):383?385.
JIA Yanling, LIU Siyuan. Design of vineyard intelligent irrigation system based on ZigBee technology [J]. Jiangsu agricultural sciences, 2015, 43(6): 383?385.
[9] 許倫輝,李鵬,周勇.基于ZigBee和GPRS的農(nóng)業(yè)區(qū)域氣象環(huán)境遠程監(jiān)測系統(tǒng)設(shè)計[J].江蘇農(nóng)業(yè)科學(xué),2015,43(6):380?383.
XU Lunhui, LI Peng, ZHOU Yong. Design of remote monitoring system for agricultural regional meteorological environment based on ZigBee and GPRS [J]. Jiangsu agricultural science, 2015, 43(6): 380?383.
[10] 王驥,郭海亮,任肖麗.基于藍牙低功耗技術(shù)的智能健康監(jiān)測手表系統(tǒng)[J].生物醫(yī)學(xué)工程學(xué)雜志,2017,34(4):557?564.
WANG Ji, GUO Hailiang, REN Xiaoli. Intelligent watch system of health monitoring based on Bluetooth low energy technology [J]. Journal of biomedical engineering, 2017, 34(4): 557?564.
[11] 張金玲,高志新.iOS平臺無線健康監(jiān)護系統(tǒng)[J].北京郵電大學(xué)學(xué)報,2016,39(6):17?21.
ZHANG Jinling, GAO Zhixin. A wireless health monitoring system based on iOS [J]. Journal of Beijing University of Posts and Telecommunications, 2016, 39(6): 17?21.
[12] 王平,秦威.基于藍牙無線傳感網(wǎng)絡(luò)的病人身體狀態(tài)實時監(jiān)護系統(tǒng)設(shè)計[J].西安科技大學(xué)學(xué)報,2015,35(1):128?131.
WANG Ping, QIN Wei. Real?time monitoring system for patients based on Bluetooth wireless sensor network [J]. Journal of Xian University of Science and Technology, 2015, 35(1): 128?131.
[13] 劉靜,楊永杰,李丹,等.可穿戴式生理數(shù)據(jù)檢測儀的研制[J].傳感器與微系統(tǒng),2016,35(7):76?79.
LIU Jing, YANG Yongjie, LI Dan, et al. Research and fabrication of wearable physiological data detector [J]. Transducer and microsystem technologies, 2016, 35(7): 76?79.
[14] 朱凌云,李連杰,孟春艷.基于WBAN的多生理參數(shù)無線傳感及前端組網(wǎng)研究[J].西南師范大學(xué)學(xué)報(自然科學(xué)版),2014,39(4):45?50.
ZHU Lingyun, LI Lianjie, MENG Chunyan. On multiple physiological parameters wireless sensing and networking based on WBAN [J]. Journal of Southwest China Normal University, 2014, 39(4): 45?50.