• So I just flashed a LoLin ESP8266 board, with 1v99, and tried to replicate your problem. SetWatch performed as expected when connected to Vin or GND. It detected the state change when I touched the pins. I used your code example.

    I have worked with setWatch alot on the ESP8266, and its pretty stable. As an example, after I tried to replicate your problem, I wired up a rotary encoder and used the "encoder" module to test. It uses setWatch under the hood. Here is my code (just a copy paste from the "encoder" module page).

    var step = 0;
    require("Encoder").connect(NodeMCU.D5,No­deMCU.D6,function (direction) {
      step += direction;
      print(step);
    });
    
    

    As you can see I got a couple of errors (probably my pin choices), and a warning about FIFO_FULL, but this didn't affect performance in anyway. I was spinning the encoder as fast as I can. So thats about 22 events in 2-3 seconds, which is not bad. I literally span the encoder as fast as I could and everything was fine. The FIFO_FULL warning only came after a restart of the module. It could perform for hundreds of turns after without problems.

     ____                 _
    |  __|___ ___ ___ _ _|_|___ ___
    |  __|_ -| . |  _| | | |   | . |
    |____|___|  _|_| |___|_|_|_|___|
             |_| espruino.com
     1v99 (c) 2018 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate
    Flash map 4MB:1024/1024, manuf 0x20 chip 0x4016
    >
    =undefined
    ERROR: Pin state not supported
    ERROR: Pin state not supported
    -1
    -2
    New interpreter error: FIFO_FULL
    -3
    -4
    -5
    -6
    -7
    -8
    -9
    -10
    -11
    -12
    -13
    -14
    -15
    -16
    -17
    -18
    -19
    -20
    -21
    -22
    

    So this suggests to me Espruino is fine. And that as @allObjects suggested your problem is electrical. Please note, that not all ESP8266 boards are the same or of the same quality. For example both the ESP-201s, and the AT-WITTYs were notoriously difficult to deal with from flash memory corruption to extremely flakey power. Other boards (WeMos D1 Mini comes to mind), operate pretty flawlessly.

    Anyways check your setup again I'd suggest.

About