Details
This is just the code you could use for making a step counter. Use a CODE node, and change the code that's set in it. Yo... This is just the code you could use for making a step counter. Use a CODE node, and change the code that's set in it. You can change the sensitivity as well. More
Pinned Items
Recent Activities
  • larissa
    Post is under moderation
    Stream item published successfully. Item will now be visible on your stream.
  • larissa
    larissa
    Try this as the code:

    // last measured value
    var measured = msg.payload;

    // calculate average (as comparison) with previous values
    var alpha = 0.05; // how much weight do we give the last measured value in our average?
    var avgPrev = flow.get('avgPrev')||0;
    var avgNow = alpha*measured + (1-alpha)*avgPrev;
    flow.set('avgPrev', avgNow);


    // compare measured value to average
    var sens = 0.2; // sensitivity (try 0.2 for motion, 0.02 for pulse)
    if (measured-avgNow>sens*avgNow) { // more than 20% larger? defines threshold event
    var send = { payload : "Step! Threshold was crossed"}; // output value from counter
    return send;
    }
    Post is under moderation
    Stream item published successfully. Item will now be visible on your stream.
  • larissa
    larissa
    Post is under moderation
    Stream item published successfully. Item will now be visible on your stream.
There are no activities here yet
COM_EASYSOCIAL_POPBOX_ERROR_UNABLE_TO_LOAD_CONTENT
Be the first to get yours.
© STEMgem