Node-RED
(此教學皆以在Raspberry Pi平臺上執行)
官方簡介
Node-RED is a programming tool for wiringtogether hardware devices, APIs and online services in new and interestingways.
It provides a browser-based editor that makesit easy to wire together flows using the wide range of nodes in the palettethat can be deployed to its runtime in a single-click.
開始安裝
建議一開始可以先系統更新。
開啟Terminal終端機輸入以下指令:
>> sudo apt-get update (更新) >> sudo apt-get upgrade (升級) |
輸入指令安裝Node-RED:
>> bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered) |
等待全部跑完後
檢查安裝:
會跑出Node-RED的版本號。
啟動 NodeRED:
開啟瀏覽器測試:
http://IP:1880
到這裡為止就算完成安裝了。
接下來寫個測試範例,輸入一句話並輸出。
在左方欄位中拖曳出兩個節點,並連接起來。
- input > inject
- output > debug
雙擊inject修改Payload為自己想打的話。
接下來把它部屬上去,點擊右上角紅色按鈕Deploy,
會顯示部屬成功訊息。
點擊inject左方小框框(紅箭頭),它就會發送訊息,並在右方debug訊息框看到接收到的資料。
* debug節點的右方小框框(藍箭頭)要記得打開。
※ 開機時自動啟動
如果希望在Raspberry Pi開機後自動運行Node-RED,輸入以下指令:
>> sudo systemctl enable nodered.service |
如需要更多的介紹,請參考官方資料