You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • As @allObjects says, Advertising is what you want. It's only in one direction so it's not guaranteed that you'll receive every advertising packet. What I usually say is to transmit a number all the time, and to then just increment that number when something happens. It's then easy to detect on your IoT hub.

    This might help you out quite a bit as it uses sending a button press as an example: BLE Advertising with Node.js/Python/C#/Android

    I should add that Puck.js doesn't have an accelerometer - it's a magnetometer (effectively a 3D compass). It's still pretty easy to use it to detect movement though as any rotation would change the compass reading.

    There's a post here:­301185/

    But basically you want some code like:

    var avr = Puck.mag();
    var magDiff;
    var hadMoved = false;
    var moveCounter = 0;
    Puck.on('mag', function(xyz) {
      // work out difference in field
      var dx = xyz.x-avr.x;
      var dy = xyz.y-avr.y;
      var dz = xyz.z-avr.z;
      magDiff = Math.sqrt(dx*dx+dy*dy+dz*dz);
      // update average
      avr.x += dx/2;
      avr.y += dy/2;
      avr.z += dz/2;  
      var moved = magDiff > 50;
      if (moved && !hadMoved) {
        NRF.setAdvertising({},{manufacturer: 0x0590, manufacturerData:[moveCounter]});
       hadMoved = moved;
    // Turn magnetometer on

    But I'm afraid at the moment that's not something that you could do with the graphical editor - it'd have to be JS.


Avatar for Gordon @Gordon started