How to use HRM-env event?

Posted on
  • I've been doing some quick tests on my Bangle running 2v19. However, I'm not sure what the output of this event is supposed to mean. All I get when I run this is zeros. Is this expected functionality?

    Bangle.setHRMPower(1);
    Bangle.setOptions({hrmPushEnv:true});
    Bangle.on('HRM-env', function(env) {
        console.log(env);
    });
    
  • On mine, if the watch is on its back I see it reporting 1 when there's nothing there (eg the green LED ends up being off) and 0 when I get my hand close to the sensor. If I shine a torch at it or point it towards the window, the value rises.

    The real use it for something like the flash counter though: https://banglejs.com/apps/?id=flashcount­

    For that you have to manually configure the sensor to run faster and to turn off the green LED:

    Bangle.setOptions({hrmPollInterval:5});
    Bangle.setHRMPower(1);
    Bangle.setOptions({hrmGreenAdjust:false,­ hrmWearDetect:false, hrmPushEnv:true});
    Bangle.hrmWr(0x10, 197&0xF8 | 4); // just SLOT2
    Bangle.hrmWr(0x16, 0); // force env to be used as fast as possible
    Bangle.on('HRM-env', function(env) {
        console.log(env);
    });
    

    So then it'll run nice and fast (200Hz in that case) and you could use it for some kind of sensing or communication

  • I'm trying to implement some type of wear detection by pulling the environment data. Maybe I'm misunderstanding how the watch does it. Do I have to rely on the other sensor to detect if something is close to the watch? I cannot replicate getting a one. Only zeros when I run the code above. I can get numbers above zero by shining my phone's flashlight, but this isn't useful for my use case.
    I've been looking at this code snippet from the source code. https://github.com/espruino/Espruino/blo­b/master/libs/misc/hrm_vc31.c#L376

  • Ahh, ok - then actually all you need is:

    Bangle.on("HRM-raw", h => {
      print(h.isWearing);
    })
    Bangle.setHRMPower(1)
    

    The isWearing value is reported in HRM-raw

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

How to use HRM-env event?

Posted by Avatar for bponce02 @bponce02

Actions