> For the complete documentation index, see [llms.txt](https://docs.antares.id/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.antares.id/en/code-and-library-examples/node-red.md).

# Node-RED

### **Menjalankan Node-RED**

You must first install Node.js and Node-RED on your computer/device. If you don't have Node.js and Node-RED, you can follow the tutorial on the page [https://nodejs.org/en/](https://nodejs.org/en) and then [https://nodered.org/docs/getting-started/installation](https://nodered.org/docs/getting-started/local).

Node-RED is a programming tool for connecting hardware devices, APIs, and online services in new and exciting ways. Node-RED provides a browser-based editor that makes it easy for users to connect flows with extensive use of nodes in a palette that can be directly applied with one click\[1]. Node-RED is shared with Antares, MQTT, and other platforms/protocols. Once installed, Node-RED can be run by typing "node-red" at the command prompt.

<figure><img src="/files/mzNNF0wjB5bHxbOhtpPZ" alt=""><figcaption><p>Running Node-RED</p></figcaption></figure>

Users can type "localhost:1880" or "IPv4-address:1880" in the browser to access Node-RED.

### Node-RED Parts

<figure><img src="/files/1ZTfLMwlnbQ5idQc6Q1l" alt=""><figcaption><p>Parts of the RED Node</p></figcaption></figure>

In Node-RED, there are sections called nodes and flows. Nodes are the parts that are used to create the programme. There are several types of nodes: input, output, function, and others. The nodes can be downloaded in the "Manage palette" menu.

<figure><img src="/files/pH7N7RHe13dcRdDxO9lB" alt=""><figcaption><p>"Manage Palette" Menu</p></figcaption></figure>

A window will appear. The "nodes" menu shows nodes that are already installed, while the "install" menu shows nodes that can be downloaded and installed.

<figure><img src="/files/LWNJUaz2vPn3WRKYAybJ" alt=""><figcaption><p> "Nodes" and "Manage Palette" Menu</p></figcaption></figure>

<figure><img src="/files/DzGLa2SMjn3sF5pw21Lm" alt=""><figcaption><p> "Install" menu in "Manage Palette"</p></figcaption></figure>

A flow is a place to attach nodes. In one Node-RED window, there can be more than one flow. Flows are independent of each other.

### Using MQTT&#x20;

#### ***A. Node*****&#x20;MQTT**

MQTT nodes are already installed during the installation of Node-RED. There are two types of MQTT nodes: MQTT input and MQTT output.

<figure><img src="/files/iVPeI81UdZAd08G0rWTd" alt=""><figcaption><p>Gambar 6. Tipe <em>Node</em> MQTT</p></figcaption></figure>

#### **B.** MQTT Broker Setup&#x20;

An MQTT node looks like this:

<figure><img src="/files/8FpnJnaQFtg0cpqBrkZ3" alt=""><figcaption><p>MQTT Node Settings</p></figcaption></figure>

Adding a new broker can be done by selecting "add new mqtt-broker" and clicking on the right-hand icon. Setting up a broker can be done by simply clicking on the right-hand icon.

<figure><img src="/files/E1qNiznu2K7hMPhh4teY" alt=""><figcaption><p>New Broker Additions</p></figcaption></figure>

Users can name the new broker and set the server and port used.

<figure><img src="/files/rTAAdXE5bxkusODxU4N8" alt=""><figcaption><p>New Broker Settings</p></figcaption></figure>

#### **C.** Transmitting and Receiving Data

Simulation of input data from the device can be done with the use of the "inject" node.

<figure><img src="/files/5Y4l8LyZtvFjc42gPrdC" alt=""><figcaption><p>Send Data</p></figcaption></figure>

The "inject" node can be changed to provide another data type. In this case, the data type used is JSON.

<figure><img src="/files/W0lCo9gcUPgT0ZLfmDkz" alt=""><figcaption><p>Setting the "inject" Node</p></figcaption></figure>

Programmes can be written by clicking on the "..." icon.

<figure><img src="/files/6bPhjHjFe7WfqhvRlA2u" alt=""><figcaption><p>Programme Writing</p></figcaption></figure>

The "debug" node can be used to view the messages sent.

<figure><img src="/files/lE8rfw2UQiN8eEwVgUkM" alt=""><figcaption><p>Receive Data</p></figcaption></figure>

Users can view the received messages in the "debug" panel.

<figure><img src="/files/KvSHEeS86LfjS7ACb8DI" alt=""><figcaption><p>Output in the "Debug" Panel</p></figcaption></figure>

## Reference

1. ["Node-RED: Flow-based Programming For The Internet"](https://nodered.org/). [Node-RED](https://nodered.org/). Accessed on 13 September 2018.
