27
Copyright © 2014 Advanced IT Consortium to Evaluate, Apply and Drive All Rights Reserved. AITCオープンラボ 第4回 IoT勉強会(再演) Pepper x IoT x Web センサーデータの表示編 AITC CC研サブリーダー ピースミール・テクノロジー株式会社 高岡大介 1

03 pepper io_t_web

Embed Size (px)

Citation preview

Page 1: 03 pepper io_t_web

Copyright © 2014 Advanced IT Consortium to Evaluate, Apply and Drive All Rights Reserved.

AITCオープンラボ 第4回 IoT勉強会(再演)

Pepper x IoT x Web

センサーデータの表示編

AITC CC研サブリーダー ピースミール・テクノロジー株式会社

高岡大介1

Page 2: 03 pepper io_t_web

Copyright © 2014 Advanced IT Consortium to Evaluate, Apply and Drive All Rights Reserved.

About me

高岡大介

最近やってること • Web関連の開発・技術顧問 • IoT勉強会シリーズ • 特集記事/対談

2

dsuket

※本資料は個人の見解であり、AITCの公式資料ではありません。

Page 3: 03 pepper io_t_web

Copyright © 2014 Advanced IT Consortium to Evaluate, Apply and Drive All Rights Reserved.

全体像

3

温度データ

PublishSubscribe

WebSocketREST

Tablet Web Browser

Page 4: 03 pepper io_t_web

Copyright © 2014 Advanced IT Consortium to Evaluate, Apply and Drive All Rights Reserved.

センサーデータの表示

4http://dsuket.github.io/pepper-iot/index.html

Page 5: 03 pepper io_t_web

Copyright © 2014 Advanced IT Consortium to Evaluate, Apply and Drive All Rights Reserved.

やったこと

1. BaaSからWebSocketでデータを取得 2. 値をHTMLに表示 3. グラフに表示 4. Pepperに連携

5

Page 6: 03 pepper io_t_web

Copyright © 2014 Advanced IT Consortium to Evaluate, Apply and Drive All Rights Reserved.

1. BaaSからWebSocketでデータを取得

6

Page 7: 03 pepper io_t_web

Copyright © 2014 Advanced IT Consortium to Evaluate, Apply and Drive All Rights Reserved.

今、IoT BaaSが熱い!

7

Page 8: 03 pepper io_t_web

Copyright © 2014 Advanced IT Consortium to Evaluate, Apply and Drive All Rights Reserved.

けど、、、

• Yahoo IoT: 未だ出ず • Kii: WebSocket使えない • Milkcocoa: Tesselで使えない • Parse: Arduino, ラズパイのみ • Firebase: Arduino, ラズパイのみ • Pusher: 前述の問題

8

Page 9: 03 pepper io_t_web

Copyright © 2014 Advanced IT Consortium to Evaluate, Apply and Drive All Rights Reserved.

最強のIoT BaaS!!

970+ SDKs!

Page 10: 03 pepper io_t_web

Copyright © 2014 Advanced IT Consortium to Evaluate, Apply and Drive All Rights Reserved.

準備

10

var pubnub = PUBNUB.init({ publish_key: "pub-c-046ffxxx", subscribe_key: "sub-c-f5f1xxxx" });

<script src="https://cdn.pubnub.com/pubnub-dev.js"></script>

html

JavaScripts

Page 11: 03 pepper io_t_web

Copyright © 2014 Advanced IT Consortium to Evaluate, Apply and Drive All Rights Reserved.

PubNub 受信

pubnub.subscribe({ channel: "Sandbox", message: onReceiveMessage });

function onReceiveMessage(data) { console.log('data = ', data); }

11

Page 12: 03 pepper io_t_web

Copyright © 2014 Advanced IT Consortium to Evaluate, Apply and Drive All Rights Reserved.

PubNub 送信

var data = { value: 12, timestamp: Date.now() }; pubnub.publish({ channel: "Sandbox", message: data });

12

Page 13: 03 pepper io_t_web

