• I was playing a little bit with the watch to see if there way to improve isWorn accuracy and I notice that the HRM turn off quite fast when it's lose contact with an object and turn on immediately when it's in contact with an object.
    I guess there is some sort of proximity sensor in the HRM module, is there any way to access this information to use it for the isWorn method for example ?

  • Try same in a dark room. If I remember right it will not turn off there. So I think its only the brightness that is measured.
    That can be beneficial for isWorn, but only in one direction: not worn if bright, but unknown if dark.
    And yes, those values are readily available. (eg see https://forum.espruino.com/conversations­/384077/#comment16877590)

  • Thanks. For me it does turn off in a black room, it turn on a bit at the very beginning then turn off. I tried it in a dark room in front of a mirror and then it doesn't turn off. It's probably darkness that is measured but then it wait for to get light back from the green light led and if not it assume it's not worn

  • There is an IR led and sensor, so the HRM measures if the light from the IR LED is getting reflected back to it. It should be a pretty good indicator of whether the Bangle is against something - but obviously if the Bangle is on a hard surface it'll say it's worn when it's not

    Which isWorn function are you referring to? the field in HRM-raw, or something else?

  • The one in the wear_detect module. But I though about it and I will probably go on a totally different direction.
    I think I will make an app with just a boot.js and a lib.js that can be use by other apps to get wear states (resting, light activity, sport, light sleep, deep sleep, notworn, unknown). The app will listen to some events, sensors, etc and based on these event will update the current wear state

  • I think I will make an app with just a boot.js and a lib.js that can be use by other apps to get wear states

    Ok - that was the idea of the library though - you could probably still modify the library such that it would do what you need? That was the whole point of having it

  • I think the best way to do it is with a "state machine" so it need to have a memory of the previous state to switch states and it need to be able to turn on some sensors for a bit.
    For example if the state is unknown it could turn on the HRM sensor for a bit to get a new value and then compute a new useful state.

    I am not sure if all this is possible within the module only or if an app is needed.

  • I think it should be fine within the module? Ideally it wouldn't take that long to work out (if an app was just started you're more likely than not wearing the watch), so you wouldn't need to save state between apps and could do what you need in the library.

    That's one of the reasons we have isWorn returning a promise - so it can go away, turn on the HRM (for example) and then return true/false when it has an answer

  • The goal would be to be used by apps that run in the background too such as activityreminer, sleepphasealarm, sleeplog, ect.

    The need for the previous state would be to know if it can go from one state to another. It makes no sens to go directly from "sport" to "deepsleep" for example.

    I do understand that isWorn is good as module and I could improve on it to add the HRM stuff but but more complex states I am not sure it's the right approach.

  • Maybe implementing calculations, averaging, sensor fusion or whatever else is needed for the state changes is best done in a library. Then build an app or widget around that library which is able to keep state all the time and handles persisting on reloads etc..
    Some months ago I had implemented a version of the van Hees method for detecting inactivitiy by checking changes in the direction of accelerometer values. Maybe you can use that or parts of it. https://github.com/halemmerich/BangleApp­s/blob/libvanhees/apps/libvanhees/lib.js­

  • Ahh, ok - I had assumed you just wanted to detect if it was worn or not - but yes, then an app that provides the activity detection might be best, and it can provide a library to get the current state. There is a method for apps to 'depend' on a module, so maybe in future someone else might want to contribute a different activity tracking app and people could switch between them.

    Bangle.getHealthStatus provides a 'movement' field that might help too - if you can avoid leaving an accelerometer handler running all the time that would be preferable as it will hurt performance of other apps and kill the battery.

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

Proximity sensor in the HRM and way to use it for isWorn?

Posted by Avatar for Stiralbios @Stiralbios

Actions