Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Arduino Yun 物聯網 Lesson 2

8,720 views

Published on

Arduino Yun 物聯網 Lesson 2。
DHT11 溫溼度感測器。
使用 temboo 服務將感測器資料上傳到 Google Docs 試算表。
使用繼電器來控制電器,本日使用檯燈
使用 REST API 與網路介面來控制繼電器

Published in: Devices & Hardware
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Hey guys! Who wants to chat with me? More photos with me here 👉 http://www.bit.ly/katekoxx
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Arduino Yun 物聯網 Lesson 2

  1. 1. Arduino Yun物聯網應用 Lesson 2
  2. 2. 本日進度 • 認識DHT11數位溫溼度感測器。 • 將此資料傳送至Google Docs試算表以方 便從任何瀏覽器或是手機應用程式來遠端 存取。 • 自動寄送電子郵件
  3. 3. 範例列表 • EX_1:sensor_test – 顯示感測器值於 Serial Monitor • EX_2:temboo_log – 將資料定期發送到Google Docs 試算表。 • EX_3:temboo_alert – 同EX_2,溫度低於邊界值時,自動寄發電子郵 件
  4. 4. [雲端氣象站]
  5. 5. 所需硬體 • Arduino Yun • 光敏電阻  Arduino A0 • DHT11 數位溫溼度感測器  Arduino D8
  6. 6. DHT11 數位溫溼度感測器 • 測量溫溼度。 • #1 pin 5V • #2訊號Arduino D8 • #4 GNDArduino GND
  7. 7. 光敏電阻 • 根據光的變化而改變本身電阻值。 • 一隻腳:Arduino 5V,另一隻 A0
  8. 8. 接線示意圖 10K 4.7 K
  9. 9. 實體完成
  10. 10. EX_1 抓感測器值 / sensor_test 把DHT11感測器值顯示於 Serial Monitor
  11. 11. 匯入DHT函式庫 • #include "DHT.h“ • 在 <Arduino IDE>/libraries 資料夾中,新 增一個名為 DHT 的資料夾。 • 請把檔案解壓縮,放入 DHT 資料夾即可。
  12. 12. 檢視感測器值
  13. 13. EX_2 傳送資料到Google Doc Yun 需要連網 /temboo_log 透過Temboo服務把資料定時送到 Google Docs 試算表。
  14. 14. 建立Google Docs試算表 • 試算表名稱任意,本範例為 Yun (Line20) • 欄位: Time、Temperature、Humidity和 Light level
  15. 15. 申請Temboo帳號 https://www.temboo.com/
  16. 16. 註冊流程 • 在主頁面中,請輸入您的電子郵件地址來 註冊並點選 Sign up。 • 建立您的第一個應用程式。請記錄以下資 料:應用程式的名稱,還有系統指派給您 的金鑰;本書之後都會用到它們。
  17. 17. ACCOUNT/新增一個 Application • 建立您的第一個應用程式。請記錄以下資 料:應用程式的名稱,還有系統指派給您 的金鑰;本書之後都會用到它們。
  18. 18. ACTIVITY/流量監控畫面
  19. 19. Temboo Choreo 物件 • 用來與指定web service 互動,本範例為 Google Docs • 另外也可用於 Gmail、Twitter等
  20. 20. 在程式中加入Google account • Line 18~20 • const String GOOGLE_USERNAME = "yourGoogleUsername"; • const String GOOGLE_PASSWORD = "yourGooglePass"; • const String SPREADSHEET_TITLE = "Yun";
  21. 21. 在TembooAccount.h中修改 • #define TEMBOO_ACCOUNT "temboo_accout_name" //Temboo 帳號名稱 • #define TEMBOO_APP_KEY_NAME " temboo_app_name " //Temboo app 名稱 • #define TEMBOO_APP_KEY " temboo_api_key " //Temboo app 金鑰
  22. 22. Choreo物件上傳到Google Docs • runAppendRow(lightLevel, temperature, humidity); //Line77 • void runAppendRow() 函式//Line84 • AppendRowChoreo.addInput() – 用來加入各種參數,例如Google username、 spreadsheet title等
  23. 23. 資料格式 • String data = ""; • data = data + timeString + "," + String(temperature) + "," + String(humidity) + "," + String(lightLevel); • AppendRowChoreo.addInput("RowData ", data);
  24. 24. 讀取感測器值 • 濕度:humidity = dht.readHumidity(); • 溫度:temperature = dht.readTemperature(); • 光度:lightLevel = analogRead(A0);
  25. 25. 每10分鐘紀錄一次 • delay(600000); //Line 80 • 請修改為 20000,每20秒紀錄一次。
  26. 26. 檢查Google Docs 有沒有資料進來
  27. 27. 計算總和與製作圖表 • 請自行用 Google Docs 試算表:插入圖 表。選擇您喜歡的圖表格式。
  28. 28. EX_3 自動寄發 email /temboo_alerts 使用 Temboo 的 Gmail 函式庫 溫度低於邊界值就寄信給自己
  29. 29. 溫度邊界值 • temperature_limit = 25.0; //Line61 • 請自行修正,相同的概念可對應到任何感 測器值。
  30. 30. 寄發email • Line 84~87 1. if (temperature < temperature_limit) { 2. if (debug_mode == true) 3. {Serial.println("Sending alert");} 4. sendTempAlert("Temperature is too low!"); 5. }
  31. 31. 設定基本資料 • Line 19~22 • const String GOOGLE_USERNAME:寄件人帳號 • const String GOOGLE_PASSWORD:寄件人密碼 • const String SPREADSHEET_TITLE:試算表名稱(Yun) • const String TO_EMAIL_ADDRESS:收件人帳號
  32. 32. 檢查有沒有收到email
  33. 33. 把溫度值放在 email 裡面 • runAppendRow(lightLevel, temperature, humidity); • String a =""; • a += "The temperature is "; • a += dht.readTemperature(); • // Send email alert ? • if (temperature < temperature_limit) { • if (debug_mode == true){Serial.println("Sending alert");} • sendTempAlert(a); • }
  34. 34. 收到了

×