Long Wire - Digital Input

Discussion in 'The Projects Forum' started by brunoudi, Jun 17, 2016.

  1. brunoudi

    Thread Starter New Member

    May 28, 2016
    I'm developing a dimmer and have some questions about the switches...

    My dimmer is developed based on ESP-12E (3.3V), and I'm worried about the distance of switch can be installed from the device... I'm detecting the changes in switch like this (R1 = 10k):


    I've thought about adding capacitors and filters, but I'm not sure about how to calculate them. Usually, the cables connecting the switch are single wires going together 220Vac - 60hz.

    This circuit can be applyed as solution to my device? http://forum.allaboutcircuits.com/threads/pic16f877a-emi-and-noise-protection.109380/#post-842094
  2. Dodgydave

    Distinguished Member

    Jun 22, 2012
    This should be ok, the micro is only detecting a high low transition.
  3. brunoudi

    Thread Starter New Member

    May 28, 2016
    @Dodgydave I would like to consider in specifications a maximum cable length for connect the switch (or switches in parallel). In your opinion, is it ok I consider 50 meters (25m to go, and 25m to return)?
  4. AlbertHall

    Well-Known Member

    Jun 4, 2014
    The circuit you link to will invert the switch action. Will that matter to you?
    Otherwise you could connect a capacitor (perhaps 10uF) from the resistor to ground, and add a 100ohm resistor in series with the switch.
  5. brunoudi

    Thread Starter New Member

    May 28, 2016
    @AlbertHall The swtich action inverted doesnt matter... I programmed the chip like that

    I using pullup, instead of pulldown, because I heard it is better to avoid interferences.
  6. Dodgydave

    Distinguished Member

    Jun 22, 2012
    Your only problem is noise spikes on a long run, 50mtr wont have a resistance of more than 10 ohms, i would make R1 1k.
  7. DickCappels


    Aug 21, 2008
    It is unlikely that the resistance will be an issue per Dodgydave, but the capacitance to time varying voltages might be a problem. Consider what might happen in a thunderstorm of in the case of the long run of wire being in parallel with AC power lines. Adding some filtering is an excellent idea.

    When I did something similar I found that I had to heavily bypass the signal line. I'm pretty sure it was 50 Hz from the wiring in my house that was getting into the signaling wire.
  8. crutschow


    Mar 14, 2008
    Using a shielded wire (audio coax) will significantly reduce any noise pickup.
    thumb2 likes this.
  9. SLK001

    Active Member

    Nov 29, 2011
    Twist the two switch lines together and add a 100pF and a 0.1uF capacitor at the micro end to the lines.
  10. Sensacell

    Well-Known Member

    Jun 19, 2012
    This subject gets religious quickly! everybody has a different take.
    You can go nuts protecting an input from lots of imaginary and real threats- keep it cheap and simple.

    1) Use a low value pull up, like 330 ohms. This reduces the input impedance, which helps mitigate capacitive coupling from AC power lines, you don't want the input floating around. Pushing some current through the contacts also helps keep them free of oxides, especially if not plated with precious metals.

    2) Isolate the input with a series resistor.
    The inputs are typically clamped with internal diodes to GND and Vcc, a 4.7K ohm series resistor prevents damaging currents from flowing into the input protection diodes.

    3) Put a 0.1 uf cap right on the input to GND. This helps to absorb ESD energy and bypasses any RF on the line.

    Happy switching!
  11. Picbuster


    Dec 2, 2013
  12. Bordodynov

    Active Member

    May 20, 2015

    TEST.png TESTplot.png