• I've got a run of cable in my house (probably only 2 metres) that I'm running at 3.3v from a switch, and even that does pick up some interference.

    I'd definitely say to use twisted pair or coaxial cable (so not straight like speaker wire). It might be worth looking at using an 'optoisolator'. They're dead simple - basically a LED and light sensor in one tiny chip, and they cut out interference that you might get from the wire by converting the signal to light first.

    Maybe use one of those, with 12v signals down the wire, going into the optoisolator via a suitable resistor (and maybe a 0.1uF capacitor across the optoisolator just to help with interference). On the other side of the optoisolator you can just go right into Espruino, and use the 'input_pullup' pin mode to take advantage of Espruino's built-in resistor.

      __
     |  |--------------- 12v
     |  |                            ______
     |__|---------/\/\/\------------|      |------- Espruino ('input_pullup' mode)
               1k resistor   |      |      |
    Switch                  _|_     |      |
                      0.1uF ___     |      |
                             |      |      |
                      GND____|______|      |_______ GND
                                    |______|
                                   Optoisolator
    
About

Avatar for Gordon @Gordon started