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.

  • 1
    What you're describing (long cable in noisy environment introduces stray signals) is pretty classic antenna behaviour. This Q&A on the EE board is probably worth a read.
    – goobering
    Commented Apr 26, 2017 at 19:02
  • Thank you very much for answer. Actually its not that long cable but it causes problem.Even its not connected to relay somehow it gets circuit complete.I have read recommended post but I'm not sure exactly what to do.Do you have any suggestion ?
    – Cozdemir
    Commented Apr 26, 2017 at 19:58

1 Answer 1


Try putting a resistor.
Well, I don't know if this helps a lot but you could still try. enter image description here

  • Thank you for answer.As I read raspberry has inputpulldown. is it not same functionality ?
    – Cozdemir
    Commented Apr 26, 2017 at 19:43
  • Currently I have 2 pins plugged +3v and gpio 17 (which is number 11) . Should I also add pin to from 11 to ground with resistor between them ? (sorry for my knowledge about circuits)
    – Cozdemir
    Commented Apr 26, 2017 at 19:59
  • I don't know much about inputpulldown, so I just use input with a real resistor. And yes you should try that.
    – pauliucxz
    Commented Apr 26, 2017 at 20:32
  • Thank you I will try it tomorrow. By the way do I need to use aluminum case to avoid magnetic field ?
    – Cozdemir
    Commented Apr 26, 2017 at 21:12
  • seems this guy has also same problem raspberrypi.org/forums/viewtopic.php?f=28&t=177500 I noticed that he uses 2.2k resistor. Is there any specific reason for 10k ?
    – Cozdemir
    Commented Apr 26, 2017 at 22:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.