Bangle.js time steadiness

Posted on
Page
of 2
/ 2
Next
  • Overnight, when the watch was "sleeping," its clock seems to have gained about 2 seconds. Through the day it gained another 2. Sometimes it's behind, sometimes ahead. I haven't determined the conditions under which the changes occur. I'm looking at the morphing clock and comparing it to an electronic clock I know is accurate.

    Possible causes? Remedies?

  • Sometimes it's behind, sometimes ahead

    But on average it's not actually drifting off?

    Do you have anything other than the default widgets installed? It's possible that something is delaying its rendering of the time.

    Also worth noting that most clock faces will actually just update the screen once every second after the screen has powered on. The actual time shown on the screen won't change exactly on the second, it'll change exactly 1,2,3,4,5 seconds after the screen was powered on, so could be as much as 1 second off. Could that be what you're seeing?

  • Default battery and Bluetooth are the only installed widgets.
    Over the second 24 hours, the watch gained another 2 seconds or so, totalling about 6 seconds ahead of real time after two days. (Both the morphing clock and my Dozenal Time are ahead by the same amount, no surprise there.)
    The watch hasn't been behind in several days. Deliberately I'm not removing or reinstalling or changing anything else, to see what happens.

    The GPS time-setting app and two alarms are installed but haven't been in use.

  • I think that's probably about what you'd expect. Most crystal oscillators are rated at around 20ppm (parts per million). From Wikipedia:

    Typical crystal RTC accuracy specifications are from ±100 to ±20 parts per million (8.6 to 1.7 seconds per day), but temperature-compensated RTC ICs are available accurate to less than 5 parts per million

    In a day you have 60*60*24 = 86400 seconds. So to keep accurate to within 1 second you need a 12ppm crystal. If you're seeing 2 seconds then I guess that's about what you might expect from a 20ppm crystal.

    Even with a separate temperature-compensated RTC you'd still be looking at drifting by maybe 0.5 sec a day.

  • Might an app be developed to record a reference time setting and pull the Bangle close to that when it drifts by a certain amount? I suppose that's asking a wayward crystal to monitor itself and is impossible, unless there's an external way to keep track of the seconds, such as connecting to wifi or a cellular phone tower. A GPS setting would correct the time but is a battery-intensive and cumbersome corrective.

    Suggestions welcomed.

  • The GPS have a real time clock inside it - so you could compare with the time for that. Turning it on for literally just 1 second (to get the time off it) and then turning it off once an hour won't hurt battery life noticeably - it wouldn't be getting new time from satellites, just telling you what time was in the GPS RTC.

    It'd be worth doing some comparisons but because GPS is so time critical, the GPS chip might have a better (temperature corrected) RTC.

    Another thing you might be able to do is perform your own temperature compensations - so put the Bangle somewhere warm with constant temperature and measure how fast it runs, then put it in a fridge and do the same, and I guess you might be able to use that to do some manual compensation. I have no idea how good it'd be though.

  • Which GPS app may you be thinking of? One that doesn't have to access a satellite but (on request or automatically) will reset the watch's time.

  • I wasn't specifically thinking of an app, you'd have to make one.

    Something as simple as this should do it:

    setInterval(function() {
      Bangle.on("GPS",function cb(g) {
        Bangle.setGPSPower(0,"time");
        Bangle.removeListener("GPS",cb);
        if (!g.time || (g.time.getFullYear()<2000) ||
           (g.time.getFullYear()>2200)) {
          // GPS receiver's time not set
        } else {
          // We have a GPS time. Set time
          setTime(g.time.getTime()/1000);
        }
      });
      Bangle.setGPSPower(1,"time");
    }, 60*60*1000);
    

    You could actually paste that into the custom boot code app and I think that'd do it

  • Thanks for the continued help! I'm not completely sure what that does, nor the order in which to do these four things:

    load custom boot code with that script
    set watch by GPS
    press BTN3 to put away GPS
    go to clock

    Is it necessary to set the watch using a GPS app? Also, how do I make sure the script stays loaded in the watch?

  • I don't really understand. All you need to do is:

    • Use any app that uses GPS enough to get a GPS lock so the GPS gets the time - maybe 'GPS Info'
    • Go to https://banglejs.com/apps/#custom%20boot­
    • Click the 3 bars icon to the right of it
    • Paste in the code above
    • Click 'Upload'

    Now the code will always stay loaded in the watch

  • Good, thanks. I will redo the whole process in case I've done something wrong, and continue observations.

    Regardless, I presume that once in a while the GPS may need to be re-engaged to set the time — and if I ever want to remove the boot code, that I merely upload a blank custom boot script.

  • I presume that once in a while the GPS may need to be re-engaged to set the time — and if I ever want to remove the boot code, that I merely upload a blank custom boot script.

    That's correct, yes

  • I'm still observing, to get a better idea of how steady the watch can be with your script installed. Meanwhile, has anyone else mentioned unsteadiness in its timekeeping?

  • Do the `E.getRTCPrescaler functions do anything to help this is sue for the Bangle, just saw them in the reference.

  • After a few days' trial, it seems to me that the watch still gains almost 2 seconds a day. Because the new script is in custom boot, perhaps I'm missing a boot action to activate it? All I'm doing after the GPS fix and uploading the custom boot is pressing BTN3. (A more serious reboot seems to replace the time with a default time.) I may be missing something.

    Would the script be more likely to work as desired (and not be subject to nullification by a novice) if embedded into the watch's own script?

  • If you are using his script there, then it would be safe to say that you are now testing GPS time. To make your test complete and cover the case that you were using GPS time prior* (cos its built into the boot file naturally), thus meaning you compared nothing. I recommend you test setting the time manually in the menu, and seeing if you get better or worse or same results with that. Make sure to remove the custom boot code you installed. The downside to this method is if you use the 'Turn off' Feature, then your time is lost. Good Luck!

  • Nope - afraid E.getRTCPrescaler is just for STM32s

    (A more serious reboot seems to replace the time with a default time.)

    Hmm. Are you running firmware 2v09 or not? I thought I'd fixed this in the most recent firmwares.

    Would the script be more likely to work as desired if embedded into the watch's own script?

    Maybe... However it should work. Maybe you could add something to the script so you can detect if it's working. Like maybe just add the code _MYSCRIPT_=1 to the end of what you upload.

    Then you can log in with the IDE and see if typing _MYSCRIPT_ on the left-hand side actually returns 1 (it working) or a ReferenceError (it not loaded)

  • (Version 2v09, 7247a2c4 here.) In the emulator MYSCRIPT returns 1, so that's okay. I may still be missing something to activate the script on the watch.

    (Note to d3nd3-o0: thanks for the suggestion. I started off with no boot code and manual setting. Same problem.)

  • When you first set the time with GPS time, does it seem accurate then? It takes always 'periods of hours' to come out of sync?
    If the gps fix makes it in sync, then you know that the script should be the solution. And can assume something is wrong with the script functioning.

    Find out how many exact time it takes to go out of sync, the script he sent was programmed for 1 hour intervals.
    You could try to do GPS Fix once a day?? Or is that not ideal solution for you.
    The time can be set when you connect to the ide. So a solution could exist to connect your watch to the IDE daily or weekly, ofc you can automate this if you can install software or write basic script in linux.

  • Turning it on for literally just 1 second (to get the time off it) and then turning it off once an hour won't hurt battery life noticeably - it wouldn't be getting new time from satellites, just telling you what time was in the GPS RTC.

    Why is this true? If you turn it on, it doesn't get fix, the callback isn't GPSfix related? What triggers the callback, if its not a fix from satellite?
    Edit: Just read something about once a second, so I guess its just spewing same data since last fix every 1 second???

  • The problem may be something I'm not doing, or not doing correctly. Gordon may have a further suggestion.

  • Btw there is GPS clock apps on appstore, which you can click to set time from GPS. Im not sure if Gordon's code actually turns GPS on long enough to get the time. So if you haven't tested gps time which might be the case, if the script did nothing because it never got a fix. Just my 2 cents. I wont' interfere further, hope you get a solution.

  • For the first time, something happened to steady the watch some. At some point in the second half of the day, it appears to have reverted to a more correct time. Not my doing; I didn't redo the GPS fix or reupload the script into the custom boot app. I've merely moved back and forth between my clock and the morphing clock.

    It would be good to know what's happening, even if that's a difficult question. I'll continue to observe.

  • The code that I posted will attempt to correct the time 1 hour after the app loads.

    However if you always change apps before one hour then that code will never fire. That could be your issue?

  • It may be. Even after an hour or more, if I change apps, does the code then cease to work?

    What may I do to ensure that the resetting of the time continues to work? Or what should I not do?

    May code be placed or created that will set the time every hour regardless of changing apps, as long as the watch isn't rebooted?

    I appreciate your continued attention to this!

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

Bangle.js time steadiness

Posted by Avatar for Numerist @Numerist

Actions