2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Watson IoT Platform - Node-RED - TIセンサータグを使う

Last updated at Posted at 2016-05-20

初めてWatson IoT Platformを使ってみよう、というかたのためのガイドです。
Watson IoT Platformを使ってみるでIoTアプリを準備しました。

#TI(テキサス・インスツルメンツ社)製のセンサータグCC2650を使います

  1. スマートフォンのAppStore(iPhone)/GooglePlay(Android)で「TI SensorTag」を検索してインストールします。
image1.PNG
  1. TIアプリを起動したら、TIセンサータグCC2650の側面の正方形のスイッチを押します。反対側に長方形のスイッチがあるのでややこしいです。
  2. スマートフォンのアプリでセンタータグが認識されます。
image2.PNG
  1. 「Sensor View」を選択するとセンタータグとスマホの間でペアリングが行われ、センサーデータの送受信が始まります。
image3.PNG
  1. 画面に表示されている赤いセンタータグのアイコンをクリックすると、センタータグの詳細情報が表示され、英数字12桁のセンサータグのデバイスIDが表示されるので書きとめておきます。
  2. 「Cloud View」の画面で右側のスイッチをスライドすると、雲との間で送信を表す赤い両方向矢印が点滅しはじめ、クラウドへのセンサーデータ送信が始まります。
image4.PNG
  1. Node-REDのIoTアプリを開きます。
  2. IoTフローの左端の青い「IBM IoT App In」ノードをダブルクリックで開き、前項で書きとめた英数字12桁のデバイスIDを指定し、「OK」で保存します。
  3. 画面右上の赤い「Deploy」ボタンを押してクラウド上のアプリへ反映します。
  4. 画面右側のDebugタブへセンサーからデータが表示されるのを確認します。
    スクリーンショット 2016-05-20 15.01.32.png

#各センサー値の取得
各センサーの値を個別に取得するフローを以下にご紹介します。
Watson IoT Platform - Node-RED - フローをコピーする方法を参照して以下のフローをコピペします。

  • CC2650を使用している場合:
