D5-D6 KX023 accelerometer

Posted on
  • Hi wonderful Espruino folks!

    Whilst I'm waiting eagerly for my Bangle, figured I'd have a play with the D6 bracelet thing I have.

    It has an KX023 accelerometer, but I'm looking for using the device as a sleep and step counter.

    Using an accel as a step counter will drain the battery fast, but I wondered if anyone had attempted this? There's some clever features that I don't really understand of the accelerometer but the datasheet is sparse ( https://eu.mouser.com/datasheet/2/217/KX­023%20Sell%20Sheet_0-542331.pdf ).

    Anyone used this particular part and got any tips?

    Cheers,

    --
    Martyn

  • Fri 2019.11.29

    '. . . but the datasheet is sparse'

    Hello Martyn @iMartyn and thank you for posting the link to the datasheet.

    From that, I grabbed the URL (bottom p.1) to that company and opened the DDL for 'Developers':

    https://www.kionix.com/technical-documen­ts

    and scrolling down, found the detail datasheet for the KX023 (nine references total)

    https://d10bqar0tuhard.cloudfront.net/en­/document/AN041-Getting-Started.pdf



    Google'ing 'using the kx023 as a step counter'

    yielded this paper with pseudo code:

    https://www.mdpi.com/1424-8220/18/1/297/­pdf

  • Using an accel as a step counter will drain the battery fast

    For using it as step counter (which is why it is in the device) it probably helps to use the buffer and interrupt and set the performance mode so it does not produce so much data. Then the main CPU can sleep most of the time. Original firmware lasts week or more in this mode so it is not so bad for the battery.

    I haven't used it for step counting yet but I tried the tap and doubletab features which can automatically guess that you hit the tracker from some side (once or twice) which can be used as additional buttons (check more info and code in this github issue)

    Now I am actually trying to sync DS-D6 build with all the new stuff for bangle.js including tensorflow. That could possibly be used for step counting too instead of some random guesswork which movement means one step.

    Tried yesterday evening and currently the build with tensorflow is too large to fit (by some small amount) so I need to trim it down a bit. I am also working on procedure for moving the bootloader so there is a bit more space (it takes 24KB now, can fit into 12KB and be moved by 12KB up).

  • @fanoush

    I tried the tap and doubletab features which can automatically guess that you hit the tracker from some side (once or twice) which can be used as additional buttons

    Nice and extremely creative! I like that very much.

  • Hey @fanoush, great that you're active here. To reduce the power drain, does espruino on the D6 use deep sleep at all? I'd like to use setTimeout() but if there's a better way for battery life, I'd love to know. If we can get to the same level (1 week on battery) as the stock firmware, that'd be incredible!

  • Sun 2019.12.01

    This suggests automatically:

    http://www.espruino.com/Reference#l__glo­bal_setDeepSleep
    Description: 'This only works on STM32 Espruino Boards (nRF52 boards sleep automatically)'

    https://github.com/fanoush/ds-d6/wiki/Es­pruino
    https://github.com/fanoush/ds-d6/tree/ma­ster/espruino

  • does espruino on the D6 use deep sleep at all?

    yes, on nrf5x platform it works automatically out of box, it sleeps almost always. I got to the point that my simple watch app checking for button (and RX pin of serial console) lasts 30-40 days just sitting on the table with bluetooth advertising on (= default state).

    You can verify it by setting busy or sleep indicator (not sure what is the difference)
    https://www.espruino.com/Reference#l__gl­obal_setBusyIndicator
    https://www.espruino.com/Reference#l__gl­obal_setSleepIndicator
    temporarily to pin 25 which is vibration motor and see how long it vibrates when you interact with the watch.

    However recently I tried espruino bootloader made for SDK12 and Softdevice 3.1.0 and I don't see such great power management with that now. I have same build of (latest) espruino for SDK11 and SDK12 and with exactly same javascript code the one with SDK12/SD3.x lasts days while SDK11 lasts weeks so I am investigating what is different. It is built from same git source the only difference seems to be the SoftDevice. I also tried to call NRF.sleep() on SDK12/SD3.x and it still discharges faster than SDK11 with advertising on. Will need more tests, maybe that DS-D6 used has already worse battery (it is the first DS-D6 I got). I don't have any measurement tools for such low currents so I just keep some idle on my desk and check battery voltage after few days.

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

D5-D6 KX023 accelerometer

Posted by Avatar for iMartyn @iMartyn

Actions