I have few switches connected to Raspberry Pi inputs. Internal pull up resistors are enabled. When I connect pin to the ground Raspberry Pi behave fine - pin state is low. However when I disconnect the pin from the ground it randomly change the state every few seconds. I have tried to add external 10k pull up resistor but it haven't worked. Pull up resistor is connected near Raspberry Pi. Switch is connected by 7 meters UTP 5e cable. I use pi4j library. enter image description here

  • Please add a photo of the connections. An external 10k resistor should be enough to stop the input floating. A listing of the software will also be useful.
    – joan
    Oct 5 '19 at 19:41
  • I have updated description and added picture Oct 5 '19 at 19:55
  • Perhaps the 7 metres of cable is too much for a 10 k resistor. As an experiment do you get a problem if you connect to GPIO 2 or 3 (they have 1k8 pulls to 3V3 fitted).
    – joan
    Oct 5 '19 at 20:12
  • related if not dupe: raspberrypi.stackexchange.com/q/57951/19949 and raspberrypi.stackexchange.com/q/93834/19949 (the length of the cable - now edited into the question - might be an issue... try decreasing the pull-up)
    – Ghanima
    Oct 5 '19 at 20:13
  • Actually I have problem with pins 4,5,13,14, and 29. I couldn't find Raspberry Pi 3B+ electric schema Oct 5 '19 at 20:15

If you are actually using GPIO0 (pin 27) this is actually SDA.0 which is used to control HATs and is marked reserved on official documentation.

I believe on newer Pi models this I²C bus is also connected to on-board extenders so is used for other purposes, although this is not documented, expect the voltage on this pin to change unexpectedly.

Use any ot the other pins (and a low impedance circuit).

  • Actually I have problem with GPIO pins 4,5,13,14, and 29 of 3B+. I couldn't find Raspberry Pi 3B+ electric schema Oct 6 '19 at 9:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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