Seedling · Rough notes and first results

Pump noise causing false triggers on Raspberry Pi GPIO

Planted Czytaj po polsku →

I switch a Grundfos MQ3-45 pump in the basement from a Raspberry Pi, so I do not have to go down there every time I water the garden (it cannot stay on permanently, because it makes noise every now and then). The Pi drives it through a typical opto-isolated Arduino relay module: 5 V supply, 3.3 V signal from GPIO. That worked flawlessly.

Trouble started when I added an input running outside over shielded twisted pair. It was meant for a reed-switch rain gauge; to start with it was a push button shorting to ground, with a 4.7 kΩ pull-up.

The symptom

Just plugging the pump into the same socket as the Raspberry Pi’s power supply was enough to pull the input low. The pump motor did not even start – only the LEDs on its panel lit up. By pulling the plug out and pushing it back in, I could trigger interrupts at will.

Diagram: the Raspberry Pi power supply and the MQ3-45 pump on the same 230 V mains; a button shorts GPIO to ground, with a 4.7 kΩ pull-up to 3.3 V
The setup while testing: relays disconnected, the pump and the Pi power supply plugged into the same socket.

I suspected the relays, so I disconnected them – no change. Running the Pi from a UPS helped, but not completely.

What the forum suggested

A long cable leaving the Pi picks up interference, and the GPIO input is galvanically connected to it. The fix is isolation:

  1. An optocoupler at the Raspberry Pi end, in place of the button: collector to GPIO (with a pull-up), emitter to ground.
  2. Power the optocoupler’s LED through the long cable and the button, with a resistor, from a separate supply.
  3. A 100 nF capacitor across the optocoupler’s LED.
  4. A software low-pass filter (debounce) on the input.
  5. Proper filtering of the Pi’s own power supply.

The same rule applies to every input and output that leaves the Pi’s enclosure.

Status

This is an old note from 2016 and I never wrote down whether the optocoupler finally solved it – hence a seedling. Electrical noise came back when I automated my storage heaters, where for similar reasons I dropped RS485/Modbus in favour of plain relay outputs.

Source: my thread on elektroda.pl (in Polish) – Pompa Grundfos sieje zakłóceniami i powoduje stan niski na GPIO Raspberry (June 2016).