• Hi,

    The simplest way to do it would be to advertise a 'button press count' variable. If you upload the following:

    var pressCount = 0;
    setWatch(function() {
      pressCount++;
      NRF.setAdvertising({
        0xFFFF : [pressCount]
      });
    }, BTN, { edge:"rising", repeat:true, debounce:50 });
    

    And then disconnect from Puck.js, whenever you press the button you'll see a service UUID '0xFFFF' broadcast that has a number in it. Each time the number changes, an MQTT event will get fired, and you can hook on to that in Node-red (by default you'll still get an event fired by EspruinoHub every 60 seconds even it it hasn't changed, but there's a node-red block that'll filter that out by only passing a message when the value changes).

    The nice thing about doing it this way is there's no connection, and also if you walk out of range, press the button and then walk back in range, the event will still fire when Puck.js gets back in range

About

Avatar for Gordon @Gordon started