*Arduino UNOをNode-Redで制御(LED ON/OFF) [#m4460b99]

Windows10からArduino UNOのLED(L 13Pin)をオン オフするまで

**ソフトの設定手順 [#x2524c57]

***ArduinoIDEをインストール [#uc478847]

DL先https://www.arduino.cc/en/Main/DonateからIDEを以下の手順で取得してインストールする

&ref("./Arduino_inst1.png");

&ref("./Arduino_inst2.png");


***Node.jsのインストール [#nc07f0be]

node-v9(node-v9.11.2-x64.msi)をインストール(Node.jsをインストール)
~[v10はnode-red-contrib-gpioを追加時にエラーするため使用しない]


***Python2.xをインストール [#m88af8a8]

以下のコマンドでwindows-build-toolsをインストールとPython2.xもインストールされる~windows-build-toolsも必要なようだ。またPython3.xはNode-Redで動作未確認

''管理者のPoweshell内で''

 PS C:\WINDOWS\system32> npm install --global --production windows-build-tools
 (略)
 ---------- Visual Studio Build Tools ----------
 Successfully installed Visual Studio Build Tools.
 ------------------- Python --------------------
 Successfully installed Python 2.7
 
 Now configuring the Visual Studio Build Tools and Python...
 
 All done!

''インストールされた内容''

&ref("./Win-tools-inst1.png");

***Node-Redのインストール [#v6cb4614]

npmでnode-redをインストール

''管理者のPoweshell内で''

 PS C:\WINDOWS\system32> npm install -g --unsafe-perm node-red
 C:\Users\user\AppData\Roaming\npm\node-red -> C:\Users\user\AppData\Roaming\npm\node_modules\node-red\red.js
 C:\Users\user\AppData\Roaming\npm\node-red-pi -> C:\Users\user\AppData\Roaming\npm\node_modules\node-red\bin\node-red-pi
 + node-red@0.20.8
 updated 5 packages in 52.937

***Node-Redを起動 [#v66a9dec]

 PS C:\WINDOWS\system32> node-red
 20 Sep 09:43:02 - [info]
 
 Welcome to Node-RED
 =================== 
 
 20 Sep 09:43:02 - [info] Node-RED version: v0.20.8
 20 Sep 09:43:02 - [info] Node.js  version: v9.11.2  ←Node.jsのバージョン
 20 Sep 09:43:02 - [info] Windows_NT 10.0.17134 x64 LE
 20 Sep 09:43:06 - [info] Loading palette nodes
 (略)
 ---------------------------------------------------------------------
 Your flow credentials file is encrypted using a system-generated key.
 
 If the system-generated key is lost for any reason, your credentials
 file will not be recoverable, you will have to delete it and re-enter
 your credentials.
 
 You should set your own key using the 'credentialSecret' option in
 your settings file. Node-RED will then re-encrypt your credentials
 file using your chosen key the next time you deploy a change.
 ---------------------------------------------------------------------
 
 20 Sep 11:05:44 - [info] Starting flows
 20 Sep 11:05:44 - [info] Started flows
 20 Sep 11:05:44 - [info] Server now running at http://127.0.0.1:1880/



***Node-Redにアクセス [#sfe0a018]

Chormeでhttp://127.0.0.1:1880にアクセス

***node-red-contrib-gpioを追加 [#b7833771]
パレットの追加で「firmata」で検索してnode-red-contrib-gpioノードを追加

&ref("./addNode1.png");

&ref("./addNode2.png");

&ref("./addNode3.png");


''Node-Red起動の管理者のPoweshell内のメッセージ''

 20 Sep 09:44:16 - [info] モジュールnode-red-contrib-gpio, バージョン: 0.14.0 をインストールします
 20 Sep 09:45:03 - [info] モジュール node-red-contrib-gpio をインストールしました
 20 Sep 09:45:03 - [info] 追加したノード:
 20 Sep 09:45:03 - [info]  - node-red-contrib-gpio:gpio in
 20 Sep 09:45:03 - [info]  - node-red-contrib-gpio:gpio out
 20 Sep 09:45:03 - [info]  - node-red-contrib-gpio:node-led
 20 Sep 09:45:03 - [info]  - node-red-contrib-gpio:nodebot
 20 Sep 09:45:03 - [info]  - node-red-contrib-gpio:johnny5

''自宅仮想マシンでは上記の方法で追加できたが、ノートPC(Windows10 Home)では追加時エラーしたので以下のように管理者のPoweshellで追加した''

''node-red停止後コマンドを使用''

 PS C:\WINDOWS\system32> npm install -g node-red-contrib-gpio
 
 > serialport@6.0.5 install C:\Users\user\AppData\Roaming\npm\node_modules\node-red-contrib-gpio\node_modules\firmata\node_modules\serialport
 > prebuild-install || node-gyp rebuild
 
 
 > serialport@6.2.2 install C:\Users\user\AppData\Roaming\npm\node_modules\node- red-contrib-gpio\node_modules\serialport
 > prebuild-install || node-gyp rebuild
 
 + node-red-contrib-gpio@0.14.0
 added 285 packages in 32.636s

''以下のノードが追加する''

&ref("./node_p1.png");



***Arduinoノード(node-red-node-arduino)を追加 [#dc96abe7]

パレットの追加で「firmata」で検索してnode-red-node-arduinoノードを追加

''Node-Red起動の管理者のPoweshell内のメッセージ''

 20 Sep 09:59:57 - [info] モジュールnode-red-node-arduino, バージョン: 0.2.2 をインストールします
 20 Sep 10:00:05 - [info] モジュール node-red-node-arduino をインストールしました
 20 Sep 10:00:05 - [info] 追加したノード:
 20 Sep 10:00:05 - [info]  - node-red-node-arduino:arduino in
 20 Sep 10:00:05 - [info]  - node-red-node-arduino:arduino out
 20 Sep 10:00:05 - [info]  - node-red-node-arduino:arduino-board


''ノートPC(Windows10 Home)でコマンド使用時''

 PS C:\WINDOWS\system32> npm install -g node-red-node-arduino
 
 > @serialport/bindings@2.0.8 install C:\Users\user\AppData\Roaming\npm\node_modules\node-red-node-arduino\node_modules\@serialport\bindings
 > prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild
 
 + node-red-node-arduino@0.2.2
 added 76 packages in 13.512s

''以下のノードが追加する''

&ref("./node_p2.png");


**ArduinoIDEの起動後スケッチ追加 [#j24bbd5b]

追加スケッチは「StandardFirmata」
ファイル→スケッチ例→Firmata→StandardFrimsata

&ref("./firmata.png");


"USBにArduino UNOを接続"
''USBにArduino UNOを接続''

StandardFrimsataを検証("レ")し、Arduinoに書き込み("⇒")
&color(red){StandardFrimsataを検証("レ")し、Arduinoに書き込み("⇒")};

&ref("./firmata2.png");

**LED ON/OFF 確認 [#vdebdb74]

Node-Redで以下のようなパーツを配置(injection,debug,arduino)

''injectionノード''

&ref("./LED_ONOFF2.png");

''arduinoノード''

&ref("./LED_ONOFF3.png");

&ref("./LED_ONOFF4.png");

''接続''

&ref("./LED_ONOFF1.png");

injectionノードの「1」の左の■をクリックするとボード上の「L」のLEDが点灯、injectionノードの「0」の左の■をクリックするとボード上の「L」のLEDが消灯する。

***その他のコマンド [#j1a31f33]

''Pythonバージョン確認''

コマンドプロンプトを再起動

 C:\Windows\system32>python -V
 Python 2.7.15

''npmバージョン確認''

 C:\WINDOWS\system32>npm -v
 5.6.0

''no-rednoアンインストール''

 PS C:\WINDOWS\system32> npm -g uninstall node-red


''npm パッケージ確認''

 C:\WINDOWS\system32>npm -g list
 C:\Users\user\AppData\Roaming\npm
 +-- node-red@0.20.8
 | +-- @node-red/editor-api@0.20.8
 | | +-- @node-red/editor-client@0.20.8
 | | +-- @node-red/util@0.20.8 deduped
 | | +-- bcrypt@3.0.6 deduped
 | | +-- bcryptjs@2.4.3 deduped
 | | +-- body-parser@1.19.0


**参考 [#a8e63fb0]
-https://www.denshi.club/pc/nodered/windows-node-red-1.html

-https://nodered.jp/docs/getting-started/windows

-https://qiita.com/akuden/items/a88630de9624039c4135


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS