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

More Related Content

Viewers also liked

Arduino、Web 到 IoT
Arduino、Web 到 IoTArduino、Web 到 IoT
Arduino、Web 到 IoTJustin Lin
 
Manufacturing engineer performance appraisal
Manufacturing engineer performance appraisalManufacturing engineer performance appraisal
Manufacturing engineer performance appraisalabbiewilliams012
 
IBM以雲端技術與物聯網創新產業應用@2016 New Taipei Maker Faire
IBM以雲端技術與物聯網創新產業應用@2016 New Taipei Maker FaireIBM以雲端技術與物聯網創新產業應用@2016 New Taipei Maker Faire
IBM以雲端技術與物聯網創新產業應用@2016 New Taipei Maker FaireCAVEDU Education
 
App inventor 教學講義 chapter3
App inventor 教學講義 chapter3App inventor 教學講義 chapter3
App inventor 教學講義 chapter3Jerry Wu
 
App inventor 教學講義 chapter2
App inventor 教學講義 chapter2App inventor 教學講義 chapter2
App inventor 教學講義 chapter2Jerry Wu
 
Arduino 習作工坊 - Lesson 4 通訊之夜
Arduino 習作工坊 -  Lesson 4 通訊之夜Arduino 習作工坊 -  Lesson 4 通訊之夜
Arduino 習作工坊 - Lesson 4 通訊之夜CAVEDU Education
 
App inventor 教學講義 chapter6
App inventor 教學講義 chapter6App inventor 教學講義 chapter6
App inventor 教學講義 chapter6Jerry Wu
 
App inventor2利用WebViewer與ActivityStarter連到外部網站
App inventor2利用WebViewer與ActivityStarter連到外部網站App inventor2利用WebViewer與ActivityStarter連到外部網站
App inventor2利用WebViewer與ActivityStarter連到外部網站Jerry Wu
 
App inventor 教學講義 chapter1
App inventor 教學講義 chapter1App inventor 教學講義 chapter1
App inventor 教學講義 chapter1Jerry Wu
 
App inventor 教學講義 chapter4
App inventor 教學講義 chapter4App inventor 教學講義 chapter4
App inventor 教學講義 chapter4Jerry Wu
 
LinkIt ONE tutorial #2- Communication and cloud service
LinkIt ONE tutorial #2- Communication and cloud serviceLinkIt ONE tutorial #2- Communication and cloud service
LinkIt ONE tutorial #2- Communication and cloud serviceCAVEDU Education
 
LinkIt ONE tutorial #1- Basics
LinkIt ONE tutorial #1- BasicsLinkIt ONE tutorial #1- Basics
LinkIt ONE tutorial #1- BasicsCAVEDU Education
 
Arduino 底層原始碼解析心得
Arduino 底層原始碼解析心得Arduino 底層原始碼解析心得
Arduino 底層原始碼解析心得roboard
 

Viewers also liked (18)

更新Arduino Yún OS
更新Arduino Yún OS更新Arduino Yún OS
更新Arduino Yún OS
 
Arduino Yún使用Temboo服務
Arduino Yún使用Temboo服務Arduino Yún使用Temboo服務
Arduino Yún使用Temboo服務
 
161123
161123161123
161123
 
Arduino Yún使用Http client
Arduino Yún使用Http clientArduino Yún使用Http client
Arduino Yún使用Http client
 
Arduino、Web 到 IoT
Arduino、Web 到 IoTArduino、Web 到 IoT
Arduino、Web 到 IoT
 
Manufacturing engineer performance appraisal
Manufacturing engineer performance appraisalManufacturing engineer performance appraisal
Manufacturing engineer performance appraisal
 
IBM以雲端技術與物聯網創新產業應用@2016 New Taipei Maker Faire
IBM以雲端技術與物聯網創新產業應用@2016 New Taipei Maker FaireIBM以雲端技術與物聯網創新產業應用@2016 New Taipei Maker Faire
IBM以雲端技術與物聯網創新產業應用@2016 New Taipei Maker Faire
 
