3
1

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 1 year has passed since last update.

enebular_uhuruAdvent Calendar 2021

Day 8

reTerminalでenebular-agentを動作させてみる

Last updated at Posted at 2021-12-08

reTerminalとは5インチのタッチスクリーン付きのRaspberry Piです。Raspberry Pi Compute Module 4を内蔵できます。Switch Science秋月電子通商で売られているものは、メモリが4GBで32GB eMMCストレージ、Wi-Fi、Bluetoothがついたモデルです。技適マークも付いています。
image.png

enebular-agentをインストール

reTerminalは、最初からRaspberryPi OS Busterがインストールされていました。タッチスクリーンが初期状態で動作するので、キーボードを用意すればWi-Fiの設定等の初期セットアップが行なえます。
enebular-agentも特に問題なくインストールができました。(enebular-agentのインストール方法は「enebular-agentをRaspberry Piにインストールする」を参照下さい)

センサー値を可視化

ディスプレイ付きということで、単純にDashboardを使って、センサーから取得できる値をゲージやグラフで表示させてみます。

センサー

センサーはオムロンのUSB型環境センサー 2JCIE-BU01を使用します。

image.png

USBに指すことで、温度、湿度、照度、気圧、騒音、3軸加速度、eTVOC(室内環境下における総揮発性有機化合物濃度)が取得できます。
以下のブログ記事にNode-REDでの使用方法が書かれています。

事前準備

センサーを使うために事前に設定が必要になります。センサーをreTerminalのUSBに刺した状態で、以下のコマンドを順に LXTerminalで実行します。

$ sudo su
$ modprobe ftdi_sio
$ echo "0590 00d4" > /sys/bus/usb-serial/drivers/ftdi_sio/new_id
$ cd /etc/udev/rules.d/
$ echo "ACTION==\"add\", ATTRS{idVendor}==\"0590\", ATTRS{idProduct}==\"00d4\", RUN+=\"/sbin/modprobe ftdi_sio\" RUN+=\"/bin/sh -c 'echo 0590 00d4 > /sys/bus/usb-serial/drivers/ftdi_sio/new_id'\"" >> 80-rename-2JCIE-BU.rules

フロー

フローは単純に1秒周期でセンサーから取得した値(温度、湿度、気圧、騒音)をDashboardのゲージノードとグラフノードで表示しているだけです。reTerminalが起動したら表示するように内蔵しているChromiumブラウザを起動し、Dashboardを表示するようにしています。これは、以前書いた記事と同様です。詳細な説明は以下を確認して下さい。

作ったフローはenebularのDiscoverで公開しています。
https://enebular.com/discover/flow/bdb14ab9-4e41-474a-8442-21f26f7a1418
image.png

