#42 バックアップ付きリアルタイムクロック
Tibbitの配置
Tibbit #42を挿入します。
ノードの配置
時刻を設定
functionノードを使用します。
functionノードの編集を開き、コードに以下を記述します。
年月日時の箇所は、設定したい時刻を指定します。
1 2 |
msg.payload = {ctrl: 2, v: '2018/12/31 23:59:30'}; return msg; |
ノードの設定を開き、スロットを選択します。
実行すると日付をTibbitにセットすることができます。
サンプルフロー
1 |
[{"id":"2d772a3c.8f637e","type":"inject","z":"3efecf70.7f7ef8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":140,"wires":[["19a601c2.e81ec6"]]},{"id":"19a601c2.e81ec6","type":"function","z":"3efecf70.7f7ef8","name":"","func":"msg.payload = {ctrl: 2, v: '2018/12/31 23:59:30'};\nreturn msg;","outputs":1,"noerr":0,"x":210,"y":200,"wires":[["8f568357.ec79d8"]]},{"id":"8f568357.ec79d8","type":"Tibbit-#42","z":"3efecf70.7f7ef8","name":"","tpSlot":"S01","communication":"SPI","spiSpeed":"500","spiMode":"3","spiEndian":"1","connectedStatus":"start","host":"","x":360,"y":260,"wires":[[]]}] |
時刻を取得
functionノードを使用します。
functionノードの編集を開き、コードに以下を記述します。
1 2 |
msg.payload = {ctrl: 1}; return msg; |
ノードの設定を開き、スロットを選択します。
実行すると時刻を取得することができます。
サンプルフロー
1 |
[{"id":"2d772a3c.8f637e","type":"inject","z":"3efecf70.7f7ef8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":140,"wires":[["19a601c2.e81ec6"]]},{"id":"19a601c2.e81ec6","type":"function","z":"3efecf70.7f7ef8","name":"","func":"msg.payload = {ctrl: 1};\nreturn msg;","outputs":1,"noerr":0,"x":210,"y":200,"wires":[["8f568357.ec79d8"]]},{"id":"8f568357.ec79d8","type":"Tibbit-#42","z":"3efecf70.7f7ef8","name":"","tpSlot":"S01","communication":"SPI","spiSpeed":"500","spiMode":"3","spiEndian":"1","connectedStatus":"start","host":"","x":360,"y":260,"wires":[["d0acc79d.a76058"]]},{"id":"d0acc79d.a76058","type":"debug","z":"3efecf70.7f7ef8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":500,"y":320,"wires":[]}] |