App inventor 教學講義 chapter3
App inventor 教學講義 chapter3App inventor 教學講義 chapter3
App inventor 教學講義 chapter3
 
App inventor 教學講義 chapter2
App inventor 教學講義 chapter2App inventor 教學講義 chapter2
App inventor 教學講義 chapter2
 
Arduino 習作工坊 - Lesson 4 通訊之夜
Arduino 習作工坊 -  Lesson 4 通訊之夜Arduino 習作工坊 -  Lesson 4 通訊之夜
Arduino 習作工坊 - Lesson 4 通訊之夜
 
App inventor 教學講義 chapter6
App inventor 教學講義 chapter6App inventor 教學講義 chapter6
App inventor 教學講義 chapter6
 
App inventor2利用WebViewer與ActivityStarter連到外部網站
App inventor2利用WebViewer與ActivityStarter連到外部網站App inventor2利用WebViewer與ActivityStarter連到外部網站
App inventor2利用WebViewer與ActivityStarter連到外部網站
 
App inventor 教學講義 chapter1
App inventor 教學講義 chapter1App inventor 教學講義 chapter1
App inventor 教學講義 chapter1
 
App inventor 教學講義 chapter4
App inventor 教學講義 chapter4App inventor 教學講義 chapter4
App inventor 教學講義 chapter4
 
LinkIt ONE tutorial #2- Communication and cloud service
LinkIt ONE tutorial #2- Communication and cloud serviceLinkIt ONE tutorial #2- Communication and cloud service
LinkIt ONE tutorial #2- Communication and cloud service
 
LinkIt ONE tutorial #1- Basics
LinkIt ONE tutorial #1- BasicsLinkIt ONE tutorial #1- Basics
LinkIt ONE tutorial #1- Basics
 
Arduino 底層原始碼解析心得
Arduino 底層原始碼解析心得Arduino 底層原始碼解析心得
Arduino 底層原始碼解析心得
 
Mbot教學(1b) mBot初體驗
Mbot教學(1b) mBot初體驗Mbot教學(1b) mBot初體驗
Mbot教學(1b) mBot初體驗
 

More from CAVEDU Education

Google TPU Edge SBC_190424
Google TPU Edge SBC_190424Google TPU Edge SBC_190424
Google TPU Edge SBC_190424CAVEDU Education
 
From computational Thinking to computational Action - Dr. Hal Abelson, MIT Ap...
From computational Thinking to computational Action - Dr. Hal Abelson, MIT Ap...From computational Thinking to computational Action - Dr. Hal Abelson, MIT Ap...
From computational Thinking to computational Action - Dr. Hal Abelson, MIT Ap...CAVEDU Education
 
BBC Micro:bit beginner project
BBC Micro:bit beginner projectBBC Micro:bit beginner project
BBC Micro:bit beginner projectCAVEDU Education
 
LINE Messaging API with LinkIt 7697
LINE Messaging API with LinkIt 7697 LINE Messaging API with LinkIt 7697
LINE Messaging API with LinkIt 7697 CAVEDU Education
 
Latte panda workshop_japan
Latte panda workshop_japanLatte panda workshop_japan
Latte panda workshop_japanCAVEDU Education
 
拿鐵熊貓外殼設計0707
拿鐵熊貓外殼設計0707拿鐵熊貓外殼設計0707
拿鐵熊貓外殼設計0707CAVEDU Education
 
LinkIt 7697 outer case - DesignSpark Mechanical / Onkscape
LinkIt 7697 outer case - DesignSpark Mechanical / OnkscapeLinkIt 7697 outer case - DesignSpark Mechanical / Onkscape
LinkIt 7697 outer case - DesignSpark Mechanical / OnkscapeCAVEDU Education
 
