Strange signal spike to GPIO pins at startup of NodeRED (Pigpiod)

I'm currently using NodeRED to interact with the GPIO pins of my RPI4 board. All works pretty well, but when I'm rebooting my RPI I have a very short signal pulse to the relays that are connected to the GPIO output pins. Which means that strange things happen in my home automation (curtains closing, sunscreens closing, etc). The reason is that this part of my domotica is connected with a classic PLC which I control with relays from the GIPIO pins. A very short signal is already sufficient for the PLC to act.

I've experimented with the different settings for the output nodes (initialise pin state, not initialise pin state, set high, set low): but all act the same.

I'm running PIGPIOD (tried the local version and currently running the docker version), which is working great. I've tried the following scenarios:

  • Stop NodeRED and stop/start Pigpiod: no output spikes
  • Both NodeRED and Pigpiod running and stop/start Pigpiod: spikes
  • Both NodeRED and Pigpiod running and restart NodeRED: no output spikes

I suspect that the output is created as soon as nodered is connected to Pigpiod (it is at the same time I can access the flows after restarting).

Does anyone using the node-red-node-pi-gpiod (v0.4.0) nodes experience the same problem?

When electronics startup or shut down as the voltages drop or fluctuate it's not unusual to get strange signals on boards. Expensive boards have parts to take care of this where it may cause problems. The Pi being "inexpensive" lacks these safeguards. If you are having issues you will need to do this yourself. Putting clamps, filters, or other circuits to hold the pin down or up until the device is fully operational can be as simple as an electrolytic capacitor but probably will be more involved. On my pi a simple rc filter did the trick. The problem is finding a solution that fixes the pin bounce but allows proper operation of the pin, or at least acceptable operation.

Have got pull up resistors on the pins?
If so, what value?

Before Node-RED starts the OS is in charge of the pins and some initialise high and some low. I’m not sure if there a table somewhere which describes which do what but if you can accept/follow those then you may not see the toggling you currently see. Obviously if you need (say) a low level and the OS initialises it high, and then Node-RED sets it low then you will see the spike.

1 Like

I don't believe it's a software issue. I think it's a hardware design compromise. It's been a while but I had a device that responded to very fast signals and thus I did the rc filter. A quick goggle still reveals power on pin issues. But, I could be wrong.

From the description it appears not to be a power up issue, it is described as happening when pigpiod is started with node-red already running, which suggests that it is an interaction between node red and pigpiod.

@rik1984, if you have not already done so, add a debug node showing what is going into the gpio pin, then stop and restart pigpiod and see what node-red sends to the pin.

Thanks for thinking along.

@Colin not sure if i understand it correctly. Pull up resistors are relevant to ensure the right signal at an input pin, right? Not for the GPIO output? I have a direct connection to a relay board VCC - In1

@Colin #2 for the debug node holds the same. There is no Nodered output connector at gpio in node. I like your idea: how can I debug?

Is there another way to debug this? GPIOD logging?

Alternatively indeed adding a vc filter is a good idea!

When the pin is initialised if may start at an input pin, which means it will float about. Add a 4k7 pull up to 3.3v.

For the debug it is what is going into the gpio node that is important. Add a debug node showing that.

That makes sense. I'll first try to add the resistor as you suggested.

I've debugged what goes into the gpio out node indeed. There are no messages at all

I think the explanation of @dceejay makes sense. That it happens at the handover of the gpio from the os to nodered. Im thinking whether i can prevent the os from having access.

Can I just check which state it is that drives the relay? I have assumed that it is 0 that drives the relay, is that correct.

Yes that is correct, I've configured the nodes initial level of the pin on high (1). And I have pulse nodes that pulses 0->1 when I trigger the relay

Good. Try it with the pullup resistor, but I must admit I am not very hopeful. Are you using the latest versions of node-red and the gpiod library?

1 Like

. All works pretty well, but when I'm rebooting my RPI I have a very short signal pulse to the relays that are connected to the GPIO output pins.

He states on power up @Colin
[Edit] I doubt resistors alone will fix this. RC filter of some type, T filter, Pi filter, something a little more sophisticated but not exotic.

But also there is

Those may be two separate causes, or they may not. If there is only one cause then it is not directly related to power up.

Note that the spike is not extremely narrow as it is wide enough to close the relay.

@rik1984 can you not communicate with the PLC with modbus or other protocol rather than relays?

@gerry, your prediction was accurate. I just did a trial by adding a 4k7 resistor. But I'm still experiencing the same behaviour :frowning:

@Colin I'm using NR 3.0.2 and pigpiod v 79

Yes sorry for the confusion about when it occurs. I have just retested all scenarios. And as you can see it only appears once after restart and the first startup of NodeRED

I just tested all scenarios:

  • When I reboot NodeRED while the Gpiod connection is running nothing happens, the same when I stop nodered, wait a while and start it again
  • When I stop pigpiod (killall) NodeRED keeps showing the active connections. When I restart NodeRED it shows Connection Refused. When I start Pigpiod NodeRED directly picks-up the connections but WITHOUT the spike signal
  • When I stop pigpiod (killall) and start it again. NodeRED is still showing the connections, but the pins are not working anymore. Till I restart NodeRED it is working again WITHOUT spike signal. I was wrong in my first post (I was really under the impression that that happened).

So the strange thing is: it only happens after a fresh boot of the RPI. In the following scenario's:

  • Gpiod auto starts at startup, NodeRED starts (after): spike!
  • Gpiod auto start disabled, NodeRED starts, Gpiod started (nothing happens, but NodeRED is not identifying the gpiod connection status), restart NodeRED: spike!
  • Gpiod auto start disabled, NodeRED not started at startup, starting up Gpiod manually, after starting up NodeRED manually: spike!
  • Gpiod auto start disabled, NodeRED not started at startup, starting up NodeRED manually, after starting up Gpiod: spike!

@Colin about the PLC: unfortunately I have an old Siemens logo installed in my house, without network connection. Maybe I should consider upgrading to one with a LAN / Modbus interface

Have you tried a small tantalum cap to see if that works? It seems to me no matter the cause all you need is a small despiking component or circuit

Unfortunately i only have some resistors at home. And im not very known with other type of electronics.

I started reading about rc circuits and think i need to create high pass filters. Using a resistor and capacitor.

Could you advise what to order? Are there also ready to use filters in the market? I dont have much space to place in a lot of components

Have you confirmed that the pullup resistor does not help?

Before we go much further can you give a little more detail on your hookups? How is the gpio hooked up to the device? Wire? What kind of wire? How long is the wire?
Unless you are sending Mhz signals down the wire I don't think you need a high pass filter. It sounds like you are sending a high or low relatively slowly. It would be helpful if you described what the gpio outputs to the device as well. Is it a command string? My first thought is a simple debounce type of circuit is all you need, maybe a couple of 10uF tantalums would work too. That fixed one of my problems similar to yours.

@Colin, yes i've put a 4k7 resistor between the gpio out and the in on the relays board. This didn't effect

@gerry I appreciate your thinking along. I will make a detailed picture of the gpio setup, relays and nodered flow. This will take some time, i will post it in the beginning of next week