Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
reTurminalを使った自室のモニタリングサイネージの作り方をまとめたドキュメント

reTurminalを使った自室のモニタリングサイネージ

使うもの

  • Grove SGP30(CO2ノードの近似値を取得するため)
  • Grove Temperature&Humidity Sensor(温度・湿度の取得)
  • reTurminal
  • Grove Base HAT for Raspberry Pi

配線

温湿度センサーはGrove Base HAT上のPWMポートに接続する。

SGP30はi2cポートに接続する(i2cであればどこに接続してもよい)

使うノード

  • node-red-dashboard
  • node-red-contrib-dht22
  • node-red-contrib-sgp30
  • node-red-contrib-reterminal

完成したフロー

[{"id":"3f241867f8f1af65","type":"tab","label":"room monitor","disabled":false,"info":"","env":[]},{"id":"fde7b2fc036da723","type":"ui_gauge","z":"3f241867f8f1af65","name":"","group":"e2b68ff1a015b3df","order":4,"width":5,"height":4,"gtype":"gage","title":"CO2eq","label":"ppm","format":"{{value}}","min":"400","max":"1500","colors":["#00b500","#e6e600","#ca3838"],"seg1":"600","seg2":"1000","className":"","x":700,"y":60,"wires":[]},{"id":"b2824d3c4762033a","type":"inject","z":"3f241867f8f1af65","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"5","crontab":"","once":false,"onceDelay":"","topic":"","payload":"","payloadType":"date","x":110,"y":80,"wires":[["8e25c41e5afc4b0a","4d21e2b4cb226954"]]},{"id":"8e25c41e5afc4b0a","type":"SGP30","z":"3f241867f8f1af65","name":"","address":"0x58","bus":1,"x":280,"y":80,"wires":[["7c9ea533d1083316"]]},{"id":"7c9ea533d1083316","type":"change","z":"3f241867f8f1af65","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.eco2","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":60,"wires":[["fde7b2fc036da723","442f93a3d33937d7"]]},{"id":"7a466bd35cb66755","type":"ui_gauge","z":"3f241867f8f1af65","name":"","group":"e2b68ff1a015b3df","order":1,"width":3,"height":3,"gtype":"donut","title":"Temperature","label":"C","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":550,"y":160,"wires":[]},{"id":"4d21e2b4cb226954","type":"rpi-dht22","z":"3f241867f8f1af65","name":"","topic":"rpi-dht22","dht":"11","pintype":"0","pin":"12","x":220,"y":160,"wires":[["51184a50c6c4f929","7a466bd35cb66755","aac5e5cdbbe38a3c"]]},{"id":"d1733a64a2f72930","type":"ui_gauge","z":"3f241867f8f1af65","name":"","group":"e2b68ff1a015b3df","order":2,"width":3,"height":3,"gtype":"donut","title":"Humidity","label":"%","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":640,"y":200,"wires":[]},{"id":"51184a50c6c4f929","type":"change","z":"3f241867f8f1af65","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"humidity","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":200,"wires":[["d1733a64a2f72930"]]},{"id":"fc91c5edb6cd45ac","type":"light_sensor","z":"3f241867f8f1af65","name":"","x":140,"y":460,"wires":[["91ab312083461687"]]},{"id":"91ab312083461687","type":"switch","z":"3f241867f8f1af65","name":"","property":"payload.light","propertyType":"msg","rules":[{"t":"lte","v":"1300","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":310,"y":460,"wires":[["bcf3451fdce6e8a7","1da526890b265bae"],["fc7284ac2072cfb2","09164bd603554610"]]},{"id":"02fcd2704aa268f4","type":"led_sta_red","z":"3f241867f8f1af65","name":"","x":710,"y":460,"wires":[]},{"id":"bcf3451fdce6e8a7","type":"change","z":"3f241867f8f1af65","name":"turn on","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":440,"wires":[["02fcd2704aa268f4"]]},{"id":"fc7284ac2072cfb2","type":"change","z":"3f241867f8f1af65","name":"turn off","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":480,"wires":[["02fcd2704aa268f4"]]},{"id":"7410a664568f38c1","type":"comment","z":"3f241867f8f1af65","name":"Light Sensor Alert","info":"","x":150,"y":420,"wires":[]},{"id":"ecf16552df4dfb90","type":"comment","z":"3f241867f8f1af65","name":"Sensor Monitor","info":"","x":100,"y":40,"wires":[]},{"id":"aac5e5cdbbe38a3c","type":"function","z":"3f241867f8f1af65","name":"","func":"temp = msg.payload;\nhumi = msg.humidity;\n// Calculate Disconfort Index\ndi = 0.81 * temp + 0.01 * humi * (0.99 * temp - 14.3) + 46.3;\nmsg.payload = Math.floor(di * Math.pow(10, 2) ) / Math.pow(10, 2);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":160,"y":220,"wires":[["8e0cee9c20624cb2","7437d1c296c2b8ec"]]},{"id":"7437d1c296c2b8ec","type":"ui_gauge","z":"3f241867f8f1af65","name":"","group":"e2b68ff1a015b3df","order":3,"width":3,"height":3,"gtype":"donut","title":"Disconfort Index","label":"","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"60","seg2":"80","className":"","x":360,"y":240,"wires":[]},{"id":"91491bafac89a2aa","type":"buzzer","z":"3f241867f8f1af65","name":"","x":430,"y":320,"wires":[]},{"id":"5fe64ed3e3f6d793","type":"delay","z":"3f241867f8f1af65","name":"","pauseType":"delay","timeout":"0.1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":270,"y":280,"wires":[["d8cb7975b0faa8c6","c5b69edae15df01d"]]},{"id":"8e0cee9c20624cb2","type":"switch","z":"3f241867f8f1af65","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"80","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":110,"y":280,"wires":[["5fe64ed3e3f6d793"]]},{"id":"d8cb7975b0faa8c6","type":"delay","z":"3f241867f8f1af65","name":"","pauseType":"delay","timeout":"0.1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":490,"y":280,"wires":[["927b22159867bae9"]]},{"id":"aa9f9dc8a5872d37","type":"buzzer","z":"3f241867f8f1af65","name":"","x":850,"y":280,"wires":[]},{"id":"c5b69edae15df01d","type":"change","z":"3f241867f8f1af65","name":"turn on","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":220,"y":320,"wires":[["91491bafac89a2aa"]]},{"id":"927b22159867bae9","type":"change","z":"3f241867f8f1af65","name":"turn off","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":280,"wires":[["aa9f9dc8a5872d37"]]},{"id":"442f93a3d33937d7","type":"switch","z":"3f241867f8f1af65","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"800","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":550,"y":120,"wires":[["0a95a34cf70d6936"],["202a9e45749715ec"]]},{"id":"0a95a34cf70d6936","type":"change","z":"3f241867f8f1af65","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"換気しましょう!","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":720,"y":100,"wires":[["443fd5081e9d6aea"]]},{"id":"202a9e45749715ec","type":"change","z":"3f241867f8f1af65","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":720,"y":140,"wires":[["443fd5081e9d6aea"]]},{"id":"443fd5081e9d6aea","type":"ui_text","z":"3f241867f8f1af65","group":"e2b68ff1a015b3df","order":5,"width":4,"height":2,"name":"","label":"","format":"{{msg.payload}}","layout":"row-center","className":"color:red;","x":890,"y":120,"wires":[]},{"id":"1da526890b265bae","type":"change","z":"3f241867f8f1af65","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"電気をつけましよう!","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":540,"wires":[["a9d3e20449446825"]]},{"id":"09164bd603554610","type":"change","z":"3f241867f8f1af65","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":580,"wires":[["a9d3e20449446825"]]},{"id":"a9d3e20449446825","type":"ui_text","z":"3f241867f8f1af65","group":"e2b68ff1a015b3df","order":6,"width":4,"height":2,"name":"","label":"","format":"{{msg.payload}}","layout":"row-center","className":"color:red;","x":650,"y":560,"wires":[]},{"id":"e2b68ff1a015b3df","type":"ui_group","name":"Monitor","tab":"e116c187b331787a","order":1,"disp":true,"width":"9","collapse":false,"className":""},{"id":"e116c187b331787a","type":"ui_tab","name":"Room Environ","icon":"dashboard","disabled":false,"hidden":false}]

アプリの起動

デモで見せるときには以下のコマンドでkioskモードで起動する

chromium-browser --kiosk --disable-pinch --incognito "http://localhost:1880/ui"

今後の展望

クラウドを使用してセンサーのデータを管理したりできるようにしたい

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment