DIO Change Detectiion flickering output

I wanto to monitor a switch with multi entry on a machine.
I link one input to my xbee s2 zb module digital input DIO4 set as high
and the ouput of the switch to IO5 set as digital input
a 10kOmh pulldown resistor is put between gnd and IO5.
Before connecting the switch to this device I test it with a simple interruptor. It work well, I receive a message every time a change is detected. But as soon as I’m neear the machine (which is apparently not CEM compatible) even if I don’t connect my xbee to the switch, my Digital input is flickering between high and low, like an antenna. What is wrong ?

Too much electrical noise getting on the radios inputs.

Do you think the right methot is to filter the noise by putting a 10uF capacitance between input and ground ?

Finally, it works well by putting a 10nF capacitance between IO and ground ! The noise is filtered.