Skip to content

GPIO Basic: Node-RED implementation #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/RPI-GPIO-Basic-Node-RED-Arduino_Cloud.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/RPI-GPIO-Basic-Node-RED-Cloud_Config-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/RPI-GPIO-Basic-Node-RED-Cloud_Config.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/RPI-GPIO-Basic-Node-RED-Digital-IN.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/RPI-GPIO-Basic-Node-RED-Digital-OUT.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 1 addition & 3 deletions js/gpio-basic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ This is a screenshot for reference.

## 2. Set up your Node.js environment

### Install the system libraries and required NPM packages

Now it is time to install the Node.js dependencies in order to use Arduino Cloud. You have a [full tutorial](https://docs.arduino.cc/arduino-cloud/guides/javascript/) that describes the process in detail.

It can be summarized as follows:
Expand All @@ -73,7 +71,7 @@ sudo apt install gpiod libgpiod2 libgpiod-dev libnode-dev
### Install the GPIOD node.js package using NPM
Next, you have to install the node package.

> Tip: The NPM modules can be installed globally or locally in the working folder. My suggestion is to work in the `js/` folder and install the modules there. Once installed, you should see a folder `js/node_modules/`.
> Tip: The NPM modules can be installed globally or locally in the working folder. My suggestion is to work in the `js/` folder and install the modules there with the command above. Once installed, you should see a folder `js/node_modules/`. If you want to install the modules globally, just add `-g` to the command.

```
npm install --save node-libgpiod node-fetch
Expand Down
34 changes: 0 additions & 34 deletions node-red/README.md

This file was deleted.

351 changes: 351 additions & 0 deletions node-red/gpio-basic/README.md

Large diffs are not rendered by default.

38 changes: 34 additions & 4 deletions node-red/gpio-basic/flows.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"id": "77a698253f4e0f3b",
"type": "tab",
"label": "Flow 1",
"label": "Arduino Cloud <-> GPIOs",
"disabled": false,
"info": "",
"env": []
Expand Down Expand Up @@ -118,7 +118,7 @@
"repeat": "1",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"onceDelay": "5",
"topic": "",
"x": 150,
"y": 220,
Expand Down Expand Up @@ -202,7 +202,7 @@
"name": "Link to Arduino Cloud Dashboard",
"info": "https://app.arduino.cc/dashboards/25b90b8d-aba5-4414-9b4f-0a0f43778749",
"x": 210,
"y": 40,
"y": 500,
"wires": []
},
{
Expand Down Expand Up @@ -252,7 +252,7 @@
"repeat": "5",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"onceDelay": "5",
"topic": "",
"x": 150,
"y": 100,
Expand Down Expand Up @@ -329,5 +329,35 @@
"45efe7b0aee2a4a1"
]
]
},
{
"id": "58df54993a68d0e7",
"type": "comment",
"z": "77a698253f4e0f3b",
"name": "Periodic integer value sent to Arduino Cloud",
"info": "",
"x": 250,
"y": 60,
"wires": []
},
{
"id": "7d011f726bbf42ee",
"type": "comment",
"z": "77a698253f4e0f3b",
"name": "Read GPIO and send value to Arduino Cloud",
"info": "",
"x": 250,
"y": 180,
"wires": []
},
{
"id": "2c56eb0de8394bc8",
"type": "comment",
"z": "77a698253f4e0f3b",
"name": "Read LED status from Arduino Cloud and set GPIO",
"info": "",
"x": 270,
"y": 300,
"wires": []
}
]
17 changes: 17 additions & 0 deletions node-red/gpio-basic/pm2-node-red-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#! /bin/sh
#
# This is script must be used to launch Node-RED if you need to pre-configure
# any of the GPIOs
#

GPIOCHIP=4
GPIOLINE=15

# Set the GPIO as pull-up
/usr/bin/gpioget -B pull-up gpiochip${GPIOCHIP} ${GPIOLINE}

# Launch Node-RED
SCRIPT_PATH="$(realpath $0)"
NODE_RED_FOLDER="$(dirname $SCRIPT_PATH)"
/usr/bin/node-red -v --userDir ${NODE_RED_FOLDER} --max-old-space-size=128

6 changes: 1 addition & 5 deletions node-red/gpio-basic/pm2.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
"apps": [
{
"name": "node-red",
"script": "node-red",
// Change the directory to your own one
"args": ["--userDir", "/home/dbeamon/projects/python/arduino-cloud/rpi-arduino-cloud/node-red/gpio-basic"],
"node_args": ["--max-old-space-size=128"],
// Other configurations...
"script": "<FULL_PATH_TO_YOUR FOLDER>/pm2-node-red-start.sh"
}
]
}
Expand Down