Skip to content

Commit e495eb2

Browse files
committed
Node-RED. First version.
1 parent 7a715c8 commit e495eb2

File tree

2 files changed

+280
-0
lines changed

2 files changed

+280
-0
lines changed

node-red/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
## The setup
2+
3+
4+
## GPIOD nodes
5+
In all the projects in this repository, we are using `libgpiod` and the different wrappers and bindings for the variuos programming languages to interact with the RPI GPIOs. There are many other projects and libraries that can be used, but this is the most portable one across all the Raspberry Pi flavours and it can also be extrapolated to any Linux-based machine.
6+
7+
In this project, we are going to use `node-red-contrib-libgpiod` which is the
8+
9+
Go to the menu "Manage Palette" --> "Install". Search the following nodes and install them.
10+
11+
@arduino/node-red-contrib-arduino-iot-cloud
12+
node-red-contrib-libgpiod
13+
14+
## Configure the access to Arduino Cloud
15+
16+
## How to install Node-RED
17+
There are many ways to install Node-RED in a Raspberry Pi or any other machine. Typically, you can use: docker, snap, apt, native node.js installation.
18+
The tricky point is that we want our Node-RED instance to have access to the GPIOs and host system. This can be achieved with all the installation methods but for most of them it is quite difficult to achieve and many conflicts and issues need to be solved. So, the easiest and recommended way would be to do a native installation using NPM.
19+
20+
These are the instructions
21+
1. Installation
22+
```
23+
sudo npm install -g --unsafe-perm node-red
24+
```
25+
2. Manage the service
26+
I recommend using pm2 to manage the service and make it start on boot
27+
```
28+
sudo npm install -g pm2
29+
pm2 start /usr/bin/node-red -- -v
30+
pm2 save
31+
sudo env PATH=$PATH:/usr/bin $(which pm2) startup systemd
32+
```
33+
34+