Copyright © 2014 Advanced IT Consortium to Evaluate, Apply and Drive All Rights Reserved.

その他の機能

• Presence • Storage & Playback • Stream Controller • Mobile Push Gateway • Analytics • Access Management

13

Page 14: 03 pepper io_t_web

Copyright © 2014 Advanced IT Consortium to Evaluate, Apply and Drive All Rights Reserved.

2. 値をHTMLに表示

14

Page 15: 03 pepper io_t_web

Copyright © 2014 Advanced IT Consortium to Evaluate, Apply and Drive All Rights Reserved.

JSとhtmlのバンディング

15

ここの部分が動的にかわる

Page 16: 03 pepper io_t_web

Copyright © 2014 Advanced IT Consortium to Evaluate, Apply and Drive All Rights Reserved.

JSライブラリ

バインディングライブラリは沢山ある

• Backbone.js • Knockout.js • Angular.js • React.js

16

Page 17: 03 pepper io_t_web

Copyright © 2014 Advanced IT Consortium to Evaluate, Apply and Drive All Rights Reserved. 17

Page 18: 03 pepper io_t_web

Copyright © 2014 Advanced IT Consortium to Evaluate, Apply and Drive All Rights Reserved.

バインディングに特化したシンプルなJavaScriptライブラリ

• MVVMによる双方向データバインディング • ディレティブとフィルタ • 単純なAPI • モジュール性とコンポーザビリティを重視

今回は複雑なことは不要なので、これで十分!

18

Vue.js

Page 19: 03 pepper io_t_web

Copyright © 2014 Advanced IT Consortium to Evaluate, Apply and Drive All Rights Reserved.

Vue.js Sample

19

Page 20: 03 pepper io_t_web

Copyright © 2014 Advanced IT Consortium to Evaluate, Apply and Drive All Rights Reserved.

3. グラフに表示

20

Page 21: 03 pepper io_t_web

Copyright © 2014 Advanced IT Consortium to Evaluate, Apply and Drive All Rights Reserved.

JSグラフライブラリ

• Canvas • Chart.js (フラットでシンプルなグラフ) • CanvasJS (jQuery pluginもあり)

• SVG • Google Charts (言わずとしれたGChart。ちょっとダサイ) • Highcharts (超高機能。高い) • amcharts (AmazonやMSで使われたとか) • D3.js (ビジュアライゼーションライブラリ) • NVD3 (D3の派生形)

• ハイブリッド • vis.js (タイムラインやネットワーク図がかける)

21

Page 22: 03 pepper io_t_web

Copyright © 2014 Advanced IT Consortium to Evaluate, Apply and Drive All Rights Reserved. 22

Page 23: 03 pepper io_t_web

Copyright © 2014 Advanced IT Consortium to Evaluate, Apply and Drive All Rights Reserved.

C3.js

グラフ描画ライブラリー • D3.jsをグラフ描画に特化して扱いやすく • 便利なAPI、カスタマイズ可能 • 元がD3なので何でも出来る • (サイトは英語だけど日本人が開発)

Why C3? • Comfortable & Customizable & Controllable

23

Page 24: 03 pepper io_t_web

Copyright © 2014 Advanced IT Consortium to Evaluate, Apply and Drive All Rights Reserved.

C3.js Example

24http://c3js.org/samples/timeseries.html

Page 25: 03 pepper io_t_web

Copyright © 2014 Advanced IT Consortium to Evaluate, Apply and Drive All Rights Reserved.

4. Pepperに連携

25

Page 26: 03 pepper io_t_web

Copyright © 2014 Advanced IT Consortium to Evaluate, Apply and Drive All Rights Reserved.

QiMessaging

26

詳しくは次で!

Page 27: 03 pepper io_t_web

Copyright © 2014 Advanced IT Consortium to Evaluate, Apply and Drive All Rights Reserved.

まとめ

ありもの組み合わせれば簡単! Pepperタブレットでも割と動く!

https://html5test.com/s/c9f22d2508c24d52.html

今回のサンプル https://github.com/dsuket/pepper-iot

27