• Hi guys,

    new to the JS2 and smart watches in general, never considered one due to privacy concerns.
    My original intent in getting one was tracking some health related data (pulse, steps) and do a long term observation on it.
    I know it might not be 100% accurate but as long as I use the same device its relative values are comparable.

    To that end I am planning on exporting my data to a tsdb and display on Grafana since I am just not an phone/app person (too old probably).

    I will be following https://github.com/simonedesogus/XiaomiM­iBand5Dashboard basically and am taking the first steps now (since I got my JS2 just yesterday).

    I have installed Health Tracking and configured a 3m interval, i autosync that to Gadgetbridge every couple of hours (as per Gadgetbridge setting)

    So with that goal declared, a couple of questions:

    1. I was under the impression that the JS2 would cache data at night to be synced to the (Android) phone in the morning. However, data stopped being gathered as soon as I turned off bluetooth last night.
      Expected behavior or a misconfiguration?

    2. I looked at the sqlite3 file I am saving my Gadgetbridge data to and it contains significantly less data then I expected. It has 49 rows and should have sampled from like 12 am to 12pm yesterday.
      I'd expect 20 data points per hour given the 3m time interval.

    Now this might be a Gadgetbridge issue or it might be a JS2 issue - if the former I'll have to ask them o/c.

    1. The table (Bangle_JSActivity_Sample) also seems to contain less columns that i expected (basically only steps, raw_kind and heart_rate. This might be everything Health Tracking saves, but I might consider adding environment data (air pressure, temp) to it and I wonder where would that go?
      Given that the table structure seems fixed (based on a bunch of other tables for other device being defined) it might actually not get exported?

    Thanks for any pointers you can give.


  • Hi,

    I was under the impression that the JS2 would cache data at night to be synced to the (Android) phone in the morning.

    There are a bunch of threads on this but basically the Bangle stores the info but there is no syncing right now.

    If you just want the data it's probably worth just going to https://banglejs.com/apps/?id=health when connected to your Bangle, and downloading all the health data direct from the watch as a CSV file. No need for Gadgetbridge at all.

    it contains significantly less data then I expected.

    The health app on the Bangle only stores data every 10 minutes. The '3 minute' option is for the heart rate - it'll take 3 HRM samples every 10 minute slot and use the best/average value of HRM readings - but it only stores one reading per 10 minutes.

    If you want more than every 10 minutes and more useful data, you'd be better off just using the recorder app on the Bangle: https://banglejs.com/apps/?id=recorder

    You can configure that to store all kinds of data, and at whatever interval you want (even down to a second). You can then download that data off the watch in CSV (or other formats)

  • Hi Gordon,

    very well, will give the Recorder a try, thanks.
    I assume there is no way to automate saving the data via the app manager?

    Is there a way to track free disk space outside the App Manager?
    That might be a nifty feature to display in the Recorder app (or alternatively provide an expected fill up duration based on selected datapoints, interval and current free space:) (especially since the default value is 10s which sounds nice but I am sure will fill up the watch in hours, not mentioning battery).
    Alternatively a widget might be even better so that we can keep an eye on it regardless of which app is saving data

    Also, is there a way to connect the JS2 to multiple bluetooth devices at the same time?
    Newer Bluetooth versions are capable, but not sure whether BLE can do it.

    Reason is that i have multiple Bluetooth capable devices and saving the recorder date to a windows or linux box directly (opposed to save on Android initially) would save me a step and also might enable me to implement a simple automation on the save button.

    Edit -
    ok looks like I misinterpreted the Recorder ... 10s was the duration it is logging data for, not the interval at which it records it seems.
    At least I tried activating record twice and both time it turned off again and I now have two tracks with a duration of 10s each...
    You said I could define the interval, but there is no option for it, nor for the temperature mentioned in the manual. I run v0.23, maybe there is a beta that has more functionality? Cant seem to find it though.

  • You do realize, that you can access the Bangle with e.g. python/bluepy and execute any command, e.g. require("Storage").read() on it?

    It should be possible to boot service/widget record the data and download later with these commands.

  • Nope, thats good to know, thanks.
    So even more reason to connect to a proper OS over Android :)

  • I think the About page on the Bangle shows free space, but honestly it's not such a big deal. Maybe each line of data uses 40 bytes, but the Bangle has 8 megabytes - so recording every 10 seconds that's over 23 days of recording 24 hours a day.

    Also, is there a way to connect the JS2 to multiple bluetooth devices at the same time?

    Yes - well, you can connect to the Bangle, and the Bangle can connect to 2 other devices (eg heart rate monitor) all at the same time.

    If you want to connect to the IDE and to Gadgetbridge then that feature has just been added: https://forum.espruino.com/conversations­/386264/#comment16973189

    saving the recorder date to a windows or linux box directly (opposed to save on Android initially) would save me a step

    Perhaps the easiest is to fork the app loader (https://github.com/espruino/BangleApps) and enable GitHub pages, then change the settings in Gadgetbridge so it loads your version.

    Your version of the App Loader could then read all your data and sync it with an HTTP POST to whatever server you wanted whenever you clicked the App Loader icon in Gadgetbridge.

    10s was the duration it is logging data for, not the interval at which it records it seems.

    it records one data point every 10 seconds.

    At least I tried activating record twice and both time it turned off again

    So you just tapped the box next to the text RECORD once and you're saying it automatically turned itself off after 10 seconds? I just tried it here and that's not what happens at all.

    You said I could define the interval, but there is no option for it

    It's called Time Period

    nor for the temperature mentioned in the manual

    I'll update the docs to make this clearer - for Core you need to install the coretemp app. OR... Turn on Log Baro and it'll use the built-in barometer to record Temperature, Pressure and Altitude

  • Some updates...

    1.Using the app recorder seems to work quite well now after the initial problems which were probably user error.
    I had some issues with battery drain initially but I was able to pinpoint that to the Light Switch Widget that caused the screen to turn on/off all the time.

    2.Running two active Bluetooth connections does not work for me, but disconnecting from the phone and then connecting to the laptop works fine. Sometimes I have to delete the connection and reconnect, but have not identified a reason yet, and its a quick solution so no problem.

    1. I tried remote connection, that didnt work at all. Tried same wireless and via Internet. The latter might fail due to firewall if its using some non standard ports (ie not 443)
    2. Gadgetbridge (0.71-2a-BangleJS) is not working properly any more for steps & sleep, but is still able to show battery and load files. But really a topic for another thread when it gets annoying. Its also not really able to save the recorder files, but I dont need them on the phone anyway.
    3. I can now save the recorder files to the laptop, so my next step is to convert them to values i can ingest to influx or prometheus... Excel threw me off at first since it really butchers these values, but looking at the raw text resolved those issues.


  • Running two active Bluetooth connections does not work for me

    No, that wouldn't. Bluetooth has the idea of a device that can be connected to and one that connects. Bangle.js can connect to 2 other devices, but it can only be connected to by one at a time.

  • Ah I see. Thanks.

    Spent time on the weekend on a script to parse data to be read into influx for Grafana... still some things to iron out but progress at least...
    For now I have/run Health App, Recorder and Sleeplog. Sleeplog is not working well for me, but have not found out why. Maybe need to tinker with thresholds, but its not clear to me what the "movement value of the built in health event" means, or rather how I would go and measure what is a normal value for me.
    Is there an app that lets me save those values for a night so i can determine what is light sleep/deep sleep?
    I can see bed movement on recorders step counter which is nice although not entirely correct (not really a step;)).

    Makes me wonder if there is more data to be had from other sensors;)
    Maybe accelerometer? But thats probably not particularly useful being 3 dimensional...

    1 Attachment

    • JS2Grafana__Recorder_Steps and Heartrate.JPG
  • Is there an app that lets me save those values for a night so i can determine what is light sleep/deep sleep?

    Yes - the health app :) If you extract the data from that using the app loader there's a column called 'Movement'. This is actually the value from the health event movement divided by 8 - so it should be easy enough to work back

  • Oh thats convenient since I already have that :)

    So, those margins seems to be quite tight, or I am not a good example (rather light sleeper).

    What I'd consider deep sleep runs between 17 and 22, and at 25 basically I am already awake (based on times). That might o/c be impacted by the 10m interval for the health data measurement.
    Or that I dont have much of one would consider deep sleep in the first place if I look at the regular deep sleep value of 100 (so 12.5 which I never reach)...

  • Ok, that's interesting then - is it repeatable day to day?

    There's the 10 minute interval, but the movement value is the movement summed up over that entire 10 minutes (not an instantaneous measurement) so you'd hope it was quite reliable.

  • Yes, looked at older data and its always the same.
    O/c I do have movement values of up to 100 too during the day so that's not the entire range, but the only range that applies to me sleeping.

    Sleep value was 19, the small peak at 01:10 was 23 and the big peak at 3 was 56. Dont ask me why I was up in the middle of the night :/

    Bottom Graphs are from recorder, upper one is Health app. Thought it interesting how the same data looks different giving the different aggregation levels (60s vs 10m)

    1 Attachment

    • banglejs2_movement.png
  • That's great - thanks for that graph. It does seem like it's quite 'close' extracting sleep + not sleep. I wonder if there's anything we could do better.

    Also makes me think that we could potentially have a '60s health' event if that was useful - it wouldn't be too hard to do, and might give apps like this a lot finer-grain data to work with if it's useful?

  • Well I am all for more data (while its not a huge drain on the battery or user configurable).
    In this case were the data is captured anyway (i think if it sums up all intermittent values?) it probably increases accuracy significantly.

    I mean sleep tracking was one of the main reasons I got a smartwatch for in the first place:)

    Now what can be done about identifying sleep or not probably depends on how common a tight boundary really is. If most people have a clearer cut off between the two states then I am an outlier and could be treated as such. If its common then at least the initial values should be adjusted and the potential range tightened (or better documented)

    We need more data;)

  • You could for example test the existing algorithm against https://ubicomp.eti.uni-siegen.de/home/d­atasets/ichi14/index.html.en which SleepPhaseAlarm is using.

  • To do that we probably would need to match their acceleration data against acceleration data from the JS2 since thats probably the only common denominator. Then we could map the current values to their values/sleep levels.
    Not done in 5 minutes;)

    I do like that they go top down ( 0 = unknown, 1-3 = sleep stages 3-1, 5 = REM, 6 = awake, 7 = movement), it looks weird to be awake at 0 and sleep at 4 in the current log data;)

  • Sleep Log seems to be quite unreliable...
    Just downloaded the current file and only got two entries, starting at 2pm today.

    The previous file in the app ends 2 weeks ago.
    I never press delete (yet), I only ever download file.
    I have downloaded files before between these (now nonexistent) times and data was present, or in binary, or not present for times... no pattern really :/

    1 Attachment

    • Bjs_sleeplog_1.png
  • I wonder how you are getting on with sleep log data 4 months on?

  • Sorry for the delayed answer...

    I basically stopped getting data off the js2
    Between unreliable apps and imprecise values I lost interest at some point

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

Beginners Question ... Logging & Exporting data

Posted by Avatar for Rand__ @Rand__