CC2650の各センサー値の取得
[{"id":"62c105ff.e299bc","type":"ibmiot in","z":"cd2fe299.783688","authentication":"quickstart","apiKey":"","inputType":"evt","deviceId":"","applicationId":"","deviceType":"+","eventType":"+","commandType":"","format":"json","name":"IBM IoT","service":"quickstart","allDevices":"","allApplications":"","allDeviceTypes":true,"allEvents":true,"allCommands":"","allFormats":"","x":90,"y":100,"wires":[["ff5782d8.fa553","8611b5b5.a4cb2","9ff0c10.66691c","3986183e.0aea7","54458336.5a6c0c","7b64f410.ac6b4c","e6de42a9.0908c","8c72b119.b6e92","efa89579.5bf078","b890d4f6.5070b8","b72b27af.93de08","fb66d420.3939a8","5bf6ccc5.bb3164","72f2afb3.3106f8"]]},{"id":"63fcd023.a218b8","type":"debug","z":"cd2fe299.783688","name":"","active":false,"console":"false","complete":"false","x":550,"y":100,"wires":[]},{"id":"ff5782d8.fa553","type":"function","z":"cd2fe299.783688","name":"ambientTempの取り出し","func":"return {payload:msg.payload.d.ambientTemp};","outputs":1,"noerr":0,"x":310,"y":100,"wires":[["63fcd023.a218b8"]]},{"id":"8611b5b5.a4cb2","type":"debug","z":"cd2fe299.783688","name":"","active":true,"console":"false","complete":"false","x":270,"y":60,"wires":[]},{"id":"9ff0c10.66691c","type":"function","z":"cd2fe299.783688","name":"humidityの取り出し","func":"return {payload:msg.payload.d.humidity};","outputs":1,"noerr":0,"x":290,"y":180,"wires":[["6ce832e8.02191c"]]},{"id":"6ce832e8.02191c","type":"debug","z":"cd2fe299.783688","name":"","active":false,"console":"false","complete":"false","x":550,"y":180,"wires":[]},{"id":"3986183e.0aea7","type":"function","z":"cd2fe299.783688","name":"objectTempの取り出し","func":"return {payload:msg.payload.d.objectTemp};","outputs":1,"noerr":0,"x":300,"y":140,"wires":[["385b70bf.f96fb"]]},{"id":"385b70bf.f96fb","type":"debug","z":"cd2fe299.783688","name":"","active":false,"console":"false","complete":"false","x":550,"y":140,"wires":[]},{"id":"54458336.5a6c0c","type":"function","z":"cd2fe299.783688","name":"magXの取り出し","func":"return {payload:msg.payload.d.magX};","outputs":1,"noerr":0,"x":290,"y":460,"wires":[["7786fd2f.62cac4"]]},{"id":"7786fd2f.62cac4","type":"debug","z":"cd2fe299.783688","name":"","active":false,"console":"false","complete":"false","x":550,"y":460,"wires":[]},{"id":"7b64f410.ac6b4c","type":"function","z":"cd2fe299.783688","name":"magYの取り出し","func":"return {payload:msg.payload.d.magY};","outputs":1,"noerr":0,"x":290,"y":500,"wires":[["5c39d403.bf06fc"]]},{"id":"5c39d403.bf06fc","type":"debug","z":"cd2fe299.783688","name":"","active":false,"console":"false","complete":"false","x":550,"y":500,"wires":[]},{"id":"e6de42a9.0908c","type":"function","z":"cd2fe299.783688","name":"magZの取り出し","func":"return {payload:msg.payload.d.magZ};","outputs":1,"noerr":0,"x":290,"y":540,"wires":[["8d213ed2.439ab8"]]},{"id":"8c72b119.b6e92","type":"function","z":"cd2fe299.783688","name":"gyroXの取り出し","func":"return {payload:msg.payload.d.gyroX};","outputs":1,"noerr":0,"x":290,"y":340,"wires":[["17ab6845.130b1"]]},{"id":"efa89579.5bf078","type":"function","z":"cd2fe299.783688","name":"gyroYの取り出し","func":"return {payload:msg.payload.d.gyroY};","outputs":1,"noerr":0,"x":290,"y":380,"wires":[["9af8e41d.b25008"]]},{"id":"b890d4f6.5070b8","type":"function","z":"cd2fe299.783688","name":"gyroZの取り出し","func":"return {payload:msg.payload.d.gyroZ};","outputs":1,"noerr":0,"x":290,"y":420,"wires":[["9d71753e.4da7b8"]]},{"id":"8d213ed2.439ab8","type":"debug","z":"cd2fe299.783688","name":"","active":false,"console":"false","complete":"false","x":550,"y":540,"wires":[]},{"id":"395a3f82.af6698","type":"debug","z":"cd2fe299.783688","name":"","active":true,"console":"false","complete":"false","x":550,"y":580,"wires":[]},{"id":"17ab6845.130b1","type":"debug","z":"cd2fe299.783688","name":"","active":false,"console":"false","complete":"false","x":550,"y":340,"wires":[]},{"id":"9af8e41d.b25008","type":"debug","z":"cd2fe299.783688","name":"","active":false,"console":"false","complete":"false","x":550,"y":380,"wires":[]},{"id":"9d71753e.4da7b8","type":"debug","z":"cd2fe299.783688","name":"","active":false,"console":"false","complete":"false","x":550,"y":420,"wires":[]},{"id":"b72b27af.93de08","type":"function","z":"cd2fe299.783688","name":"accelXの取り出し","func":"return {payload:msg.payload.d.accelX};","outputs":1,"noerr":0,"x":290,"y":220,"wires":[["91290eed.00e108"]]},{"id":"fb66d420.3939a8","type":"function","z":"cd2fe299.783688","name":"accelYの取り出し","func":"return {payload:msg.payload.d.accelY};","outputs":1,"noerr":0,"x":290,"y":260,"wires":[["d397e2b0.b7f968"]]},{"id":"5bf6ccc5.bb3164","type":"function","z":"cd2fe299.783688","name":"accelZの取り出し","func":"return {payload:msg.payload.d.accelZ};","outputs":1,"noerr":0,"x":290,"y":300,"wires":[["eb95e5dc.73e998"]]},{"id":"91290eed.00e108","type":"debug","z":"cd2fe299.783688","name":"","active":true,"console":"false","complete":"false","x":550,"y":220,"wires":[]},{"id":"d397e2b0.b7f968","type":"debug","z":"cd2fe299.783688","name":"","active":false,"console":"false","complete":"false","x":550,"y":260,"wires":[]},{"id":"eb95e5dc.73e998","type":"debug","z":"cd2fe299.783688","name":"","active":false,"console":"false","complete":"false","x":550,"y":300,"wires":[]},{"id":"72f2afb3.3106f8","type":"function","z":"cd2fe299.783688","name":"lightの取り出し","func":"return {payload:msg.payload.d.light};","outputs":1,"noerr":0,"x":280,"y":580,"wires":[["395a3f82.af6698"]]}]

