You are reading a single comment by @maman and its replies. Click here to read the full conversation.
  • @hungryforcodes, @allObjects, thanks for the reply. I use ESP-07 from Ai. Now, I am developing lamp controller that can be remotely controlled by MQTT protocol. However, I want to use the previously mechanical switch to control the lamp, locally, in case the network failed. I connected directly the mechanical switch to pin D5 of esp8266 tied-up with 10K resistor to VCC. It seems that the problem is the mechanical switch. I have tested the code below :

    print("Starting watch set test\n");
    var testPin = D13;
    pinMode(testPin, "input");
    var watchId = setWatch(function() {
      print("The callback function was called for a pin I/O change\n");
    }, testPin, { repeat: true} );
    print("A new watch was set up with id=" + watchId + "\n");
    

    And the result is there are many callback function was called, and the ESp8266 was crashed.

    then I put a small capacitor on the switch terminal, and add debounce at 100, then it is run well.
    Thanks for your attention.

About

Avatar for maman @maman started