Wiki source code of Node-RED_Install and Use

Version 39.1 by Herong Lu on 2022/07/26 09:07

Hide last authors
Edwin Chen 14.1 1 (% class="wikigeneratedid" id="HEndDeviceFrequencyBand" %)
Xiaoling 37.2 2 **Table of** **Contents:**
Edwin Chen 13.1 3
Edwin Chen 14.1 4 {{toc/}}
5
Herong Lu 2.1 6
Xiaoling 37.2 7
8
9 = 1.  Installation =
10
11
Herong Lu 21.1 12 Check installation instruction for different OS from this link: [[https:~~/~~/nodered.org/docs/getting-started/>>https://nodered.org/docs/getting-started/]]
Herong Lu 2.1 13
14
Edwin Chen 12.1 15
Xiaoling 37.2 16 == 1.1  Install Example for CENTOS ==
17
18
19 === 1.1.1  Installation ===
20
21
Edwin Chen 11.1 22 (% class="box infomessage" %)
23 (((
Herong Lu 21.1 24 Reference Instruction from this link:  [[https:~~/~~/github.com/node-red/linux-installers>>https://github.com/node-red/linux-installers]]
25 Run below commands and wait for installation complete.
Edwin Chen 11.1 26 )))
Herong Lu 9.1 27
Xiaoling 32.2 28 [[image:image-20220526161040-1.png]]
Herong Lu 9.1 29
30
Xiaoling 37.4 31 (% style="color:blue" %)**Verify if the installation was successful**
Herong Lu 9.1 32
Xiaoling 37.4 33 Type in the command line interface ** (% style="color:red" %)node-red(%%)**(% style="color:red" %)  
34
Herong Lu 21.1 35 The following information appears to prove that the installation has been successful
Herong Lu 9.1 36
Xiaoling 32.2 37 [[image:image-20220526161103-2.png]]
Herong Lu 9.1 38
39
Xiaoling 37.4 40
Xiaoling 37.2 41 === 1.1.2  If you want to start Node-RED as a background process ===
Herong Lu 9.1 42
Xiaoling 37.2 43
Xiaoling 37.4 44 Type in the command line interface  (% style="color:red" %)**nohup node-red &**
Herong Lu 9.1 45
Herong Lu 21.1 46 It will prompt after startup
Herong Lu 9.1 47
48 [[image:image-20220519104601-5.png]]
49
Xiaoling 37.4 50 After seeing the above information, press **enter**
Herong Lu 9.1 51
Herong Lu 21.1 52 Type in the command line  exit
Herong Lu 9.1 53
Herong Lu 21.1 54 The above is the installation and startup process of nodered. If you don't understand anything, you can go to the nodered official website. There are installation instructions for various systems. The address has a link at the top
Edwin Chen 12.1 55
56
Edwin Chen 15.1 57
Xiaoling 37.2 58 == 1.2  Install in Dragino Gataway ==
Edwin Chen 15.1 59
Herong Lu 38.1 60 Dragino Gateway is already installed, no need for users to install it by themselves
Edwin Chen 12.1 61
Xiaoling 37.2 62
63 = 2.  Use Node-RED =
64
65
66 == 2.1  Login to Node-RED interface ==
67
68
Herong Lu 21.1 69 Enter your public IP address followed by the port number 1880
Edwin Chen 12.1 70
Herong Lu 21.1 71 example:[[http:~~/~~/xxx.xx.xx.xx:1880/>>http://119.91.62.30:1880/]]
Edwin Chen 12.1 72
Herong Lu 38.1 73 [[image:image-20220519104115-4.png||height="280" width="768"]]
Edwin Chen 12.1 74
75
Edwin Chen 16.1 76
Xiaoling 37.2 77 == 2.2  Add flow ==
78
79
Herong Lu 21.1 80 Take NBSN95 mod1 UDP protocol as an example
Edwin Chen 16.1 81
Xiaoling 37.5 82 After logging into the interface click** (% style="color:red" %)"+" (%%)**to create a flow
Edwin Chen 16.1 83
Herong Lu 38.1 84 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/node_red%20usage%20example/WebHome/image-20220519133634-1.png?rev=1.1||alt="image-20220519133634-1.png" height="183" width="770"]]
Edwin Chen 16.1 85
Xiaoling 37.5 86
87
Herong Lu 21.1 88 Rename the stream
Edwin Chen 16.1 89
Herong Lu 38.1 90 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/node_red%20usage%20example/WebHome/image-20220519134042-2.png?rev=1.1||alt="image-20220519134042-2.png" height="535" width="548"]]
Edwin Chen 16.1 91
Herong Lu 38.1 92 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/node_red%20usage%20example/WebHome/image-20220519134318-3.png?rev=1.1||alt="image-20220519134318-3.png" height="461" width="753"]]
Edwin Chen 17.1 93
Herong Lu 20.2 94 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/node_red%20usage%20example/WebHome/image-20220519134346-4.png?rev=1.1||alt="image-20220519134346-4.png"]]
Edwin Chen 17.1 95
Herong Lu 21.1 96 Drag UDP into the editing area
Edwin Chen 17.1 97
Xiaoling 37.5 98
99
Herong Lu 20.2 100 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/node_red%20usage%20example/WebHome/image-20220519134533-5.png?rev=1.1||alt="image-20220519134533-5.png"]]
101
Xiaoling 37.5 102
Herong Lu 21.1 103 The same method as above, drag and drop functions and debug into the editing area
Herong Lu 20.2 104
Herong Lu 38.1 105 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/node_red%20usage%20example/WebHome/image-20220519134850-6.png?rev=1.1||alt="image-20220519134850-6.png" height="442" width="776"]]
Herong Lu 20.2 106
Xiaoling 37.5 107
108
Herong Lu 21.1 109 configure UDP in
Herong Lu 20.2 110
Herong Lu 38.1 111 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/node_red%20usage%20example/WebHome/image-20220519135402-7.png?rev=1.1||alt="image-20220519135402-7.png" height="332" width="767"]]
Herong Lu 20.2 112
Xiaoling 37.5 113
Herong Lu 21.1 114 Write to the UDP port that the device node sends to the server
Herong Lu 20.2 115
Herong Lu 21.1 116 Example My UDP device node sends to server port 8585
117 just write 8585
Herong Lu 20.2 118
119
Xiaoling 37.5 120 (% style="color:red" %)**Note: that the port that is already in use cannot be used. If the receiving fails, you need to check whether the port of the server is occupied. The sending port of the device node should not use the default port used by the server, such as a common port such as 8080.**
121
122
Herong Lu 21.1 123 In order to avoid data confusion, different types of nodes do not use the same UDP port, because different nodes have different data formats and different functions.
Herong Lu 20.2 124
Herong Lu 38.1 125 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/node_red%20usage%20example/WebHome/image-20220519135915-8.png?rev=1.1||alt="image-20220519135915-8.png" height="415" width="735"]]
Herong Lu 20.2 126
Xiaoling 37.5 127
Herong Lu 38.1 128 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/node_red%20usage%20example/WebHome/image-20220519144651-14.png?rev=1.1||alt="image-20220519144651-14.png" height="348" width="779"]]
Herong Lu 20.2 129
Xiaoling 37.5 130
Herong Lu 38.1 131 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/node_red%20usage%20example/WebHome/image-20220519141355-11.png?rev=1.1||alt="image-20220519141355-11.png" height="437" width="744"]]
Herong Lu 20.2 132
Xiaoling 37.5 133
Herong Lu 38.1 134 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/node_red%20usage%20example/WebHome/image-20220519141704-12.png?rev=1.1||alt="image-20220519141704-12.png" height="229" width="777"]]
Herong Lu 20.2 135
Xiaoling 37.5 136
137
Herong Lu 21.1 138 When the node successfully sends data, the effect shown in the following figure will appear
Herong Lu 20.2 139
Herong Lu 38.1 140 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/node_red%20usage%20example/WebHome/image-20220519150455-15.png?rev=1.1||alt="image-20220519150455-15.png" height="403" width="799"]]
Herong Lu 20.2 141
142
Xiaoling 37.2 143
144 === 2.2.1  About function ===
145
146
Herong Lu 21.1 147 If you are familiar with JS code, you can write it yourself
148 If you are not familiar, we have the JS code for each type of node, you just need to copy and paste it into it
Herong Lu 20.2 149
Xiaoling 37.6 150
Herong Lu 38.1 151 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/node_red%20usage%20example/WebHome/image-20220519141833-13.png?rev=1.1||alt="image-20220519141833-13.png" height="478" width="789"]]
Herong Lu 20.2 152
153
154
Xiaoling 37.2 155 == 2.3  Plot Chart for sensors ==
156
157
Herong Lu 25.1 158 If you need data visualization, please refer to the following
Herong Lu 20.2 159
Xiaoling 37.2 160
Herong Lu 25.1 161 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/node_red%20usage%20example/WebHome/image-20220519152802-16.png?rev=1.1||alt="image-20220519152802-16.png"]]
162
Xiaoling 37.6 163
164
165 (% style="color:blue" %)**1. Click Install
Herong Lu 25.1 166 2. Search the dashboard
Xiaoling 37.6 167 3. Click Install**
Herong Lu 25.1 168
Xiaoling 37.6 169
170
Herong Lu 38.1 171 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/node_red%20usage%20example/WebHome/image-20220519152956-17.png?rev=1.1||alt="image-20220519152956-17.png" height="763" width="835"]]
Herong Lu 25.1 172
Xiaoling 37.7 173
174
Herong Lu 25.1 175 After the installation is successful, nodered will show the following node icon
176
177 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/node_red%20usage%20example/WebHome/image-20220519153335-19.png?rev=1.1||alt="image-20220519153335-19.png"]]
178
179
Xiaoling 37.2 180
181 === 2.3.1  the line chart as an example ===
182
183
Herong Lu 25.1 184 Drag the line chart to the editing area
185
186 Just drag and drop as many as you need, or you can copy
187
188 The demo uses 3 kinds. Voltage, temperature, humidity
189
Xiaoling 37.7 190
Herong Lu 38.1 191 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/node_red%20usage%20example/WebHome/image-20220519154521-20.png?rev=1.1||alt="image-20220519154521-20.png" height="242" width="743"]]
Herong Lu 25.1 192
Xiaoling 37.7 193
194
Herong Lu 25.1 195 double click function
196
Xiaoling 37.7 197
Herong Lu 38.1 198 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/node_red%20usage%20example/WebHome/image-20220519154640-21.png?rev=1.1||alt="image-20220519154640-21.png" height="549" width="749"]]
Herong Lu 25.1 199
Xiaoling 37.7 200
201
Herong Lu 25.1 202 Adjusted to 3, because we need to display 3 charts
203
Xiaoling 37.7 204
Herong Lu 38.1 205 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/node_red%20usage%20example/WebHome/image-20220519154812-22.png?rev=1.1||alt="image-20220519154812-22.png" height="418" width="755"]]
Herong Lu 25.1 206
207
Xiaoling 37.2 208
209 === 2.3.2  the chart settings ===
210
211
Herong Lu 25.1 212 Double-click while setting up the node as above
213
Xiaoling 37.7 214
Herong Lu 38.1 215 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/node_red%20usage%20example/WebHome/image-20220519160314-23.png?rev=1.1||alt="image-20220519160314-23.png" height="703" width="729"]]
Herong Lu 25.1 216
Xiaoling 37.7 217
Herong Lu 38.1 218 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/node_red%20usage%20example/WebHome/image-20220519160412-24.png?rev=1.1||alt="image-20220519160412-24.png" height="501" width="727"]]
Herong Lu 25.1 219
Xiaoling 37.7 220
Herong Lu 38.1 221 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/node_red%20usage%20example/WebHome/image-20220519160759-27.png?rev=1.1||alt="image-20220519160759-27.png" height="554" width="722"]]
Herong Lu 25.1 222
Xiaoling 37.7 223
Herong Lu 38.1 224 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/node_red%20usage%20example/WebHome/image-20220519161326-30.png?rev=1.1||alt="image-20220519161326-30.png" height="444" width="721"]]
Herong Lu 25.1 225
Xiaoling 37.7 226
Herong Lu 38.1 227 [[image:image-20220525185746-2.png||height="421" width="724"]]
Herong Lu 25.1 228
Xiaoling 37.7 229
Herong Lu 38.1 230 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/node_red%20usage%20example/WebHome/image-20220519161650-32.png?rev=1.1||alt="image-20220519161650-32.png" height="722" width="726"]]
Herong Lu 25.1 231
Xiaoling 37.7 232
233
Herong Lu 25.1 234 After the display interface is defined for the first time, subsequent charts can directly select the display interface
235
236
Herong Lu 38.1 237 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/node_red%20usage%20example/WebHome/image-20220519162039-34.png?rev=1.1||alt="image-20220519162039-34.png" height="644" width="724"]]
Xiaoling 37.7 238
239 ​​​​​​
240
Herong Lu 38.1 241 [[image:image-20220525190106-3.png||height="575" width="724"]]
Herong Lu 25.1 242
Xiaoling 37.7 243
244
Herong Lu 25.1 245 Connect graph nodes to functions with lines
246
247 Click to deploy
248
Xiaoling 37.7 249
Herong Lu 38.1 250 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/node_red%20usage%20example/WebHome/image-20220519162412-36.png?rev=1.1||alt="image-20220519162412-36.png" height="256" width="726"]]
Herong Lu 25.1 251
252 Enter the server public IP + port 1880/ui
253
254 example:[[http:~~/~~/xxx.xx.xx.xx:1880/ui>>url:http://119.91.62.30:1880/ui/#!/18?socketid=WY1MCE0RFEKHey8KAADj]]
255
Xiaoling 37.7 256
257
Herong Lu 38.1 258 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/node_red%20usage%20example/WebHome/image-20220519163141-37.png?rev=1.1||alt="image-20220519163141-37.png" height="203" width="735"]]
Herong Lu 25.1 259
260 At this point, the basic demonstration of nodered is completed. If you need to beautify the chart and various visualizations, you can go to the official documentation of nodered for further understanding.
261
Herong Lu 20.2 262
Xiaoling 37.2 263
264 == 2.4  Store Value ==
265
266
Xiaoling 37.8 267 Regarding storage, we recommend two ways.
Herong Lu 20.2 268
Herong Lu 36.1 269
Xiaoling 37.2 270
Xiaoling 37.3 271 === 2.4.1  1. Generate txt document directly ===
Xiaoling 37.2 272
Herong Lu 38.1 273 Sample JSON file:链接转到示例JSON文件
Xiaoling 37.8 274
Herong Lu 38.1 275 [[image:image-20220713102658-1.png||height="346" width="728"]]
Herong Lu 36.1 276
277
278
Xiaoling 37.3 279 === 2.4.2  2. Use sqlite database ===
Xiaoling 37.2 280
281
Xiaoling 37.8 282 ==== (% style="color:blue" %)**1.  Install SQLite**(%%) ====
Xiaoling 37.2 283
284
Herong Lu 38.1 285 [[image:image-20220713111030-2.png||height="438" width="739"]]
Herong Lu 36.1 286
287
Xiaoling 37.2 288
Xiaoling 37.8 289 ==== (% style="color:blue" %)**2.  After the installation is successful, the nodes in the picture will appear**(%%) ====
Xiaoling 37.2 290
291
Herong Lu 36.1 292 [[image:image-20220713111200-3.png]]
293
294
295
Xiaoling 37.8 296 ==== (% style="color:blue" %)**3.  Import sample flow**(%%) ====
Herong Lu 20.2 297
Herong Lu 39.1 298 Refer to the import example below to import the sqlite example flow
Herong Lu 20.2 299
Herong Lu 39.1 300 Download sample JSON file link: 链接
Xiaoling 37.8 301
Xiaoling 37.2 302 = 3.  Input Flow =
303
304
Herong Lu 27.1 305 Directly import JSON files to generate flow
306
307 Download the required JSON file through this link: 提供一个链接
308
Herong Lu 28.1 309 Take LHT65 as an example  (this node is already registered with TTN,MQTT protocol to connect)
310
Herong Lu 27.1 311 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/Directly%20import%20JSON%20files%20to%20generate%20flow/WebHome/image-20220524175748-3.png?rev=1.1||alt="image-20220524175748-3.png"]]
312
313 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/Directly%20import%20JSON%20files%20to%20generate%20flow/WebHome/image-20220524175814-4.png?rev=1.1||alt="image-20220524175814-4.png"]]
314
Herong Lu 38.1 315 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/Directly%20import%20JSON%20files%20to%20generate%20flow/WebHome/image-20220524175914-5.png?rev=1.1||alt="image-20220524175914-5.png" height="443" width="773"]]
Herong Lu 27.1 316
Herong Lu 38.1 317 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/Directly%20import%20JSON%20files%20to%20generate%20flow/WebHome/image-20220524175935-6.png?rev=1.1||alt="image-20220524175935-6.png" height="568" width="768"]]
Herong Lu 27.1 318
Herong Lu 28.1 319 After the import is successful, change the MQTT in node to your TTN information
320
Herong Lu 38.1 321 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/Directly%20import%20JSON%20files%20to%20generate%20flow/WebHome/image-20220524184449-1.png?rev=1.1||alt="image-20220524184449-1.png" height="643" width="772"]]
Herong Lu 28.1 322
Herong Lu 38.1 323 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/Directly%20import%20JSON%20files%20to%20generate%20flow/WebHome/image-20220524184521-2.png?rev=1.1||alt="image-20220524184521-2.png" height="648" width="773"]]
Herong Lu 28.1 324
325 Configure information consistent with your TTN
326
Herong Lu 38.1 327 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/Directly%20import%20JSON%20files%20to%20generate%20flow/WebHome/image-20220524184722-3.png?rev=1.1||alt="image-20220524184722-3.png" height="349" width="758"]]
Herong Lu 28.1 328
Herong Lu 38.1 329 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/Directly%20import%20JSON%20files%20to%20generate%20flow/WebHome/image-20220524192830-4.png?rev=1.1||alt="image-20220524192830-4.png" height="376" width="758"]]
Herong Lu 28.1 330
331 API keys generated by the password for you
332
Herong Lu 38.1 333 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/Directly%20import%20JSON%20files%20to%20generate%20flow/WebHome/image-20220524193028-5.png?rev=1.1||alt="image-20220524193028-5.png" height="370" width="759"]]
Herong Lu 28.1 334
335 Topic modify it to the following format
336
Herong Lu 30.1 337 v3/(% style="color:red" %)Application ID(%%)@ttn/devices/(% style="color:red" %)End device ID(%%)/up
Herong Lu 28.1 338
Herong Lu 38.1 339 [[image:http://8.211.40.43:8080/xwiki/bin/download/Main/Node-RED/Directly%20import%20JSON%20files%20to%20generate%20flow/WebHome/image-20220524193258-6.png?rev=1.1||alt="image-20220524193258-6.png" height="690" width="755"]]
Herong Lu 28.1 340
341 After the modification is completed, click Deploy