スクリーンショット 2016-06-10 8.20.41.png

  • CC2541を使用している場合:
CC2541の各センサー値の取得
[{"id":"efecb9fb.a923","type":"ibmiot in","z":"d6f399d.2f1f6e8","authentication":"quickstart","apiKey":"","inputType":"evt","deviceId":"","applicationId":"","deviceType":"+","eventType":"+","commandType":"","format":"json","name":"IBM IoT","service":"quickstart","allDevices":"","allApplications":"","allDeviceTypes":true,"allEvents":true,"allCommands":"","allFormats":"","x":160,"y":160,"wires":[["a1d0a95d.5e375","c56c81c7.93d69","776b5a1f.da39bc","736747ee.fe43e","be4864c4.c836e8","59a5a99a.c4445","1e339c98.6881c3","a1e0caf5.4efb4","b56268ed.93602","ae22c60d.3de468","61a6cbb4.4cafdc","a78f029a.e3b51"]]},{"id":"cce17e24.1ffaf8","type":"debug","z":"d6f399d.2f1f6e8","name":"","active":false,"console":"false","complete":"false","x":610,"y":160,"wires":[]},{"id":"a1d0a95d.5e375","type":"function","z":"d6f399d.2f1f6e8","name":"ambientTempの取り出し","func":"return {payload:msg.payload.d.ambientTemp};","outputs":1,"noerr":0,"x":390,"y":160,"wires":[["cce17e24.1ffaf8"]]},{"id":"c56c81c7.93d69","type":"debug","z":"d6f399d.2f1f6e8","name":"","active":true,"console":"false","complete":"false","x":350,"y":120,"wires":[]},{"id":"776b5a1f.da39bc","type":"function","z":"d6f399d.2f1f6e8","name":"humidityの取り出し","func":"return {payload:msg.payload.d.humidity};","outputs":1,"noerr":0,"x":370,"y":240,"wires":[["dcf2ca89.6ea9b"]]},{"id":"dcf2ca89.6ea9b","type":"debug","z":"d6f399d.2f1f6e8","name":"","active":false,"console":"false","complete":"false","x":610,"y":240,"wires":[]},{"id":"736747ee.fe43e","type":"function","z":"d6f399d.2f1f6e8","name":"objectTempの取り出し","func":"return {payload:msg.payload.d.objectTemp};","outputs":1,"noerr":0,"x":380,"y":200,"wires":[["5a4361c6.14155"]]},{"id":"5a4361c6.14155","type":"debug","z":"d6f399d.2f1f6e8","name":"","active":false,"console":"false","complete":"false","x":610,"y":200,"wires":[]},{"id":"be4864c4.c836e8","type":"function","z":"d6f399d.2f1f6e8","name":"magXの取り出し","func":"return {payload:msg.payload.d.magX};","outputs":1,"noerr":0,"x":370,"y":280,"wires":[["7e09cfd7.05aa18"]]},{"id":"7e09cfd7.05aa18","type":"debug","z":"d6f399d.2f1f6e8","name":"","active":false,"console":"false","complete":"false","x":610,"y":280,"wires":[]},{"id":"59a5a99a.c4445","type":"function","z":"d6f399d.2f1f6e8","name":"magYの取り出し","func":"return {payload:msg.payload.d.magY};","outputs":1,"noerr":0,"x":370,"y":320,"wires":[["a4cadab1.893428"]]},{"id":"a4cadab1.893428","type":"debug","z":"d6f399d.2f1f6e8","name":"","active":false,"console":"false","complete":"false","x":610,"y":320,"wires":[]},{"id":"1e339c98.6881c3","type":"function","z":"d6f399d.2f1f6e8","name":"magZの取り出し","func":"return {payload:msg.payload.d.magZ};","outputs":1,"noerr":0,"x":370,"y":360,"wires":[["1b222dc4.7ce3ba"]]},{"id":"a1e0caf5.4efb4","type":"function","z":"d6f399d.2f1f6e8","name":"pressureの取り出し","func":"return {payload:msg.payload.d.pressure};","outputs":1,"noerr":0,"x":380,"y":400,"wires":[["ad561f34.8719c8"]]},{"id":"b56268ed.93602","type":"function","z":"d6f399d.2f1f6e8","name":"altitudeの取り出し","func":"return {payload:msg.payload.d.altitude};","outputs":1,"noerr":0,"x":370,"y":440,"wires":[["710ced68.3f34dc"]]},{"id":"ae22c60d.3de468","type":"function","z":"d6f399d.2f1f6e8","name":"gyroXの取り出し","func":"return {payload:msg.payload.d.gyroX};","outputs":1,"noerr":0,"x":370,"y":480,"wires":[["e98c1ebb.a2971"]]},{"id":"61a6cbb4.4cafdc","type":"function","z":"d6f399d.2f1f6e8","name":"gyroYの取り出し","func":"return {payload:msg.payload.d.gyroY};","outputs":1,"noerr":0,"x":370,"y":520,"wires":[["cc1dee06.0de39"]]},{"id":"a78f029a.e3b51","type":"function","z":"d6f399d.2f1f6e8","name":"gyroZの取り出し","func":"return {payload:msg.payload.d.gyroZ};","outputs":1,"noerr":0,"x":370,"y":560,"wires":[["fff06bf6.3b5e28"]]},{"id":"1b222dc4.7ce3ba","type":"debug","z":"d6f399d.2f1f6e8","name":"","active":false,"console":"false","complete":"false","x":610,"y":360,"wires":[]},{"id":"ad561f34.8719c8","type":"debug","z":"d6f399d.2f1f6e8","name":"","active":false,"console":"false","complete":"false","x":610,"y":400,"wires":[]},{"id":"710ced68.3f34dc","type":"debug","z":"d6f399d.2f1f6e8","name":"","active":false,"console":"false","complete":"false","x":610,"y":440,"wires":[]},{"id":"e98c1ebb.a2971","type":"debug","z":"d6f399d.2f1f6e8","name":"","active":true,"console":"false","complete":"false","x":610,"y":480,"wires":[]},{"id":"cc1dee06.0de39","type":"debug","z":"d6f399d.2f1f6e8","name":"","active":false,"console":"false","complete":"false","x":610,"y":520,"wires":[]},{"id":"fff06bf6.3b5e28","type":"debug","z":"d6f399d.2f1f6e8","name":"","active":false,"console":"false","complete":"false","x":610,"y":560,"wires":[]}]

スクリーンショット 2016-06-10 8.11.57.png

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?