170615 國中小自造者教育師資培訓營
170615  國中小自造者教育師資培訓營170615  國中小自造者教育師資培訓營
170615 國中小自造者教育師資培訓營CAVEDU Education
 
170522_Raspberry Pi 相容開發板
170522_Raspberry Pi 相容開發板170522_Raspberry Pi 相容開發板
170522_Raspberry Pi 相容開發板CAVEDU Education
 
Maker Movement and Education in Taiwan
Maker Movement and Education in TaiwanMaker Movement and Education in Taiwan
Maker Movement and Education in TaiwanCAVEDU Education
 
AAEON 當創客碰上UP板 - Intel Cherry Trail 高效能maker開發者平台@2016 new taipei maker faire
AAEON 當創客碰上UP板 - Intel Cherry Trail 高效能maker開發者平台@2016 new taipei maker faireAAEON 當創客碰上UP板 - Intel Cherry Trail 高效能maker開發者平台@2016 new taipei maker faire
AAEON 當創客碰上UP板 - Intel Cherry Trail 高效能maker開發者平台@2016 new taipei maker faireCAVEDU Education
 
物聯網好棒棒 您專屬的IoT私有雲平台
物聯網好棒棒 您專屬的IoT私有雲平台物聯網好棒棒 您專屬的IoT私有雲平台
物聯網好棒棒 您專屬的IoT私有雲平台CAVEDU Education
 
絕地武士心靈控制家用雲端智慧型物聯網光劍搭載無線路由器光劍底座Final
絕地武士心靈控制家用雲端智慧型物聯網光劍搭載無線路由器光劍底座Final絕地武士心靈控制家用雲端智慧型物聯網光劍搭載無線路由器光劍底座Final
絕地武士心靈控制家用雲端智慧型物聯網光劍搭載無線路由器光劍底座FinalCAVEDU Education
 
160901 翻轉開發,活用雲端創新技術@IBM Cloud Innovation Day
160901  翻轉開發,活用雲端創新技術@IBM Cloud Innovation Day160901  翻轉開發,活用雲端創新技術@IBM Cloud Innovation Day
160901 翻轉開發,活用雲端創新技術@IBM Cloud Innovation DayCAVEDU Education
 
160603 T客邦7688物聯網實作坊
160603  T客邦7688物聯網實作坊160603  T客邦7688物聯網實作坊
160603 T客邦7688物聯網實作坊CAVEDU Education
 
2016 CAVEDU物聯網應用發表會 - 開場
2016 CAVEDU物聯網應用發表會 - 開場2016 CAVEDU物聯網應用發表會 - 開場
2016 CAVEDU物聯網應用發表會 - 開場CAVEDU Education
 
Amazon AWS IoT 利用 AWS IoT 開發智慧家居解決方案
Amazon AWS IoT 利用 AWS IoT 開發智慧家居解決方案Amazon AWS IoT 利用 AWS IoT 開發智慧家居解決方案
Amazon AWS IoT 利用 AWS IoT 開發智慧家居解決方案CAVEDU Education
 

More from CAVEDU Education (20)

Google TPU Edge SBC_190424
Google TPU Edge SBC_190424Google TPU Edge SBC_190424
Google TPU Edge SBC_190424
 
From computational Thinking to computational Action - Dr. Hal Abelson, MIT Ap...
From computational Thinking to computational Action - Dr. Hal Abelson, MIT Ap...From computational Thinking to computational Action - Dr. Hal Abelson, MIT Ap...
From computational Thinking to computational Action - Dr. Hal Abelson, MIT Ap...
 
180321 MIT見聞分享
180321   MIT見聞分享180321   MIT見聞分享
180321 MIT見聞分享
 
BBC Micro:bit beginner project
BBC Micro:bit beginner projectBBC Micro:bit beginner project
BBC Micro:bit beginner project
 
