#36 3軸加速度センサ
Tibbitの配置
Tibbit #36 と Tibbit #00-3を挿入します。
加速度の向き
ノードの配置
以下のようにフローを配置します。
ノードの設定を開き、スロットを選択します。
Node-REDデプロイ後、injectノードをクリックすると加速度(x,y,z)mGを取得することができます。
サンプルフロー
1 |
[{"id":"e4bb0e51.577e18","type":"inject","z":"3c31dc44.0e66fc","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":1260,"wires":[["e319c92d.c218d"]]},{"id":"d54637db.6e43f8","type":"debug","z":"3c31dc44.0e66fc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":510,"y":1340,"wires":[]},{"id":"e319c92d.c218d","type":"Tibbit-#36","z":"3c31dc44.0e66fc","name":"","tpSlot":"S01","communication":"I2C","connectedStatus":"start","host":"","x":380,"y":1300,"wires":[["d54637db.6e43f8"]]}] |
dashboardで可視化
gauge
簡易的に可視化するために、dashboardのgaugeノードを使用します。
以下のようにフローを配置します。
1秒間隔で表示を更新します。
changeノードを使用して、x,y,zをそれぞれ取得します。
以下はxのchangeノードです。yとzも同じ要領で設定します。
gaugeノードの設定を開きます。
以下はxのgaugeノードです。yとzも同じ要領で設定します。
Units(単位)やRange(範囲)を指定します。
Groupは任意で設定してください。
ダッシュボードタブの赤枠をクリックします。
Node-REDデプロイ後、injectノードをクリックするとゲージが1秒間隔で更新されます。
Tibbo-Piを傾けると、それぞれの加速度が変わります。
サンプルフロー
1 |
[{"id":"e4bb0e51.577e18","type":"inject","z":"3c31dc44.0e66fc","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":1260,"wires":[["e319c92d.c218d"]]},{"id":"e319c92d.c218d","type":"Tibbit-#36","z":"3c31dc44.0e66fc","name":"","tpSlot":"S01","communication":"I2C","connectedStatus":"start","host":"","x":320,"y":1320,"wires":[["4c09f8e1.e9dad","4aef6762.e9e288","9be9efd7.709e08","b99325e9.f620f"]]},{"id":"4c09f8e1.e9dad","type":"delay","z":"3c31dc44.0e66fc","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":320,"y":1380,"wires":[["e319c92d.c218d"]]},{"id":"4aef6762.e9e288","type":"change","z":"3c31dc44.0e66fc","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.x","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":1320,"wires":[["d74e28c3.fcca4"]]},{"id":"9be9efd7.709e08","type":"change","z":"3c31dc44.0e66fc","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.y","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":1360,"wires":[["a5bc5692.141898"]]},{"id":"b99325e9.f620f","type":"change","z":"3c31dc44.0e66fc","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.z","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":1400,"wires":[["b628ce46.d1c22"]]},{"id":"d74e28c3.fcca4","type":"ui_gauge","z":"3c31dc44.0e66fc","name":"","group":"173ca4ac.32a41b","order":0,"width":0,"height":0,"gtype":"gage","title":"X","label":"mG","format":"{{value}}mG","min":"-2000","max":"2000","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":670,"y":1320,"wires":[]},{"id":"a5bc5692.141898","type":"ui_gauge","z":"3c31dc44.0e66fc","name":"","group":"173ca4ac.32a41b","order":0,"width":0,"height":0,"gtype":"gage","title":"Y","label":"mG","format":"{{value}}mG","min":"-2000","max":"2000","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":670,"y":1360,"wires":[]},{"id":"b628ce46.d1c22","type":"ui_gauge","z":"3c31dc44.0e66fc","name":"","group":"173ca4ac.32a41b","order":0,"width":0,"height":0,"gtype":"gage","title":"Z","label":"mG","format":"{{value}}mG","min":"-2000","max":"2000","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":670,"y":1400,"wires":[]},{"id":"173ca4ac.32a41b","type":"ui_group","z":"","name":"デフォルト","tab":"da05ff1c.ed28b","disp":true,"width":"6","collapse":false},{"id":"da05ff1c.ed28b","type":"ui_tab","z":"","name":"ホーム","icon":"dashboard"}] |