How does Bangle synchronize time

Posted on
  • So, while waiting for my Bangle to arrive, I am wondering how it actually keeps track of the time.

    I don't see an RTC in the specs. Does the micro have sufficiently precise oscillators to keep an accurate time without too much drift? Or does it actually need to get a GPS fix every couple of hours to get its time from space? Or is using a smartwatch to show the time just too crazy an idea? :D

  • Hi,

    The microcontroller itself has an RTC built in. While there's no external low-speed oscillator, there is a high speed oscillator and the microcontroller uses that to calibrate the internal low-speed oscillator.

    Bluetooth Low Energy demands a certain level of accuracy of the microcontroller, and that tends to be more than good enough for a clock.

    But... since there's a GPS receiver, that itself has a very accurate clock in it too, so while Bangle.js doesn't request the time from it (unless it's had a cold reboot and lost the time) it'd be pretty easy to poll it every so often.

    ... also if you're using Gadgetbridge you can sync the time automatically with that too, but it's really not needed

  • There is also GPS Time app that can sync time from GPS on request.

  • Cool, thanks!

  • On a BTN1+BTN2 reset / boot there is a message 'getting GPS time'. What is happening when this message comes up ?

  • When you do a hard reset like that, Bangle.js loses the time.

    However, if you'd ever had a GPS lock in the past, as long as the battery didn't go flat the GPS receiver has the current time on it.

    So when Bangle.js starts it sees the time isn't set, then it asks the GPS receiver if it has the time, and if it does, it uses it.

  • Really nice feature.

  • How does one set the time (or especially timezone) in an Espruino environment?
    new Date() is almost always wrong for me, either because offset is 0 or because actual time is wrong.

    Note that I have a pico, but that shouldn't matter as I'm asking how to do this, but for Espruino, not Linux.

  • You can use all the methods of the Javascript Date object I believe, but obviously you need to know what the actual time is. Since a Pico does neither have a battery-buffered RTC nor a GPS it has no way to set the time automatically or store it permanently. Bangle only does it as long as the battery is connected.

    The only (simple) way is to synchronize the time from a PC that it is connected to, but you would need some software on that PC that does it. The Espruino Web IDE does that I believe, but again, the time would be lost once your Pico is unplugged.

  • When you upload code via the IDE it should attempt to set the time with setTime and timezone with E.setTimeZone() using your PC's settings (unless it's been disabled in the IDE settings) - you could do the same yourself. Especially when you're uploading code, nothing stops you from sticking E.setTimeZone(4); to the top of your code to ensure the date functions all use the correct timezone.

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

How does Bangle synchronize time

Posted by Avatar for Sebastian @Sebastian

Actions