簡易檢索 / 詳目顯示

研究生: 彭少麒
Shao-Chi Peng
論文名稱: 一個應用於智慧農場的環境監控系統 -行動裝置應用程式設計
An Environmental Monitoring and Control System for Smart Farm Applications -Design of Mobile Application
指導教授: 吳傳嘉
Chwan-Chia Wu
黎碧煌
Bih-Hwang Lee
口試委員: 黎碧煌
Bih-Hwang Lee
張俊明
Chun-Ming Chang
吳傳嘉
Chwan-Chia Wu
學位類別: 碩士
Master
系所名稱: 電資學院 - 電機工程系
Department of Electrical Engineering
論文出版年: 2021
畢業學年度: 109
語文別: 中文
論文頁數: 138
中文關鍵詞: 物聯網智慧農場智慧農業HTTP傳輸協定iOS應用程式
外文關鍵詞: iOS 14.4, Swift 5, Xcode 12.4, UIGestureRecognizer
相關次數: 點閱:208下載:2
分享至:
查詢本校圖書館目錄 查詢臺灣博碩士論文知識加值系統 勘誤回報
  • 氣候變遷日益嚴重,未來將面臨全球糧食短缺,就臺灣而言,從農人口逐漸
    高齡化,因缺乏年輕人補進而大幅縮減。隨著物聯網蓬勃發展,現今農業發展朝
    「自動化」、「智慧化」邁進。
    本論文使用 Swift 5 實現在 iOS 14.4 系統裝置上,開發一套 App 應用於智慧
    農場的物聯網系統。主要頁面為「登入」、「註冊」、「農場管理系統」、「溫
    室管理系統」、「手動診斷」,功能包含「動態規劃溫室」、「動態規劃感測器」、
    「查看感測器歷史紀錄」、「警報設定」、「自動偵測」。目的為幫助使用者遠
    端管理農場,透過動態規劃溫室模擬實際農場溫室佈局,於溫室內動態規劃感測
    器,藉由 BLE Mesh 結合 HTTP 發展出長距離低功耗傳輸技術,將感測器搜集到
    的資料數據上傳至 MySQL 資料庫,實現 iOS App 與電腦網頁「同步」,讓使用
    者居家即輕鬆完成「雲端巡田」,透過遠端監控即時掌握農場運作情形。
    本論文突破傳統農業限制,節省大量務農時間與人力。「警報設定」能針對
    農作物本身條件設置上下限,若數值超標可對溫室內部設備實施遠端遙控,即時
    處理危機,降低農作物損失。當感測器連線異常、數值超標…等問題發生將啟動
    「自動偵測」,iOS App 介面上感測器與溫室圖示會即時變色,提醒使用者排除
    警戒,本論文亦提供表格化「手動診斷」,讓使用者一目瞭然該溫室所有感測器
    名稱、連線狀況、更新時間,並以視覺化圖表呈現「感測器歷史紀錄」,讓使用
    者具備大數據進一步分析,優化農作物品質。


    Climate change is getting worse, which will make food shortages foreseeable in
    the future. Most Taiwanese farmers are gaffers, and the agricultural population will
    shrink significantly. Along with the vigorous development of the IoT, agriculture is
    developing towards automation and intelligence.
    In This thesis, we develop an App on iOS 14.4 with Swift 5 for the smart farm
    based on IoT architecture. The main pages are “Login,” “Registration,” “Farm
    Management System,” “Greenhouse Management System,” and “Manual Diagnostics.”
    The App functions include “Dynamic Planning Greenhouse,” “Dynamic Planning
    Sensor,” “Checking Sensor History Records,” “Warning Setting, and Auto Detection.”
    The primary purpose is to help users manage farms remotely, simulate the real world’s
    greenhouses layout through dynamic programming, and develop low- power and long
    distance transmission technology through BLE Mesh network combined with HTTP
    protocol to upload collected data to the MySQL database. This iOS App is synchronous
    with the computer website so that users can efficiently operate it. Through remote
    monitoring, it can immediately deal with the farm’s emergency, and reduce employee
    costs.
    This iOS App can also throw agricultural convention to the winds. Users can set
    the maximum and minimum condition value for crops through “Warning Setting”, if
    the detection value is not in the standard range, carry out “Remote Switching” can deal
    with the crisis immediately and efficiently and reduce crop damage. When the sensor
    connection is abnormal, or the sensor detection value is out of the standard range, “Auto
    Detection” warns users by changing the sensor and greenhouse icons’ color instantly to
    modify it. The system also provides “Manual Diagnostics.” it uses UITableView to
    present the sensor’s names, connection status, and update time.“Sensor History
    Records” uses a visual chart to show the sensor’s detection values and times so that
    users can further analyze and optimize the quality of crops.

    摘要.............................................................................................................................. I ABSTRACT.............................................................................................................II 誌謝............................................................................................................................III 目錄............................................................................................................................IV 圖索引 ..................................................................................................................... VII 表索引 ..................................................................................................................... XII 第一章 緒論..............................................................................................................1 1.1 研究背景.....................................................................................................1 1.1.1 IoT.........................................................................................................1 1.1.2 智慧農業..............................................................................................4 1.2 研究動機.....................................................................................................5 1.3 研究目的.....................................................................................................6 1.4 章節架構.....................................................................................................7 第二章 相關技術與文獻介紹.............................................................................8 2.1 WPAN..........................................................................................................8 2.2 WLAN..........................................................................................................8 2.3 網路拓樸.....................................................................................................9 2.3.1 拓樸種類..............................................................................................9 2.4 Wi-Fi..........................................................................................................10 2.4.1 IEEE 802.11........................................................................................11 2.5 ZigBee........................................................................................................13 2.6 Bluetooth....................................................................................................14 2.6.1 BLE.....................................................................................................18 2.6.2 BLE Mesh Network ............................................................................27 2.7 TCP/IP .......................................................................................................31 2.8 HTTP..........................................................................................................32 2.8.1 API......................................................................................................34 2.8.2 URL & Parameter ...............................................................................35 2.8.3 HTTP 訊息格式.................................................................................36 2.8.4 HTTP Method .....................................................................................39 2.8.5 GET 與 POST.....................................................................................40 2.9 JSON..........................................................................................................42 2.10 iOS ...........................................................................................................43 2.11 Swift.........................................................................................................44 2.11.1 Xcode ................................................................................................45 2.11.2 CocoaPods.........................................................................................46 第三章 系統架構設計.........................................................................................49 3.1 全端系統架構...........................................................................................49 3.1.1 iOS App 直接對接 MySQL 資料庫 ..................................................50 3.2 iOS 應用功能部署 ....................................................................................51 3.3 Sign Up Page 註冊系統.............................................................................53 3.3.1 Codable ...............................................................................................54 3.3.2 URLSession ........................................................................................54 3.3.3 Closure ................................................................................................56 3.3.4 GCD....................................................................................................57 3.4 Home Page 登入首頁................................................................................58 3.4.1 UIViewController 生命週期 .............................................................59 3.4.2 iOS 鎖定頁面方向 ............................................................................60 3.4.3 UserDefaults .......................................................................................61 3.5 Sign In Page 農場管理系統......................................................................62 3.5.1 CGRect................................................................................................63 3.5.2 UIGestureRecognizer..........................................................................64 3.5.3 UINavigationController......................................................................67 3.5.4 Timer...................................................................................................68 3.5.5 Sync.....................................................................................................69 3.5.6 解決 Sync 衍生的弊端......................................................................69 3.5.7 新增溫室............................................................................................70 3.5.8 拖曳溫室............................................................................................71 3.5.9 縮放溫室............................................................................................72 3.5.10 變形溫室..........................................................................................73 3.5.11 命名溫室..........................................................................................73 3.5.12 刪除溫室..........................................................................................74 3.5.13 進入溫室..........................................................................................75 3.5.14 提醒未定義 Peripheral 數量...........................................................75 3.6 Green House Page 溫室管理系統.............................................................76 3.6.1 Floaty ..................................................................................................78 3.6.2 UIButton 自動佈局 ............................................................................78 3.6.3 啟動偵測............................................................................................79 3.6.4 新增感測器........................................................................................80 3.6.5 拖曳感測器........................................................................................81 3.6.6 命名感測器........................................................................................82 3.6.7 刪除感測器........................................................................................83 3.6.8 查看感測器座標軸............................................................................84 3.7 警報設定...................................................................................................85 3.7.1 設置感測器上下限............................................................................85 3.7.2 遠端遙控第三方設備........................................................................86 3.8 Sensor History Page 感測器歷史紀錄......................................................86 3.8.1 UIPickerView .....................................................................................87 3.8.2 Charts..................................................................................................88 3.9 Manual Diagnosis Page 手動診斷.............................................................89 3.9.1 UITableView.......................................................................................89 第四章 系統實作與成果 ....................................................................................91 4.1 Sign Up Page 註冊系統.............................................................................91 4.2 Home Page 登入首頁................................................................................93 4.3 Sign In Page 農場管理系統......................................................................96 4.3.1 新增溫室............................................................................................96 4.3.2 拖曳溫室............................................................................................97 4.3.3 縮放溫室............................................................................................99 4.3.4 變形溫室..........................................................................................100 4.3.5 命名溫室..........................................................................................101 4.3.6 刪除溫室..........................................................................................102 4.3.7 進入溫室..........................................................................................103 4.3.8 提醒未定義 Peripheral 數量...........................................................104 4.4 Green House Page 溫室管理系統...........................................................104 4.4.1 啟動偵測..........................................................................................104 4.4.2 新增感測器......................................................................................106 4.4.3 刪除感測器......................................................................................108 4.4.4 命名感測器......................................................................................109 4.4.5 拖曳感測器......................................................................................110 4.4.6 查看感測器座標軸..........................................................................111 4.4.7 遠端遙控..........................................................................................112 4.5 Sensor History Page 感測器歷史紀錄....................................................113 4.6 Manual Diagnosis Page 手動診斷...........................................................115 4.7 Auto Diagnosis 自動診斷........................................................................116 4.7.1 連線異常..........................................................................................116 4.7.2 偵測值超標......................................................................................117 4.7.3 正常狀態..........................................................................................118 第五章 結論與未來展望 ..................................................................................119 5.1 結論.........................................................................................................119 5.2 未來展望.................................................................................................119 參考文獻.................................................................................................................120

    [1] ResearchGate:
    https://www.researchgate.net/figure/ETSI-M2M-Reference-Architectural-Model
    The-ETSI-reference-model-has-three-domains-Device_fig4_311519188
    [2] WINIX Technologies,6 Main Challenges Facing IoT:
    https://medium.com/@winix/6-main-challenges-facing-iot-b6055bdf6782
    [3] IoT ANALYTICS,Internet of Things-Technology Architecture:
    https://iot-analytics.com/our-coverage/industrial-iot/
    [4] IoT in Agriculture and Farming:
    https://www.eetindia.co.in/iot-in-agriculture-and-farming/
    [5] IOT-BASED SMART FARMING:
    https://www.facebook.com/redtonemalaysia/photos/quick-facts-on-world
    populations-growth-food-agriculture-resources-can-our-agric/1779049768859655/
    [6] The Future of Food and Farming:
    https://agriregionieuropa.univpm.it/sites/are.econ.univpm.it/files/the_future_of_foo
    d_and_farming.pdf
    [7] 廖建興,無線個⼈區域網路(WPAN)技術發展與應⽤概論,37 中華民國電
    ⼦零件認證委員會:
    http://www.cteccb.org.tw/pdf/IECQ-50-7.pdf
    [8] Internet of Things Wireless Networks:
    https://www.ccontrols.net/cz-sk/applications/internet-of-things-iot/wireless-networks/
    [9] 前進 6GHzWi-Fi 技術持續提升速度/頻寬性能,電子工程專欄:
    https://www.eettaiwan.com/20210323nt31-the-continued-evolution-of-wi-fi/
    [10] James F. Kurose, Keith W. Ross 著 全華翻譯小組 譯(2020),電腦網際網路,
    7/e (國際版)(Computer Networking: A Top-Down Approach, 7/e),全華圖書股份
    有限公司
    [11] OURBLOG EDUCATION,IEEE 802.11 Standards For WLAN:
    https://blog.oureducation.in/ieee-802-11-standards-for-wlan/
    [12] Wireless Communication and Networking CMPT371:
    https://coursys.sfu.ca/2017su-cmpt-371-d1/pages/Wireless_pdf/view
    [13] Kai Ren and Martin Woolley,The Fundamental Concepts of Bluetooth Mesh
    Networking, Part2:
    https://www.bluetooth.com/blog/the-fundamental-concepts-of-bluetooth-mesh
    networking-part-2/
    [14] 認識藍⽛之技術、測試與未來應⽤:
    https://ithelp.ithome.com.tw/articles/10237243
    [15] Embedded Centric EMBEDDED SYSTEMS TRAINING SPECIALISTS,Lesson1-
    Introduction to Bluetooth Low Energy/Bluetooth5:
    https://embeddedcentric.com/introduction-to-bluetooth-low-energy-bluetooth-5/
    [16] MICROCHIP Developer Help,Bluetooth Low Energy(BLE):
    https://microchipdeveloper.com/wireless:ble-gap-roles
    [17] Embedded Centric,Lesson2-BLE profiles, services, characteristics, device roles and
    network topology:
    https://embeddedcentric.com/lesson-2-ble-profiles-services-characteristics-device
    roles-and-network-topology/
    [18] 林志隆,BLE 藍⽛協定簡介:
    https://drive.google.com/file/d/1cuVZq3RjUqkKwoGymqCGcNhSp87f1zEW/view
    [19] Bluetooth SMART:
    https://learn.adafruit.com/introduction-to-bluetooth-low-energy/gatt?view=all
    [20] 透過連線/廣播⽅式實作 BLE 網狀網路建構⾮夢事:
    https://www.2cm.com.tw/2cm/zh-tw/tech/7480E3786F984FCBA7CC9DFDFAE3D196
    [21] TEXAS INSTRUMENTS,Bluetooth Low Energy Tree Structure Network:
    https://www.ti.com/lit/an/swra648/swra648.pdf?ts=1628839279825&ref_url=https
    %253A%252F%252Fwww.ti.com%252Ftool%252FLAUNCHXL-CC26X2R1
    [22] JavaScript,What is JSON and How to Use It:
    https://javascript.plainenglish.io/what-is-json-519751ee0435
    [23] 前端開發 30 個問題:
    https://ithelp.ithome.com.tw/articles/10246127
    [24] 資訊網路⼯程,TCP/IP 網際網路協議:
    https://hackmd.io/@mohjj/S1wejbRH4#資訊網路⼯程
    [25] SIMILAR POSTS,How HTTP request and response works:
    https://bytesofgigabytes.com/networking/how-http-request-and-response-works/
    [26] 何謂 HTTP 傳輸協定:
    https://medium.com/pierceshih/%E7%AD%86%E8%A8%98-
    %E4%BD%95%E8%AC%82-http-
    %E5%82%B3%E8%BC%B8%E5%8D%94%E5%AE%9A-1d9b5be3fd24
    [27] ⿈⼠嘉、張⼒元 著(2019),輕鬆學會 iPhone App 實作開發 精⼼設計 17 個
    Lab 讓你輕鬆上⼿,博碩⽂化股份有限公司
    [28] 游鴻斌 著(2021),iOS 14 程式設計開發與應⽤ 使⽤ Xcode 12& iOS 14&
    Swift 5 開發,博碩⽂化股份有限公司
    [29] MDN Web Docs,What is a URL:
    https://developer.mozilla.org/en-US/docs/Learn/Common_questions/What_is_a_URL
    [30] 2.2 The World Wide Web:HTTP:
    http://www2.ic.uff.br/~michael/kr1999/2-application/2_02-http.htm
    [31] Guru99.com,GET vs POST:Key Difference between HTTP Methods:
    https://www.guru99.com/difference-get-post-http.html
    [32] 魏巍 著(2017),Swift 3 ⾃學⼒!圖解 146 個 iOS App 開發範例,⼊⾨必備
    超直覺設計指南,電腦⼈⽂化出版/城邦⽂化發⾏
    [33] Nix Software Engineering,Swift VS Objective-C:Which is Better for Your Next
    Mobile App?:
    https://nix-united.com/blog/swift-vs-objective-c-which-is-better-for-your-next
    mobile-app/
    [34] 彼得潘 著(2017),彼得潘的 Swift 程式設計⼊⾨,松崗資產管理股份有限公司
    [35] NOT CODING WILL DIE,<⼗分鐘學程式>COCOAPODS 安裝教學:
    https://notcodingwilldie.blogspot.com/2018/10/cocoapods.html
    [36] 朱克剛 著(2020),iOS 13 程式設計實戰—Swift 5.1/Swift UI 框架|快速上
    ⼿的開發技巧 200+,碁峰資訊股份有限公司
    [37] Shin Chao,『Swift 5 學習系列』-11.閉包(Closures):
    https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84
    -swift-ios-app-
    %E9%96%8B%E7%99%BC%E6%95%99%E5%AE%A4/%E7%B0%A1%E6%
    98%93%E8%AA%AA%E6%98%8Eswift-4-closures-77351c3bf775
    [38] kciter/Floaty:Floating Action Button for iOS–GitHub:
    https://github.com/kciter/Floaty
    [39] Swift UIButton 功能解析⼤部分解開始!! –2021 年:
    https://badgameshow.com/steven/swift/swift-uibutton-%E6%95%99%E5%AD%B8/
    [40] stackoverflow,Label under image in UIButton:
    https://stackoverflow.com/questions/4201959/label-under-image-in-uibutton
    [41] Putting a UICollectionView in a UITableViewCell in Swift:
    https://ashfurrow.com/blog/putting-a-uicollectionview-in-a-uitableviewcell-in-swift/
    [42] Swift Package Registry,Charts4.0.1:
    https://swiftpackageregistry.com/danielgindi/Charts
    [43] 網路的拓樸(Topology):
    http://epaper.gotop.com.tw/PDFSample/ACN025700.pdf
    [44] 無線通訊技術原理介紹–Zigbee 技術概觀:
    http://rportal.lib.ntnu.edu.tw/bitstream/20.500.12235/98995/3/n069370037203.pdf
    [45] Advance Turorials,8. Internet of Things:
    https://mpython.readthedocs.io/en/master/tutorials/advance/iot/
    [46] 黃英豪,一個應用於智慧農場的物聯網系統-行動裝置應用程式設計,國立
    臺灣科技大學電機工程系碩士學位論文,民 109
    [47] 農試所技服組 吳惠卿,當前農業人力資源面結構之探討:
    https://scholars.tari.gov.tw/bitstream/123456789/11963/1/30-2-8.pdf
    [48] MacRumors,iOS and Android Activations Now Split Evenly in the U.S.,
    Research Shows:
    https://www.macrumors.com/2021/07/19/ios-and-android-activations-now-split
    evenly-in-the-u-s-research-shows/
    [49] Statcounter GlobalStats,Mobile Operating System Market Share Taiwan June
    2020 – June 2021:
    https://gs.statcounter.com/os-market-share/mobile/taiwan
    [50] GeeksforGeeks,Difference between Bluetooth and Zigbee:
    https://www.geeksforgeeks.org/difference-between-bluetooth-and-zigbee/
    [51] everythingRF,What is the difference between Bluetooth 5, Bluetooth 4.2 and
    Bluetooth 2.0?:
    https://www.everythingrf.com/community/what-is-the-difference-between
    bluetooth-5-0-bluetooth-low-energy-bluetooth-v4-2-and-classic-bluetooth
    [52] CYPRESS,Getting Started with Bluetooth Mesh – AN227069:
    https://www.cypress.com/html_doc/AppNotes/AN227069/index.html#getting
    started-with-bluetooth-mesh-an227069
    [53] Ayushi Rawat’s Blog,What is an API? API-101:
    https://ayushirawat.com/what-is-an-api-api-101
    [54] HTTP Status Code Poster:
    https://www.steveschoger.com/status-code-poster/
    [55] GCD:
    https://medium.com/@crafttang/gcd%E5%92%8Coperation-operationqueue-
    %E7%9C%8B%E8%BF%99%E4%B8%80%E7%AF%87%E6%96%87%E7%A
    B%A0%E5%B0%B1%E5%A4%9F%E4%BA%86-f38d50521543
    [56] Rakiba Rayhana, Gaozhi Xiao, Zheng Liu,”Internet of Things Empowered Smart
    Greenhouse Farming” , IEEE Journal of Radio Frequency Identification ,
    Sept.2020

    QR CODE