Problem with watches on esp32

Posted on
  • I tried to use a watch on a esp32 where I got the following error:

    setWatch(function(st) { console.log(st.time) }, D4, {repeat: false, edge: 'falling', debounce: 10});
    WARNING: Unable to set watch. You may already have a watch on a pin with the same number (eg. A0 and B0),
    or this pin cannot be used with watch
    

    I also tried other pins which should work without luck. I am using esruino 2v00 on a esp32s chip. On espruino 2v01 i get the same message.

  • Only a few pins are available for setWatch. Its checked with jshCanWatch in targets/ESP32/jshardware.c
    Just checked with D12 and that works.

    bool jshCanWatch(
        Pin pin //!< The pin that we are asking whether or not we can watch it.
      ) {
      return pin == 0 || ( pin >= 12 && pin <= 19 ) || pin == 21 ||  pin == 22 || ( pin >= 25 && pin <= 27 ) || ( pin >= 34 && pin <= 39 );
    }
    
  • That solved the problem. Thanks alot!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Problem with watches on esp32

Posted by Avatar for fanThomas @fanThomas

Actions