[{"id":"758fcf9b.52276","type":"tab","label":"フロー 1","disabled":false,"info":""},{"id":"77f9ed8f.f08294","type":"2jcie-bu","z":"758fcf9b.52276","name":"","port":"/dev/ttyUSB0","event_target":0,"event_type":"0x0001","event_upper":0,"event_lower":0,"event_count":0,"event2_target":0,"event2_type":"0x0001","event2_upper":0,"event2_lower":0,"event2_count":0,"event3_target":0,"event3_type":"0x0001","event3_upper":0,"event3_lower":0,"event3_count":0,"led_event_rule":"0x0001","led_event_red":0,"led_event_green":0,"led_event_blue":0,"led_normal_rule":0,"led_normal_red":0,"led_normal_green":0,"led_normal_blue":0,"x":300,"y":240,"wires":[["90e5807a.96832","844dcf9d.cb7de","2220acc1.dce194","3ec998a4.68e448"],[]]},{"id":"da0f8f69.05535","type":"ui_gauge","z":"758fcf9b.52276","name":"","group":"a9d46f53.6fb3b","order":1,"width":"5","height":"5","gtype":"gage","title":"気温","label":"度","format":"{{value}}","min":"-20","max":"50","colors":["#0065b3","#00e6bf","#f4a4a4"],"seg1":"","seg2":"","x":670,"y":240,"wires":[]},{"id":"90e5807a.96832","type":"change","z":"758fcf9b.52276","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.temperature","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":240,"wires":[["da0f8f69.05535","fc97107a.9682"]]},{"id":"844dcf9d.cb7de","type":"change","z":"758fcf9b.52276","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.relativeHumidity","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":320,"wires":[["a83a0979.7c5fc8","1b42da48.e4aec6"]]},{"id":"a83a0979.7c5fc8","type":"ui_gauge","z":"758fcf9b.52276","name":"","group":"a9d46f53.6fb3b","order":2,"width":"5","height":"5","gtype":"gage","title":"湿度","label":"%","format":"{{value}}","min":"0","max":"100","colors":["#ebf6ff","#00a1e6","#0011ff"],"seg1":"","seg2":"","x":670,"y":320,"wires":[]},{"id":"ea65058c.3b45e8","type":"ui_gauge","z":"758fcf9b.52276","name":"","group":"a9d46f53.6fb3b","order":3,"width":"5","height":"5","gtype":"gage","title":"気圧","label":"hPa","format":"{{value}}","min":"700","max":"1200","colors":["#ffffff","#b0b0b0","#666666"],"seg1":"","seg2":"","x":670,"y":400,"wires":[]},{"id":"2220acc1.dce194","type":"change","z":"758fcf9b.52276","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.barometricPressure","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":400,"wires":[["ea65058c.3b45e8"]]},{"id":"4d3ad50b.b0f5fc","type":"ui_gauge","z":"758fcf9b.52276","name":"","group":"a9d46f53.6fb3b","order":4,"width":"5","height":"5","gtype":"gage","title":"騒音","label":"dB","format":"{{value}}","min":"0","max":"200","colors":["#ffffff","#ffc2c2","#ff7070"],"seg1":"","seg2":"","x":670,"y":440,"wires":[]},{"id":"3ec998a4.68e448","type":"change","z":"758fcf9b.52276","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.soundNoise","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":440,"wires":[["4d3ad50b.b0f5fc"]]},{"id":"7199de05.63bad","type":"inject","z":"758fcf9b.52276","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":240,"wires":[["77f9ed8f.f08294"]]},{"id":"142a22b7.e05d1d","type":"exec","z":"758fcf9b.52276","command":"DISPLAY=:0 chromium-browser --noerrdialogs --kiosk --incognito http://localhost:1880/ui","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":590,"y":60,"wires":[[],[],[]]},{"id":"5f1d3875.fecef8","type":"inject","z":"758fcf9b.52276","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":120,"y":60,"wires":[["142a22b7.e05d1d","4a8afe04.30f79"]]},{"id":"4a8afe04.30f79","type":"exec","z":"758fcf9b.52276","command":"DISPLAY=:0 xset -dpms;DISPLAY=:0 xset s off;DISPLAY=:0 xset s noblank","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":550,"y":120,"wires":[[],[],[]]},{"id":"fc97107a.9682","type":"ui_chart","z":"758fcf9b.52276","name":"","group":"5af2ba41.c53b94","order":1,"width":0,"height":0,"label":"気温","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"-20","ymax":"50","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7700","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"x":670,"y":280,"wires":[[]]},{"id":"1b42da48.e4aec6","type":"ui_chart","z":"758fcf9b.52276","name":"","group":"5af2ba41.c53b94","order":2,"width":0,"height":0,"label":"湿度","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"100","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7700","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"x":670,"y":360,"wires":[[]]},{"id":"a9d46f53.6fb3b","type":"ui_group","z":"","name":"メーター","tab":"1999e4bf.78d11b","order":1,"disp":false,"width":"10","collapse":false},{"id":"5af2ba41.c53b94","type":"ui_group","z":"","name":"グラフ","tab":"1999e4bf.78d11b","order":2,"disp":false,"width":"10","collapse":false},{"id":"1999e4bf.78d11b","type":"ui_tab","z":"","name":"環境センサ","icon":"dashboard","disabled":false,"hidden":false}]

動作確認

enebularからフローをデプロイして、動作確認します。デプロイしてフローが動作すれば、Dashboardが表示されました。

image.png

最後に

Node-REDのDashboardで簡単にUIを作れるので、reTerminalとの相性は良いですね。いろいろなケースのアプリケーションが想像できます。
reTerminal内臓のセンサー(3軸加速度、環境光)やボタン、ブザー、タッチ位置を扱うためのノードも見つけました。こちらも活用して他にも作って記事にしたいと思います。

※本記事は、enebular公式に動作を保証するものではありません。

3
1
1

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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?