JETSON ORIN NANO Developer kitでNode-REDを動かすメモ

# はじめに

JETSON ORIN NANO Developer kitを起動してNode-REDを動かすまでのメモです。

## SDカードイメージのダウンロード

https://developer.nvidia.com/embedded/jetpack

JP511-orin-nano-sd-card-image.zip (10.4GB)というファイルがダウンロードされます。

## SDカードイメージの書き込み

Etcherを使用してSDカード (32GB以上) へファイルを書き込みます。

https://www.balena.io/etcher

## 起動

JETSON ORIN NANOへSDカードを挿入し、HDMIケーブル(DisplayPort - HDMI変換アダプタ経由)、USBキーボード・マウス、Ethernetケーブル、DC電源ケーブル(AC電源アダプタ)を接続して、JETSON ORIN NANO Developer kitを起動します。

![jetson_orin_nano.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/72479/e70ed047-e967-d85a-78e8-2a2cf0aa2d35.jpeg)

![Screenshot from 2023-06-20 16-12-59.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/72479/5c16aeab-b7d4-4e53-ff1e-5f6944f15da4.png)

# Node-REDのインストール

Xtermを起動してターミナル画面を表示します。
(リモートからJETSON ORIN NANOへSSHアクセスしても可。)

ソフトウェアアップデートを実行し、curlコマンドをインストールします。

```bash
$ sudo apt update
$ sudo apt upgrade
$ sudo apt install curl
```

以下のコマンドを実行して、JETSON ORIN NANO に Node-RED をインストールします。

```bash
$ bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)
```

質問を聞かれた場合は、y を入力します。(2回)
インストール完了後に質問を聞かれた場合は、 n または Enterを入力します。(1回)

```bash
Are you really sure you want to do this ? [y/N] ? (← y を入力)
Would you like to install the Pi-specific nodes ? [y/N] ? (← y を入力)

Running Node-RED install for user kitazaki at /home/kitazaki on ubuntu

This can take 20-30 minutes on the slower Pi versions - please wait.

  Stop Node-RED                       ✔
  Remove old version of Node-RED      ✔
  Remove old version of Node.js       ✔   
  Install Node.js 16 LTS              ✔   v16.20.0   Npm 8.19.4
  Clean npm cache                     ✔
  Install Node-RED core               ✔   3.0.2
  Move global nodes to local          -
  Npm rebuild existing nodes          ✔
  Install extra Pi nodes              ✔
  Add shortcut commands               ✔
  Update systemd script               ✔
                                      

Any errors will be logged to   /var/log/nodered-install.log
All done.
You can now start Node-RED with the command  node-red-start
  or using the icon under   Menu / Programming / Node-RED
Then point your browser to localhost:1880 or http://{your_pi_ip-address}:1880

Started :  2023年  6月 20日 火曜日 15:46:35 JST 
Finished:  2023年  6月 20日 火曜日 15:49:06 JST
 
**********************************************************************************
 ### WARNING ###
 DO NOT EXPOSE NODE-RED TO THE OPEN INTERNET WITHOUT SECURING IT FIRST
 
 Even if your Node-RED doesn't have anything valuable, (automated) attacks will
 happen and could provide a foothold in your local network
 
 Follow the guide at https://nodered.org/docs/user-guide/runtime/securing-node-red
 to setup security.
 
 ### ADDITIONAL RECOMMENDATIONS ###
  - You can customise the initial settings by running:
 
      node-red admin init
 
  - After running Node-RED for the first time, change the ownership of the settings
    file to 'root' to prevent unauthorised changes:
 
      sudo chown root:root ~/.node-red/settings.js
 
**********************************************************************************
 
  Would you like to customise the settings now (y/N) ? (← N または Enterを入力)
```

# Node-REDを動かす

```bash
$ node-red start

20 Jun 15:49:36 - [info] 

Welcome to Node-RED
===================

20 Jun 15:49:36 - [info] Node-RED version: v3.0.2
20 Jun 15:49:36 - [info] Node.js  version: v16.20.0
20 Jun 15:49:36 - [info] Linux 5.10.104-tegra arm64 LE
20 Jun 15:49:36 - [info] Loading palette nodes
20 Jun 15:49:38 - [info] Settings file  : /home/kitazaki/.node-red/settings.js
20 Jun 15:49:38 - [info] Context store  : 'default' [module=memory]
20 Jun 15:49:38 - [info] User directory : /home/kitazaki/.node-red
20 Jun 15:49:38 - [warn] Projects disabled : editorTheme.projects.enabled=false
20 Jun 15:49:38 - [info] Flows file     : /home/kitazaki/.node-red/start
20 Jun 15:49:38 - [info] Creating new flow file
20 Jun 15:49:38 - [warn] 

---------------------------------------------------------------------
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 Jun 15:49:38 - [info] Server now running at http://127.0.0.1:1880/
20 Jun 15:49:38 - [warn] Encrypted credentials not found
20 Jun 15:49:38 - [info] Starting flows
20 Jun 15:49:38 - [info] Started flows
```

# フローエディタを表示する

ブラウザからhttp://[JETSON ORIN NANOのIPアドレス]:1880へアクセスします。

![node-red.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/72479/ddef4e22-3cae-550e-bbd6-604e96d3f87c.jpeg)