GPIO for NodeRED Topic is solved

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
Post Reply
Krisberg
Posts: 7
Joined: Thu Jul 22, 2021 1:03 am

GPIO for NodeRED

Post by Krisberg »

Hello, DietPi community. I hope everyone is doing well.

Firstly, let me say that my experience with DietPi has been much more enjoyable than with Raspbian. This operating system is awesome! Thank you!

I am contacting you today because I ran into some trouble with NodeRED. Don't worry, NodeRED installs and works just fine. However, when I try to install the node package from the palette manager that lets me use the GPIO pins on the Raspberry Pi (RPI 3 in this case), the installation process is unsuccessful. Let me elaborate. I chose the node package called "node-red-node-pi-gpio" since it has the most downloads. However, "node-red-node-pi-gpiod" is also recommended. You cannot simply download "node-red-node-pi-gpio" from the palette manager and expect it to work - there is some additional setup required by entering commands in the terminal as per the instalation instructions. Perhaps these terminal commands work on most other operating systems for the Raspberry Pi, but they do not work on DietPi. I am hoping we can work through them together. I got an error message on the second command specifically - ImportError: No module named setuptools. Thank you.

Respect and gratitude,
Krisberg
User avatar
Joulinar
Posts: 5619
Joined: Sat Nov 16, 2019 12:49 am

Re: GPIO for NodeRED

Post by Joulinar »

Hi,

I did a test installation on my RPi3B+ running Debian Bullseye 32bit and installation was running without issues. I did following
  1. dietpi-software install 122
  2. cd /mnt/dietpi_userdata/node-red/
  3. npm i node-red-node-pi-gpio
The package is available afterwards

Code: Select all

root@DietPi3:/mnt/dietpi_userdata/node-red# npm list
node-red@ /mnt/dietpi_userdata/node-red
├── node-red-node-pi-gpio@1.2.3
└── node-red@2.0.6

root@DietPi3:/mnt/dietpi_userdata/node-red#
Did you changed into sub directory /mnt/dietpi_userdata/node-red before running installation of node-red-node-pi-gpio package?
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Krisberg
Posts: 7
Joined: Thu Jul 22, 2021 1:03 am

Re: GPIO for NodeRED

Post by Krisberg »

Hello Joulinar. Thank you for your quick reply.

Forgive me if I was not clear. Installing the node package called "node-red-node-pi-gpio" isn't the issue exactly. Installing it from the palette manager or with your method directly from the terminal both install the node package and they are made available in NodeRED. However, just because they are available in NodeRED, doesn't mean that they are working. In addition to installing this node package, you must also use these terminal commands to truly complete the installation process, as per its installation instructions.

Code: Select all

sudo apt-get install python-pip python-dev
sudo pip install RPi.GPIO  
sudo addgroup gpio
sudo chown root:gpio /dev/gpiomem
sudo adduser $USER gpio
echo 'KERNEL=="gpiomem", NAME="%k", GROUP="gpio", MODE="0660"' | sudo tee /etc/udev/rules.d/45-gpio.rules
sudo udevadm control --reload-rules && sudo udevadm trigger
I got the error message "ImportError: No module named setuptools" on the second command. I was able to solve this error by, well, installing so-called "setuptools" and the nodes that control the GPIO pins on the Raspberry Pi are now actually controlling the GPIO pins. So, an additional line at the beginning is needed from the instructions provided, like this:

Code: Select all

sudo sudo apt-get install -y python-setuptools
sudo apt-get install python-pip python-dev
sudo pip install RPi.GPIO  
sudo addgroup gpio
sudo chown root:gpio /dev/gpiomem
sudo adduser $USER gpio
echo 'KERNEL=="gpiomem", NAME="%k", GROUP="gpio", MODE="0660"' | sudo tee /etc/udev/rules.d/45-gpio.rules
sudo udevadm control --reload-rules && sudo udevadm trigger
This page from StackOverflow was useful. Thanks again Joulinar!

Respect and Gratitude,
Krisberg
Last edited by Krisberg on Wed Sep 08, 2021 4:04 pm, edited 1 time in total.
User avatar
Joulinar
Posts: 5619
Joined: Sat Nov 16, 2019 12:49 am

Re: GPIO for NodeRED

Post by Joulinar »

ah ok. probably I misunderstood you question. Good you solved it now.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Post Reply