LINE Messaging API with LinkIt 7697
LINE Messaging API with LinkIt 7697 LINE Messaging API with LinkIt 7697
LINE Messaging API with LinkIt 7697
 
Latte panda workshop_japan
Latte panda workshop_japanLatte panda workshop_japan
Latte panda workshop_japan
 
拿鐵熊貓外殼設計0707
拿鐵熊貓外殼設計0707拿鐵熊貓外殼設計0707
拿鐵熊貓外殼設計0707
 
LinkIt 7697 outer case - DesignSpark Mechanical / Onkscape
LinkIt 7697 outer case - DesignSpark Mechanical / OnkscapeLinkIt 7697 outer case - DesignSpark Mechanical / Onkscape
LinkIt 7697 outer case - DesignSpark Mechanical / Onkscape
 
170615 國中小自造者教育師資培訓營
170615  國中小自造者教育師資培訓營170615  國中小自造者教育師資培訓營
170615 國中小自造者教育師資培訓營
 
170522_Raspberry Pi 相容開發板
170522_Raspberry Pi 相容開發板170522_Raspberry Pi 相容開發板
170522_Raspberry Pi 相容開發板
 
LinkIt 7697 IoT tutorial
LinkIt 7697 IoT tutorialLinkIt 7697 IoT tutorial
LinkIt 7697 IoT tutorial
 
Maker Movement and Education in Taiwan
Maker Movement and Education in TaiwanMaker Movement and Education in Taiwan
Maker Movement and Education in Taiwan
 
AAEON 當創客碰上UP板 - Intel Cherry Trail 高效能maker開發者平台@2016 new taipei maker faire
AAEON 當創客碰上UP板 - Intel Cherry Trail 高效能maker開發者平台@2016 new taipei maker faireAAEON 當創客碰上UP板 - Intel Cherry Trail 高效能maker開發者平台@2016 new taipei maker faire
AAEON 當創客碰上UP板 - Intel Cherry Trail 高效能maker開發者平台@2016 new taipei maker faire
 
物聯網好棒棒 您專屬的IoT私有雲平台
物聯網好棒棒 您專屬的IoT私有雲平台物聯網好棒棒 您專屬的IoT私有雲平台
物聯網好棒棒 您專屬的IoT私有雲平台
 
絕地武士心靈控制家用雲端智慧型物聯網光劍搭載無線路由器光劍底座Final
絕地武士心靈控制家用雲端智慧型物聯網光劍搭載無線路由器光劍底座Final絕地武士心靈控制家用雲端智慧型物聯網光劍搭載無線路由器光劍底座Final
絕地武士心靈控制家用雲端智慧型物聯網光劍搭載無線路由器光劍底座Final
 
160901 翻轉開發,活用雲端創新技術@IBM Cloud Innovation Day
160901  翻轉開發,活用雲端創新技術@IBM Cloud Innovation Day160901  翻轉開發,活用雲端創新技術@IBM Cloud Innovation Day
160901 翻轉開發,活用雲端創新技術@IBM Cloud Innovation Day
 
160625 arduino101
160625 arduino101160625 arduino101
160625 arduino101
 
160603 T客邦7688物聯網實作坊
160603  T客邦7688物聯網實作坊160603  T客邦7688物聯網實作坊
160603 T客邦7688物聯網實作坊
 
2016 CAVEDU物聯網應用發表會 - 開場
2016 CAVEDU物聯網應用發表會 - 開場2016 CAVEDU物聯網應用發表會 - 開場
2016 CAVEDU物聯網應用發表會 - 開場
 
Amazon AWS IoT 利用 AWS IoT 開發智慧家居解決方案
Amazon AWS IoT 利用 AWS IoT 開發智慧家居解決方案Amazon AWS IoT 利用 AWS IoT 開發智慧家居解決方案
Amazon AWS IoT 利用 AWS IoT 開發智慧家居解決方案
 

Arduino Yun 物聯網 Lesson 2