node-red/gpio-basic/flows.json

Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
[
2+
{
3+
"id": "77a698253f4e0f3b",
4+
"type": "tab",
5+
"label": "Flow 1",
6+
"disabled": false,
7+
"info": "",
8+
"env": []
9+
},
10+
{
11+
"id": "75cf75b699400a70",
12+
"type": "arduino-connection",
13+
"applicationname": "Arduino Cloud"
14+
},
15+
{
16+
"id": "24cfd9cc1c1afa32",
17+
"type": "debug",
18+
"z": "77a698253f4e0f3b",
19+
"name": "debug 1",
20+
"active": true,
21+
"tosidebar": true,
22+
"console": false,
23+
"tostatus": false,
24+
"complete": "false",
25+
"statusVal": "",
26+
"statusType": "auto",
27+
"x": 680,
28+
"y": 60,
29+
"wires": []
30+
},
31+
{
32+
"id": "c867832c3d1e4d7b",
33+
"type": "inject",
34+
"z": "77a698253f4e0f3b",
35+
"name": "",
36+
"props": [
37+
{
38+
"p": "payload"
39+
},
40+
{
41+
"p": "topic",
42+
"vt": "str"
43+
}
44+
],
45+
"repeat": "",
46+
"crontab": "",
47+
"once": false,
48+
"onceDelay": 0.1,
49+
"topic": "",
50+
"payload": "0",
51+
"payloadType": "num",
52+
"x": 150,
53+
"y": 180,
54+
"wires": [
55+
[
56+
"74096cf67e153bb0",
57+
"45efe7b0aee2a4a1"
58+
]
59+
]
60+
},
61+
{
62+
"id": "72088a8b307e6580",
63+
"type": "inject",
64+
"z": "77a698253f4e0f3b",
65+
"name": "",
66+
"props": [
67+
{
68+
"p": "payload"
69+
},
70+
{
71+
"p": "topic",
72+
"vt": "str"
73+
}
74+
],
75+
"repeat": "",
76+
"crontab": "",
77+
"once": false,
78+
"onceDelay": 0.1,
79+
"topic": "",
80+
"payload": "1",
81+
"payloadType": "num",
82+
"x": 150,
83+
"y": 240,
84+
"wires": [
85+
[
86+
"74096cf67e153bb0",
87+
"45efe7b0aee2a4a1"
88+
]
89+
]
90+
},
91+
{
92+
"id": "2ed4ef3e5a6259bd",
93+
"type": "debug",
94+
"z": "77a698253f4e0f3b",
95+
"name": "debug 2",
96+
"active": true,
97+
"tosidebar": true,
98+
"console": false,
99+
"tostatus": false,
100+
"complete": "false",
101+
"statusVal": "",
102+
"statusType": "auto",
103+
"x": 440,
104+
"y": 300,
105+
"wires": []
106+
},
107+
{
108+
"id": "63c94b31249472ac",
109+
"type": "gpio-in",
110+
"z": "77a698253f4e0f3b",
111+
"name": "",
112+
"state": "INPUT",
113+
"device": "gpiochip4",
114+
"pin": "4",
115+
"x": 320,
116+
"y": 100,
117+
"wires": [
118+
[]
119+
]
120+
},
121+
{
122+
"id": "74096cf67e153bb0",
123+
"type": "gpio-out",
124+
"z": "77a698253f4e0f3b",
125+
"name": "",
126+
"state": "OUTPUT",
127+
"device": "gpiochip4",
128+
"pin": "17",
129+
"x": 450,
130+
"y": 180,
131+
"wires": [
132+
[]
133+
]
134+
},
135+
{
136+
"id": "1732b73c9a35b80c",
137+
"type": "inject",
138+
"z": "77a698253f4e0f3b",
139+
"name": "",
140+
"props": [
141+
{
142+
"p": "topic",
143+
"vt": "str"
144+
}
145+
],
146+
"repeat": "1",
147+
"crontab": "",
148+
"once": false,
149+
"onceDelay": 0.1,
150+
"topic": "",
151+
"x": 150,
152+
"y": 100,
153+
"wires": [
154+
[
155+
"244b9558c4ea408c"
156+
]
157+
]
158+
},
159+
{
160+
"id": "65724da039f208af",
161+
"type": "rbe",
162+
"z": "77a698253f4e0f3b",
163+
"name": "",
164+
"func": "rbe",
165+
"gap": "",
166+
"start": "",
167+
"inout": "out",
168+
"septopics": true,
169+
"property": "payload",
170+
"topi": "topic",
171+
"x": 490,
172+
"y": 100,
173+
"wires": [
174+
[
175+
"24cfd9cc1c1afa32",
176+
"d73d5d99772925b2"
177+
]
178+
]
179+
},
180+
{
181+
"id": "d73d5d99772925b2",
182+
"type": "property out",
183+
"z": "77a698253f4e0f3b",
184+
"connection": "75cf75b699400a70",
185+
"thing": "74c49bf8-3844-4239-a663-76927d173cb2",
186+
"property": "93fc3c3f-d936-4d74-ac26-982fb6a2d7c4",
187+
"name": "button",
188+
"propname": "button",
189+
"defaultname": true,
190+
"sendasdevice": false,
191+
"device": "09d3a634-e1ad-4927-9da0-dde663f8e5c6",
192+
"x": 670,
193+
"y": 100,
194+
"wires": []
195+
},
196+
{
197+
"id": "2a01b1b47921fcfd",
198+
"type": "property in",
199+
"z": "77a698253f4e0f3b",
200+
"connection": "75cf75b699400a70",
201+
"thing": "74c49bf8-3844-4239-a663-76927d173cb2",
202+
"property": "49eb3950-5fab-41ed-8baf-95d45ad0357e",
203+
"name": "led",
204+
"propname": "led",
205+
"defaultname": true,
206+
"variableName": "led",
207+
"x": 130,
208+
"y": 300,
209+
"wires": [
210+
[
211+
"2ed4ef3e5a6259bd",
212+
"45efe7b0aee2a4a1"
213+
]
214+
]
215+
},
216+
{
217+
"id": "244b9558c4ea408c",
218+
"type": "gpio-in",
219+
"z": "77a698253f4e0f3b",
220+
"name": "",
221+
"state": "INPUT",
222+
"device": "gpiochip4",
223+
"pin": "15",
224+
"x": 330,
225+
"y": 60,
226+
"wires": [
227+
[
228+
"65724da039f208af"
229+
]
230+
]
231+
},
232+
{
233+
"id": "45efe7b0aee2a4a1",
234+
"type": "gpio-out",
235+
"z": "77a698253f4e0f3b",
236+
"name": "",
237+
"state": "OUTPUT",
238+
"device": "gpiochip4",
239+
"pin": "14",
240+
"x": 450,
241+
"y": 240,
242+
"wires": [
243+
[]
244+
]
245+
}
246+
]

0 commit comments

Comments
 (0)