Rasberry Pi GPIO pins not switching

I have a simple GPIO set up where I inject a 1 and a 0 into the standard GPIO node to turn a relay on and off. my GPIO pins will not change state

H @Jsimon003 , welcome to the forum.

Perhaps you could give a little more information:

What device are you running Node-red on?
What operating system does it run?
What version of Node-red and node.js?
Exactly what "standard GPIO node" are you using?
How do you know that the pins do not change state?
Can you show us your flow? Export it from Node-red and paste it here after clicking the </> button.

What device are you running Node-red on?
Rasbery Pi 4
What operating system does it run?
Rasberry pi OS
What version of Node-red and node.js?
v1.0.6
Exactly what "standard GPIO node" are you using?
node-red-node-pi-gpio is the pallet and im using rip GPIO out

How do you know that the pins do not change state?
Because the relay constantly stay on even though I inject a 0

Can you show us your flow? Export it from Node-red and paste it here after
clicking the </> button.

[{"id":"1def1387.cd722c","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"a04aa8dc.1f7988","type":"inject","z":"1def1387.cd722c","name":"","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":310,"y":220,"wires":[["6383dbad.370dc4"]]},{"id":"6383dbad.370dc4","type":"rpi-gpio out","z":"1def1387.cd722c","name":"","pin":"40","set":"","level":"0","freq":"","out":"out","x":570,"y":200,"wires":[]},{"id":"7ebaf35.02cca0c","type":"inject","z":"1def1387.cd722c","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":310,"y":140,"wires":[["6383dbad.370dc4"]]}]

Thanks! I'm in my phone just now so I can't look at the flow but my first thought is whether your relays work with 3.3V and the very low current from a Pi gpio pin.

The current node red version is 2.2.2 so if you are on 1.0.6 it's probably a good idea to run the installation script to update NR and node.js, then update your nodes individually in palette manager.

1 Like

There have definitely been updates to the gpio nodes recently to do with the latest raspiOS and it’s use of python 3. So it is probably worth upgrading, and ensuring you have the latest gpio nodes as well.

Apart from the advice above from @dceejay regarding upgrading, which you really should follow, can you measure the voltage on the GPIO pins with a multi-meter to see if they are turning on and off? @jbudd's question whether the relays work on 3.3V is important too.

I have updated to node-red 2.2.2 and ensured the GPIO palette was updated with no change. Every digital pin on the Rasberry pi is reading 3.3 volts. When I unplug the wire coming from the relay to the Rasberry pi the relay turns off. I switch the wire to another pin on the Rasberry pi and the relay activates again even though that pin is not in use.

Which relay are you using?
And how are you configuring the GPIO pins in node-red?

im using a sainsmart 12volt relay. attached is the code im using.

`[{"id":"1def1387.cd722c","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"a04aa8dc.1f7988","type":"inject","z":"1def1387.cd722c","name":"","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":310,"y":220,"wires":[["6383dbad.370dc4"]]},{"id":"6383dbad.370dc4","type":"rpi-gpio out","z":"1def1387.cd722c","name":"","pin":"40","set":"","level":"0","freq":"","out":"out","x":570,"y":200,"wires":[]},{"id":"7ebaf35.02cca0c","type":"inject","z":"1def1387.cd722c","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":310,"y":140,"wires":[["6383dbad.370dc4"]]}]`

Have you measured the pin with a multi-meter, without attaching the relay?

yes its 3.3 volts

And when you inject 0?

so I did a little more testing with the multi meter. The GPIO pins do change when I inject the 0 and 1. It seems the issue is in the relay board somewhere. I had a ground wire running to the relay board from the pi ground and a wire running from GPIO pin 40 to a pin on the relay board. I removed the ground wire because that was wrong. Theres an LED on the relay board to tell me when its active or not. The LED is only half lit. When I had the ground attached it was fully lit. I think my problem is trying to find out where to put my ground wire.

so I hooked everything to a 5v relay using the 5v GPIO pin on the Rasberry pi and it worked

Again, the max. current that the Rpi can drive is 50mA (on Rail)!
Each pin can drive 16mA.
You can also use only 3 output pins.
More current damage the output driver.
At moment to buy a Rpi isn't easy.

Do you have a 12Volt power supply for the relay board ?
Why was the ground wrong ?
The ground pin on the 12V PSU, the Rpi and the relay board should all be connected together.

The Rasperry Pi does not have 5V GPIO's:

Raspberry Pi GPIO Pinout: What Each Pin Does on Pi 4, Earlier Models | Tom's Hardware.

I have a feeling that the OP means the 5V power pin - which will not be enough to drive the relays properly.

I have a feeling that the OP means the 5V power pin - which will not be enough to drive the relays properly.
Not sure about that statement, maybe I didn't read close enough but I didn't see board specs. I would be curious about the interconnects though. Besides current draw there might be ground loop issues. Sometimes plug and play - isn't. Half lit led's is an obvious problem.

half lit LED not unexpected :slight_smile: