Rpi-gpio input node "stopped"


I'm trying to follow the Rapsberrypi.org guide "getting started with Node-RED"

I completed very easily the first flow for switching on/off a LED with a rpi-gpio out node and two inject nodes, but I got stuck adding a button with a rpi-gpio in node to control the LED. This is step 11 in the above-mentioned getting started guide.

The button shows as "stopped" and does not change its state after pressing it

I have a RPi2 Model B with the following raspbian and node-red versions:

Description:    Raspbian GNU/Linux 9.1 (stretch)
Release:        9.1
Codename:       stretch

Welcome to Node-RED

25 Nov 17:24:58 - [info] Node-RED version: v0.19.4
25 Nov 17:24:58 - [info] Node.js  version: v8.11.1
25 Nov 17:24:58 - [info] Linux 4.9.41-v7+ arm LE

For the rpio-gpio in node (that's the node for my press button) I have the same properties as in the tutorial, one pin connected to GPI04-7 (with pullup resistor) and the other one to GND. That should mean that GPIO pin 4 will be set to HIGH, and pressing the button will cause it to go LOW.

I've also added a debug node to check if the payload changes from 1 to 0 but I only get this first message (this "1" is due to the pullup resistor and the checkbox "Read initial state of pin on deploy/restart" being marked in the settings):

11/25/2018, 10:30:52 AMnode: f5cc3952.9c7f58
pi/7 : msg.payload : number

But after that, the flow diagram shows the button as "stopped" and nothing happens when I press the button.I've double-checked the wiring and it's identical to the one in the tutorial.



Are there any messages printed to the window where you copied the “welcome to node-red” message from?



Nope. It only shows the server start messages and start/stop flow messages, but nothing happens when I press the button.

By the way, I should say that node-js was already installed in my raspbian version, I havent installed it myself.

I include the node-red console messages:

pi@raspberrypi:~ $ node-red
26 Nov 02:20:32 - [info] 

Welcome to Node-RED

26 Nov 02:20:32 - [info] Node-RED version: v0.19.4
26 Nov 02:20:32 - [info] Node.js  version: v8.11.1
26 Nov 02:20:32 - [info] Linux 4.9.41-v7+ arm LE
26 Nov 02:20:38 - [info] Loading palette nodes
26 Nov 02:20:47 - [info] Settings file  : /home/pi/.node-red/settings.js
26 Nov 02:20:47 - [info] Context store  : 'default' [module=memory]
26 Nov 02:20:47 - [info] User directory : /home/pi/.node-red
26 Nov 02:20:47 - [warn] Projects disabled : set editorTheme.projects.enabled=true to enable
26 Nov 02:20:47 - [info] Flows file     : /home/pi/.node-red/flows_raspberrypi.json
26 Nov 02:20:47 - [warn] 

Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.

You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.

26 Nov 02:20:47 - [info] Starting flows
26 Nov 02:20:48 - [info] Started flows
26 Nov 02:20:48 - [info] Server now running at
26 Nov 02:23:11 - [info] Stopping flows
26 Nov 02:23:11 - [info] Stopped flows
26 Nov 02:23:11 - [info] Starting flows
26 Nov 02:23:11 - [info] Started flows


Does changing the pin to 40-GPIO21 make any difference?

1 Like


From the documentation, have you tried:

sudo apt-get update && sudo apt-get install python-rpi.gpio

Also, the user must be a member of the gpio group. To add the current user to the group

sudo adduser $USER gpio


Yes! it works with BCM21
Why is that?



It could be that something else is controlling access to pin7 (gpio4)



I'm working with pi user, which belongs to gpio group already.
I've installed node-red from scratch in another RasPi using the script:

bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)

But the button remained also "stopped". Trying with pin gpio21 instead of gpio04 worked, though.



Thanks! it works actually with any other GPIO pin except with GPIO04.(GPCLK0). Even the other two GPCLK pins (BCM5 & 6) work, but not GPIO04.
How could I check if there's something interfering with that pin? I have no other circuits connected to the RPi.



That pin is used for a clock output or something I think. If you have not disabled that use then it was still being acquired by that so you could not use it.

1 Like


Run raspi-config and check that 1-wire is disabled.

1 Like