第1é¨ãNode-REDã使ç¨ãã¦IoTã¢ããªãç°¡åã«ä½ã£ã¦ã¿ã
Node-REDã¨ã¯
ãNode-REDã¯ãIBMè±å½Hursleyç 究æãéçºããã½ããã¦ã§ã¢ã§ãIoTããã¤ã¹ãAPIããªã³ã©ã¤ã³ãµã¼ãã¹ãé£æºãããããã®éçºç¨ãã¼ã«ã§ãããã©ã¦ã¶UIãã¼ã¹ã§ãã¸ã¥ã¢ã«ã«ã¢ãã«ãä½æã§ããä½æããã¢ãã«ãããã«åããã¦ã¿ããã¨ãã§ãã¾ããNode-REDã¯ãªã¼ãã³ã½ã¼ã¹ã¨ãã¦æä¾ããã¦ãããGitHubããã½ã¼ã¹ãåå¾ãããã¨ãã§ãã¾ãã
ãNode-REDã¯Node.jsãåä½ããç°å¢ã§å©ç¨ã§ãã¾ããããã®é£è¼ã§ã¯ã»ããã¢ãããç°¡åãªNode-RED for Bluemixãç¨ãã¾ãã
ããªããNode-REDã¯ç¾å¨ã®ã¨ããã¢ã¤ãã¢ãæ軽ã«è©¦ãã¦ã¿ããããªã±ã¼ã¹ï¼ãããã¿ã¤ãã³ã°ï¼ãæ³å®ãã¦ããããã®ã¾ã¾æ¬çªç°å¢ã§å©ç¨ãããããªã±ã¼ã¹ã¯æ³å®ãã¦ãã¾ãããBluemixä¸ã§ããã¼ã¿ã®æ±ãã«ãªã£ã¦ãã¦ãçªç¶ä½¿ç¨ã§ããªããªãå¯è½æ§ãããã¾ãã®ã§æ³¨æãã¦ãã ããã
éçºã»ãã¹ãæé 解説ã®åæäºé
ããããã説æããæé ã¯ã以ä¸ãåæã¨ãã¦ãã¾ãã
- ä»åã®éçºã«ã¯ãMacã使ç¨ãã¦ãã¾ã
- IBM IDåå¾æ¸ã¿ãBluemixã«ãµã¤ã³ã¢ããæ¸ã¿ã®åæã¨ãã¾ã
- mbedã«ã¢ããªã±ã¼ã·ã§ã³ã»ãã¼ããè£ çæ¸ã¿ã¨ãã¾ã
- mbedã®ã¯ã©ã¤ã¢ã³ããµã¤ãã¢ããªã¯ç¬¬2åã§ã¤ã³ã¹ãã¼ã«ãããã®ã使ãã¾ã
- mbedãBluemixã«æ¥ç¶ããããã®ãããã¯ã¼ã¯ç°å¢ï¼ã«ã¼ã¿ã¼ãLANã±ã¼ãã«ï¼ãå¿ è¦ã§ã
ä»åã®ã¢ããªã±ã¼ã·ã§ã³æ¦è¦
ã第2åã§ã¯ãIBM Internet of Things Foundationã®èªè¨¼ä¸è¦ãªQuickstartãµã¼ãã¹ãç¨ãã¦ãmbedããMQTTã§éä¿¡ãããã»ã³ãµã¼ãã¼ã¿ãQuickstartã§è¡¨ç¤ºã§ãããã¨ã確èªãã¾ãããä»åã¯ã»ã³ãµã¼ãã¼ã¿ãBluemixã¸éä¿¡ããBluemixä¸ã®ãµã¼ãã¹ãã¢ããªã±ã¼ã·ã§ã³ã§å¦çãè¡ããããã«ãã¾ãã
ãã¾ãæé ã®è§£èª¬ã§ã¯Bluemixã®å¤ãæ¹ã®Webç»é¢ã使ç¨ãã¾ãããããTry the new Bluemixã®ãªã³ã¯ãã¯ãªãã¯ãã¦ãã¾ããæ°ããWebç»é¢ã«ãªã£ã¦ãã¾ã£ãæ¹ã¯ãç»é¢ä¸é¨ã«ãããã¯ã©ã·ãã¯ã»ã¨ã¯ã¹ããªã¨ã³ã¹ã«é²ãããã¯ãªãã¯ããã¨å ã®å¤ãWebç»é¢ã«æ»ããã¨ãã§ãã¾ãã
Bluemixã®Node-REDã§ã¢ããªã±ã¼ã·ã§ã³ãä½æãã
ãBluemixã«IBM IDã§ãã°ã¤ã³ãã¾ãã
ããã°ã¤ã³å¾ã®ããã·ã¥ãã¼ãã§å³ä¸ã®äººåã¢ã¤ã³ã³ãã¯ãªãã¯ãããå°åãããç±³å½åé¨ãã«è¨å®ãã¦ãã ããï¼å³1ï¼ã
ãã¹ãã¼ã¹ãæªä½æã®å ´åã¯ãä»»æã®ååã§ã¹ãã¼ã¹ãä½æãã¾ãããï¼ãã®æé ã§ã¯ãdevãã¨ãã¾ãï¼ã
ãã¢ããªã±ã¼ã·ã§ã³ãä½æãã¾ãããã«ã¿ãã°ããããInternet of Things Platform Starterï¼ã¢ãã®ã¤ã³ã¿ã¼ãããã»ã¹ã¿ã¼ã¿ã¼ã»ãã¤ã©ã¼ãã¬ã¼ãï¼ï¼å³2ï¼ããé¸æããã¨ãIoTã¢ããªã®éçºç°å¢ãä½æããã¾ãã
ãã¢ããªã±ã¼ã·ã§ã³ã«ä»»æã®ååãä»ãã¾ãããï¼æé ã§ã¯ãiotmytestappãã¨ãã¾ãï¼ã
ãã¢ããªã±ã¼ã·ã§ã³ã稼åä¸ã«ãªã£ãããçµè·¯ãã®å³æ¨ªã«è¡¨ç¤ºãããURLãã¯ãªãã¯å¯è½ã¨ãªãã¾ãã®ã§ãã¯ãªãã¯ãã¦ã¿ã¾ãããï¼å³3ï¼ã
ãNode-REDã®ã¹ã¿ã¼ãã¢ããããã©ã¦ã¶ã«è¡¨ç¤ºããã¾ãã赤è²ã®ãGo to your Node-RED flow editorããã¯ãªãã¯ãã¦ãã ããï¼å³4ï¼ã
ãããã¼ã»ã¨ãã£ã¿ã¼ã®ã¯ã¼ã¯ã¹ãã¼ã¹ã«ã¯ãããããããµã³ãã«ã®ããã¼ãä½ãããç¶æ ã¨ãªã£ã¦ãã¾ãï¼å³5ï¼ã
ã試ãã«ã¯ã¼ã¯ã¹ãã¼ã¹ã®ä¸çªå·¦ã«é ç½®ããããIBM IoT APP Inããã¼ããããã«ã¯ãªãã¯ãã¦ã¿ã¦ãã ãããããããã£ã®ç¢ºèªãå¤æ´ãå¯è½ãªæ§æãã¤ã¢ãã°ã表示ããã¾ãããIBM IoT APP Inããã¼ãã¯ãé£è¼ç¬¬2åã§ããç´¹ä»ããIBM Internet of Things Foundationã®ãQuickstartããµã¼ãã¹ãããããã¤ã¹ã®ã¤ãã³ããã¼ã¿ãããã¼ã¸å ¥åãã責åãæã¡ã¾ãã
ããã®ã»ãã®ãã¼ãã®ããããã£ã確èªãã¦ã¿ã¾ãããããµã³ãã«ããã¼ã®åãã¼ãã®è²¬åã¯è¡¨1ã®ã¨ããã§ãã
ãã¼ãå | 責å |
---|---|
IBM IoT APP In | IBM IoT Foundationããããã¤ã¹ã®ã¤ãã³ããã¼ã¿ããµãã¹ã¯ã©ã¤ããã |
device data | ããã¼ã»ã¨ãã£ã¿ã¼ã®debugã¿ãã«ãããã°ã¡ãã»ã¼ã¸ã¨ãã¦ããã¤ã¹ãã¼ã¿ãåºåãã |
temp | ã¡ãã»ã¼ã¸ãã¤ãã¼ãã®JSONãã¼ã¿ããtempï¼æ¸©åº¦ï¼å±æ§ã®ã¿ãåãåºãã¦è¿ã |
temp thresh | ã¡ãã»ã¼ã¸ãã¤ãã¼ãã40度以ä¸ãªã1çªç®ã®ããã¼ã«é²ã¿ã40度ããä¸ãªã2çªç®ã®ããã¼ã«é²ã |
safe | Temperatureï¼æ¸©åº¦ï¼ãå®å ¨ãªé¾å¤ã®ç¯å²å ã«ããã¨ããã¡ãã»ã¼ã¸ãåºåãã |
danger | Temperatureï¼æ¸©åº¦ï¼ãå±éºãªé¾å¤ã®ç¯å²å ã«ããï¼å®å ¨ãªé¾å¤ã®ç¯å²å¤ï¼ã¨ããã¡ãã»ã¼ã¸ãåºåãã |
cpu status | CPUã®æ¸©åº¦ã®ç¶æ ããããã°ã¡ãã»ã¼ã¸ã¨ãã¦åºåããï¼ãã®ãµã³ãã«ã§ã¯ãCPUã®æ¸©åº¦ãã¤ãã³ãã¨ãã¦ä¸ãã£ã¦ãã¦ããã¨æ³å®ãã¦ãã¾ãï¼ |
ãåãã¼ãã®è²¬åããã³ãã¼ã¿ããã¼ï¼ãã¼ãã®ç¹ããï¼ã確èªãããã¨ã«ããããã®ãµã³ãã«ããã¼ã¯ãããã¤ã¹ããéä¿¡ããã温度ã®ãã¼ã¿ããã¨ã«ãCPUã®ç¶æ ãå®å ¨ãå±éºããå¤å®ãã¦éç¥ããIoTãµã¼ãã¹ãå®ç¾ãããã¨ãã¦ãããã¨ãåããã¾ãã
ããã®ããã«ãNode-REDã§ã¯ããã©ã¦ã¶UIãã¼ã¹ã®ã¯ã¼ã¯ã¹ãã¼ã¹ä¸ã§ãã¾ãã¾ãªãã¼ãï¼ã«ãã»ã«åãããå°ããªæ©è½ï¼ãç¹ãããã¨ã«ãã£ã¦ã¢ããªã±ã¼ã·ã§ã³ãæ§ç¯ãã¾ããè¦ä»¶ã«ãã£ã¦ã¯ãã»ã¼ãã³ã³ã¼ãã£ã³ã°ã§ä½æãããã¨ãã§ãã¾ãããJavaScriptã§èªä½ããæ©è½ãä»è ãæä¾ããAPIããµã¼ãã¹ã¨é£ä¿ããã¦ã«ã¹ã¿ãã¤ãºã§ãã¾ãã
ãä½æãããã¼ã¿ã»ããã¼ã®ã¢ãã«ã¯ããããã¤ããã°åä½ã確èªãããã¨ãã§ããã®ã§ãNode-RED for Bluemixã¯ãIoTã¢ããªã±ã¼ã·ã§ã³ã®ãããã¿ã¤ãæ§ç¯ã«æé©ãªã½ãªã¥ã¼ã·ã§ã³ã®ä¸ã¤ã¨è¨ããã§ãããã
ã次ã«ãIoTã®ãµã³ãã«ããã¼ã«å°ãå®ç¾©ãå ãã¦ãå®éã«åä½ã確èªãã¦ã¿ã¾ãããã
ããIBM IoT App Inããã¼ãã«ãQuickstartããµã¼ãã¹ãããã¼ã¿å ¥åã§ããããã«ãã¾ããIoT Sensorã·ãã¥ã¬ã¼ã¿ã¼ããã©ã¦ã¶ã®æ°ããªã¿ãã«è¡¨ç¤ºããã¦ãã ãããã·ãã¥ã¬ã¼ã¿ã¼ã«è¡¨ç¤ºãããå³ä¸ã®è±æ°åãããã¤ã¹IDã§ãããã®å¤ãã³ãã¼ãããæ§ãã¦ããã¦ãã ããï¼å³6ï¼ã
ãNode-REDã®ããã¼ã»ã¨ãã£ã¿ã¼ã«æ»ãããIBM IoT App Inããã¼ãã®ãDevice Idãã«æ§ãã¦ãããå¤ãå ¥åãã¦ãOkããã¯ãªãã¯ãã¾ãï¼å³7ï¼ã
ãå¤æ´ãå ãã£ãã®ã§ãç»é¢å³ä¸ã«ãããDeployãã赤è²ã«ãªãã¾ããããDeployããã¯ãªãã¯ãã¦ã¿ã¾ãããï¼å³8ï¼ã
ããSuccessfully Deployedãã¨ããéç¥ã表示ãããããããã¤å®äºã§ããããã¼ã¨ãã£ã¿ã®å³ã«ãããããã°ã³ã³ã½ã¼ã«ã«ãå³9ã®ãããªã¡ãã»ã¼ã¸ãåºåããã¾ãããï¼
ã2ç§ããã«ã·ãã¥ã¬ã¼ã¿ã¼ã®ã¤ãã³ããå®è¡ãããBluemixã®ã¢ããªã±ã¼ã·ã§ã³ãã·ãã¥ã¬ã¼ã¿ã¼ã®ã»ã³ãµã¼ãã¼ã¿ãå ¥åå¦çãã¾ãããtemp threshããã¼ãã§ã¯æ¸©åº¦ã®é¾å¤å¤å®ãè¡ããããã®å¤å®çµæããããã°ã¡ãã»ã¼ã¸ã¨ãã¦åºåããã¾ãã
ããããã°ã³ã³ã½ã¼ã«ã«ã¯ãã·ãã¥ã¬ã¼ã¿ã¼ããã®å ¥åãã¼ã¿ããããã°ç¨éã§åºåããã¦ãããã¨ãåããã¾ãã
ãã·ãã¥ã¬ã¼ã¿ã¼ã®ä¸é¨ã«è¡¨ç¤ºãããç¢å°ãã¯ãªãã¯ããã¨æ¸©åº¦ãä¸ä¸ã§ããã®ã§ã40度以ä¸ã®æ¸©åº¦ãã¾ã41度以ä¸ã®æ¸©åº¦ã«å¤æ´ãã¦ã¿ã¾ãããããããã°ã³ã³ã½ã¼ã«ã«è¡¨ç¤ºãããå¤å®çµæã®å 容ãå¤ããã¾ãããï¼
ããµã³ãã«ããã¼ã®åä½ç¢ºèªãçµãã£ããããIBM IoT App Inããã¼ãã®ãDevice Idãã®å¤ãåé¤ãã¦åã³ãããã¤ãã¾ããããããã§ã·ãã¥ã¬ã¼ã¿ã¼ã®ã¤ãã³ããã¼ã¿ã®ãµãã¹ã¯ã©ã¤ããæ¢ãããã¨ãã§ãã¾ãããããã°ã³ã³ã½ã¼ã«ã«ãDevice Id is not set for Quickstart flowãã¨ããã¡ãã»ã¼ã¸ãåºåãããå¾ã¯ãä½ãåºåãããªããã¨ã確èªãã¦ãã ããã