![]() |
小惡魔穿新衣 |
- 在 device 程式碼, 小惡魔 idle 時, 加了 server.sleepfor() 指令來省電.
- 舊版: ~18hrs (每十分鐘記錄一次溫度)
- 新版: ~48hrs (每五分鐘記錄一次溫度)
// Based on TempBug Simple Example Device Code // /* GLOBALS and CONSTANTS -----------------------------------------------------*/ const INTERVAL = 300; /* CLASS AND GLOBAL FUNCTION DEFINITIONS -------------------------------------*/ function getTemp() { // schedule the next temperature reading //imp.wakeup(INTERVAL, getTemp); // hardware id is used to separate feeds on Xively, so provide it with the data //local id = hardware.getdeviceid(); local data=temperature.read(); // Reading analog output local volt=hardware.voltage(); // Reading ADC ref. voltage local temp = data*volt/65536*100.0 // Calc. temp (16bits ADC) // tempreature can also be returned in Kelvin or Celsius local datapoint = { "id" : "ooo", "temp" : temp } server.log("Temp: " datapoint.temp); agent.send("data",datapoint); } /* REGISTER AGENT CALLBACKS --------------------------------------------------*/ /* RUNTIME BEGINS HERE -------------------------------------------------------*/ // Configure Pins temperature <- hardware.pin9; temperature.configure(ANALOG_IN); //getTemp(); imp.onidle(function() { getTemp(); server.sleepfor(INTERVAL); });[2] 加上防水保護殼, 讓小惡魔出門工作囉.
[3] 事件觸發
- 利用 Zapier 的服務, 設定當溫度到達一定條件, 就做某件事. (可參考這篇設定步驟)
- 萊恩大兵設定 Web Hook + Evernote, 每當溫度高於 34.5°C, 就在 Evernote 產生一則筆記, 記錄下當時的溫度值與時間.
Web Hook + Evernote 選擇要記錄哪些資訊 - Evernote 真的有溫度/時間的筆記吔. (Zapier 說發出了 31 篇, Evernote 也真的收到了 31 篇)
Zapier 的記錄 Evernote 的記錄
檢討
雖然改善的成果頗為豐碩, 還但是有些缺失或靈異事件, 需要進一步澄清.
(1) (靈異事件) 在上午這種時段, 照理溫度只升不降的, 竟然會測到短時間內的大幅振盪 (高低溫差接近 4°C).
8~9時, 10~11時中間, 溫測值大幅振盪. |
- 猜想這可能是風吹或陰影的影響.
(2) (靈異事件) 雨勢加大的半夜, 已經工作超過 48hrs 的溫度感測器, 溫測值從平常的兩位數突然飆高到三位數.
三位數的溫測值. |
- 萊恩大兵觀測到電池的電壓值已接近低點 (7.76V). 不確定電池電壓的穩定與否, 會不會影響 LM35 的量測結果.
電池濱臨過放. - 猜測另一個可能性, 是驟大的雨勢打在保鮮盒上, 讓 LM35 的杜邦頭腳位鬆脫了, 結果造成誤測.
萊恩大兵第一次夾杜邦頭, 手藝不精. - 這問題在電池充飽電, 接腳線路重新安置好後, 就消失了.
(3) 透過 Zapier 的服務, 雖然有自動產出 Evernote 的溫度筆記. 可是, 萊恩大兵設定條件是 >34.5°C, 每五分鐘記錄一次溫度, 以 7/1 早晨為例, 10:01時的溫度是 35.147°C, 10:41時的溫度是 34.55°C, 照理應該 10:06, 10:11,... 10:36 都應該會觸發條件才對. 結果卻沒有.. 這之間的落差, 到底是 Xively 造成的, 抑或 Zapier 是凶手? 萊恩大兵還得再調查.
![]() |
10:01, 35.147°C |
![]() |
10:41, 34.55°C |
(4) (改善建議) 可以在 LM35 裝一片散熱片, 加大接觸面積, 可提高測量的敏感度.
(5) (改善建議) LM35 測得的數值會有偏差, 應該做 Kalman Filter 的調整. (可參考這篇的說明)
(6) 社群網友的分享
- (黃偉峻) Arduino WiFi 氣象站
- (Philip Zheng)(黃偉峻) 改用 MQTT 的方法來上傳資料, 會比用 HTTP + JSON 來得快又省電.- BloomSky 智慧天氣監測相機
Okay, 暫時就這些心得了. 這題目萊恩大兵還會再往裡面鑽一點, 有興趣的朋友歡迎給意見交流交流. 謝謝.
[萊恩大兵的其它文章]
自動報球速的棒球
* 自動報球速的棒球, (1) 概念與雛形 (Arduino, MPU-6050, HC-06)
* 自動報球速的棒球, (2) 第一版試作品 (Arduino, NanoWii, microSD, MPU6050)
* 自動報球速的棒球, (3) 拋接實驗的數據分析 (Arduino, NanoWii, microSD, MPU6050)
* 做實驗, 寫入 EEPROM 的速度能否跟得上 MPU6050 的數據產出? (Arduino, MPU-6050, EEPROM)
* 筆記, NanoWii, 一些經驗分享 (Arduino, NanoWii, MPU6050)
CC2540 Bluetooth Low Energy
* 筆記, CC2540 Bluetooth Low Energy, (1) 開發環境 架設 (Bluetooth, CC2540)
* 筆記, CC2540 Bluetooth Low Energy, (2) 跑第一個範例程式 (Bluetooth, CC2540)
* 筆記, CC2540 Bluetooth Low Energy, (3) SimpleBLEPeripheral 簡單介紹 (Bluetooth, CC2540)
* 筆記, CC2540 Bluetooth Low Energy, (4) 在智慧手機上執行範例程式 (Bluetooth, CC2540)
* 筆記, CC2540 Bluetooth Low Energy, (5) 偵測與發送 iBeacon 訊號 (Bluetooth, CC2540, iBeacon)
* 實作, iBeacon 發訊器 x 防丟器 (Bluetooth, CC2540, iBeacon)
小惡魔 無線溫度感測器
* 小惡魔, (1) 溫度感測 + 物聯網 (Electric Imp, Xively, LM35, Internet of Things)
* 小惡魔, (2) 溫度感測 + 物聯網 + 事件觸發 (Electric Imp, Xively, LM35, Internet of Things)
108 大眼仔
* 108 大眼仔, 初登場 (Arduino, SG-90, Maker Faire Taipei 2014, Animatronic Eye)
* 108 大眼仔, 進化, (1) 專屬程式庫 (Arduino, SG90, Animatronic Eye)
* 108 大眼仔, 進化, (2) 當我們串在一起 (Arduino, SG90, Animatronic Eye, I2C)
* 108 大眼仔, 進化, (3) 檢查 Gmail 信箱 (Arduino, SG90, Animatronic Eye, Temboo)
* 108 大眼仔, 進化, (4) 看著我的臉 (Arduino, SG90, Animatronic Eye, OpenCV, Processing, I2C)
* 108 大眼仔, 進化, (5) 迎著人來人往 (Arduino, SG90, Animatronic Eye, OpenCV, Processing, I2C)
Plot Clock
* Murmur, 有趣的零件售價
* Murmur, Arduino 保險桿 (Arduino, bumper, 3D printing)
* Murmur, 許一個 maker 分享網站
* Murmur, 物聯網新概念- The Physical Web (Internet of Things, The Physical Web)
* 開箱, 鋼彈小劇場 (Pepper's Ghost, GUNDAM)
* 開箱, 偉力控二號機, 小四軸飛行器 (CG022, Quadcopter)
* 偉力控二號機, 修理防護罩與飛行心得 (CG022, Quadcopter)
* 偉力控二號機, 我想有個家 (CG022, Quadcopter)
* 實作, 電容感應音樂樹
自動報球速的棒球
* 自動報球速的棒球, (1) 概念與雛形 (Arduino, MPU-6050, HC-06)
* 自動報球速的棒球, (2) 第一版試作品 (Arduino, NanoWii, microSD, MPU6050)
* 自動報球速的棒球, (3) 拋接實驗的數據分析 (Arduino, NanoWii, microSD, MPU6050)
* 自動報球速的棒球, (2) 第一版試作品 (Arduino, NanoWii, microSD, MPU6050)
* 自動報球速的棒球, (3) 拋接實驗的數據分析 (Arduino, NanoWii, microSD, MPU6050)
* 做實驗, 寫入 EEPROM 的速度能否跟得上 MPU6050 的數據產出? (Arduino, MPU-6050, EEPROM)
* 筆記, NanoWii, 一些經驗分享 (Arduino, NanoWii, MPU6050)
* 筆記, NanoWii, 一些經驗分享 (Arduino, NanoWii, MPU6050)
CC2540 Bluetooth Low Energy
* 筆記, CC2540 Bluetooth Low Energy, (1) 開發環境 架設 (Bluetooth, CC2540)
* 筆記, CC2540 Bluetooth Low Energy, (2) 跑第一個範例程式 (Bluetooth, CC2540)
* 筆記, CC2540 Bluetooth Low Energy, (3) SimpleBLEPeripheral 簡單介紹 (Bluetooth, CC2540)
* 筆記, CC2540 Bluetooth Low Energy, (4) 在智慧手機上執行範例程式 (Bluetooth, CC2540)
* 筆記, CC2540 Bluetooth Low Energy, (5) 偵測與發送 iBeacon 訊號 (Bluetooth, CC2540, iBeacon)
* 實作, iBeacon 發訊器 x 防丟器 (Bluetooth, CC2540, iBeacon)
* 筆記, CC2540 Bluetooth Low Energy, (2) 跑第一個範例程式 (Bluetooth, CC2540)
* 筆記, CC2540 Bluetooth Low Energy, (3) SimpleBLEPeripheral 簡單介紹 (Bluetooth, CC2540)
* 筆記, CC2540 Bluetooth Low Energy, (4) 在智慧手機上執行範例程式 (Bluetooth, CC2540)
* 筆記, CC2540 Bluetooth Low Energy, (5) 偵測與發送 iBeacon 訊號 (Bluetooth, CC2540, iBeacon)
* 實作, iBeacon 發訊器 x 防丟器 (Bluetooth, CC2540, iBeacon)
小惡魔 無線溫度感測器
* 小惡魔, (1) 溫度感測 + 物聯網 (Electric Imp, Xively, LM35, Internet of Things)
* 小惡魔, (2) 溫度感測 + 物聯網 + 事件觸發 (Electric Imp, Xively, LM35, Internet of Things)
* 小惡魔, (2) 溫度感測 + 物聯網 + 事件觸發 (Electric Imp, Xively, LM35, Internet of Things)
108 大眼仔
Plot Clock
* 實作, 電容感應音樂樹
* 108 大眼仔, 初登場 (Arduino, SG-90, Maker Faire Taipei 2014, Animatronic Eye)
* 108 大眼仔, 進化, (1) 專屬程式庫 (Arduino, SG90, Animatronic Eye)
* 108 大眼仔, 進化, (2) 當我們串在一起 (Arduino, SG90, Animatronic Eye, I2C)
* 108 大眼仔, 進化, (3) 檢查 Gmail 信箱 (Arduino, SG90, Animatronic Eye, Temboo)
* 108 大眼仔, 進化, (4) 看著我的臉 (Arduino, SG90, Animatronic Eye, OpenCV, Processing, I2C)
* 108 大眼仔, 進化, (5) 迎著人來人往 (Arduino, SG90, Animatronic Eye, OpenCV, Processing, I2C)
* 108 大眼仔, 進化, (1) 專屬程式庫 (Arduino, SG90, Animatronic Eye)
* 108 大眼仔, 進化, (2) 當我們串在一起 (Arduino, SG90, Animatronic Eye, I2C)
* 108 大眼仔, 進化, (3) 檢查 Gmail 信箱 (Arduino, SG90, Animatronic Eye, Temboo)
* 108 大眼仔, 進化, (4) 看著我的臉 (Arduino, SG90, Animatronic Eye, OpenCV, Processing, I2C)
* 108 大眼仔, 進化, (5) 迎著人來人往 (Arduino, SG90, Animatronic Eye, OpenCV, Processing, I2C)
* Murmur, 有趣的零件售價
* Murmur, Arduino 保險桿 (Arduino, bumper, 3D printing)
* Murmur, 許一個 maker 分享網站
* Murmur, 物聯網新概念- The Physical Web (Internet of Things, The Physical Web)
* Murmur, Arduino 保險桿 (Arduino, bumper, 3D printing)
* Murmur, 許一個 maker 分享網站
* Murmur, 物聯網新概念- The Physical Web (Internet of Things, The Physical Web)
* 開箱, 鋼彈小劇場 (Pepper's Ghost, GUNDAM)
* 開箱, 偉力控二號機, 小四軸飛行器 (CG022, Quadcopter)
* 偉力控二號機, 修理防護罩與飛行心得 (CG022, Quadcopter)
* 偉力控二號機, 我想有個家 (CG022, Quadcopter)
* 開箱, 偉力控二號機, 小四軸飛行器 (CG022, Quadcopter)
* 偉力控二號機, 修理防護罩與飛行心得 (CG022, Quadcopter)
* 偉力控二號機, 我想有個家 (CG022, Quadcopter)
這個應用很好,可以作為機房溫度感測監控,超過某個溫度就告警,進一步去控制冷氣強度。
回覆刪除Sgar.. 的確可以這樣用. 只是我在兜 Xively 和 Zapier 時, 發現它們之間有掉了幾個 trigger point. 不確定是哪邊造成這問題的. 你若要用這些 solution, 得注意一下. By the way, Xively 是 LogMeIn 旗下的事業吔..
回覆刪除