I'm using raspberry pi 3b to collect data from industrial machine for IoT project. We can collect data without any problem from customer's old machines by manually installing magnetic sensors.
Customer has new generation machines and we wanted to collect information ( just press of some mechanic part, not some advance information because machine does not have Ethernet module)
Machine has Plc and when press happens it gives +24v to circuit. We deployed relay and I connected 2 pin cable to relay (one from +24 other ground) and other part of relay goes to raspberry pi one cable from number 4 (5v) and number 11 and I configured number 11 as inputpulldown. Everything was ok when testing at our lab. When we complete circuit it was counting as expected.
We also tested at machine after working hour ( this was the only machine was working at that time for test ) it was also ok.
But when we came other day for testing we saw that number counts randomly even the plc does not complete relay circuit. I removed cable from relay and take it in my hand ( its not touching each other ) it was randomly counting I noticed that if I get closer to some machines its counting if I go away I stops counting.
We replaced cable from raspberry pi to relay with shielded one and its still same.( I use small pin cables to plug gpoi and connect this pin cables to shielded cable)
What strange is if I remove this long shielded cable (3m) leave only small pin cables on gpio 4 and 11 it does not complete circuit it works normal but if extend pin cables with any cable it starts counting (completing circuit) near this big machines. We checked machine is grounded
What's the reason can be for this ? Is it some kind of electromagnetic field making circuit complete ? (if so how to avoid)
While I'm writing this I notice that number 4 on raspberry is 5v input I changed it to number 1 do you think that maybe the reason ?
Details : Raspberry pi 3b and raspberry official screen and plastic cage and official power supply is used.