Movement data display in Graph and Steps Counter

Posted on
  • Hello Gordon,
    I would like to display in graph all the movement data(moving or be still) and also is it possible to count how many steps i do as i walk?? Also i want to put a password for my puck when it's time to connect with it
    Thanks in advance!

  • Hi - where do you want to display the graph? On a Web Page? If so, the­shboard page is probably pretty useful.

    I'm afraid you can't easily get the number of steps though (without adding a separate accelerometer), but you can use the Magnetometer to get a good idea of when the Puck is/isn't moving.

    To set a password, just use the­tPassword command

  • could you please send me sample of movement function in dashboard and setpassword function also? thanks

  • For movement, there's a thread on it here:­301185/

    Maybe increment a counter based on movement (instead of the LED.write) and then use that counter in the Web Bluetooth example instead of E.getTemperature()

    Use E.setPassword("password") for the password.

  • Last thing please.. Just want to know how to implement this code­301185/ in my web bluetooth dashboard in order to get live graph for every value I get.. Thanks in advance!

  • Something like this:

    var avr = Puck.mag();
    var magDiff;
    var movementCounter = 0;
    var magCounter = 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;  
      if (magDiff > 50) movementCounter++;
      var movement = movementCounter / magCounter;
      movementCounter = 0;
      magCounter = 0;
    }, 60000 /* update every minute */);

    But you then need to remove the whole connection.write("reset();\n", function() { .... part from the Web Bluetooth example.

  • Thanks.. Do I have to put the whole piece of code in my connectDevice() function and get the movement value like that? elements.movement.setValue(j.movement); and then display that in my graph because I tried and i saw nothing to be displayed. Sorry for the inconvenience..

  • try just elements.movement.setValue(j)?

    You could stick it in your connectDevice function yes (leaving the reset() part in and just changing the code it uploads).

    Otherwise you could remove the reset and upload the code to the Puck separately - which would allow you to maybe keep a history of movement in the Puck and initially populate the graph.

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

Movement data display in Graph and Steps Counter

Posted by Avatar for Pzr0 @Pzr0