I have an ESP8266 where I took one of the GPIO pins, configured the pullup on the input, then connected it to one lead of a 15m cable and the other lead to the ESP8266 ground.

The problem I have is that the input is flaky all the times, high/low. If I remove the leads to the cable, it's stable high. I measured the cable and with the leads connected together to one another, there's is a resistance of a 1.03 ohm. If the leads are not connected as they are 99.9% of the time, there is no resistance on the cable.

What am I doing wrong? How can I fix this issue?

  • 3
    \$\begingroup\$ Congratulations, you've built your first loop antenna. Now try to demodulate the input to find out what's on the radio. Arrange it in a circle for better reception. \$\endgroup\$ – berendi - protesting Jul 9 '19 at 7:59
  • \$\begingroup\$ Seriously, it's picking up electromagnetic noise. The internal pullup has quite high resistance, between 30 and 100 kΩ, probably not enough to bring to a stable high. What were you trying to do with that cable? \$\endgroup\$ – berendi - protesting Jul 9 '19 at 8:07
  • 2
    \$\begingroup\$ Use a an external pullup with a resistance as low as your power supply can handle. Perhaps wait until a qualified electrical engineer (which I'm not) writes a proper answer, because things can happen to long wires strung out outdoors, which may fry sensitive electronics. \$\endgroup\$ – berendi - protesting Jul 9 '19 at 8:18
  • 2
    \$\begingroup\$ Beware that long cables can pickup high voltages and blow up your GPIO input (A lightning strike in the vicinity being the ultimate challenge.) There are special protection circuits (ICs) which try to prevent your circuit being fried. \$\endgroup\$ – Oldfart Jul 9 '19 at 10:22
  • 1
    \$\begingroup\$ While not necessary in a simple case, something fairly robust would be to use an optocoupler. Configure the wire and sensor-switch with an appropriate resistor to pass a few milliamps to light the optocoupler's LED, and use the pullup resistor on the transistor side. To get the maximum isolation benefit you'd need a distinct power supply for the sensor circuit and the ESP8266 and a geometrically isolated layout around the optocoupler package, but even without, a current-mode loop has a lot more noise immunity than a voltage-mode sensor input. \$\endgroup\$ – Chris Stratton Jul 9 '19 at 12:42

Your Answer

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

Browse other questions tagged or ask your own question.