How to reset system clock over BT Serial #5404
Replies: 1 comment
-
Posted at 2016-08-01 by @gfwilliams Yes, the Instead, you can use the Just make the first argument the number of seconds since 1970 and you're good to go! Posted at 2016-08-07 by CoffeeCups My IDE is set to transfer my computer time to my Espruino (Settings/Communications/Set Current Time), as long as I have a battery installed at the same time, I can unhook USB and continue with Serial1 on Bluetooth (HC-05). The problem is the time transferred is GMT without TZs or Summer Time adjustments. This leaves a 2 hour gap in my case. i.e. My computer tells me it is 15:00 hrs, but 13:00 hrs gets transferred to my Espruino. Now, maybe there is something in the guts of my computer I can change, but I doubt it. So I made this for now, posting it here in case anyone else is searching for a work-around.
As I cannot believe that I am the only one who wants (almost) correct time sync with their devices I will ask : Any chance the IDE Set Current Time setting can have a GMT +/- hour diff option? OR maybe I have missed something? Posted at 2016-08-07 by @gfwilliams Yes, it wouldn't be too painful for someone to add this However perhaps timezone support in Although (and one of the reasons I've been slow to do this) - I'm unsure how Daylight Saving Time would work. Last thing I want to do is to add all the calendar offsets for each timezone into Espruino. Perhaps just a module called Posted at 2016-08-07 by CoffeeCups I see your point. Yes, the Daylight Saving (DST) would be a pain -- I even wonder if that would be worth the bother. As my device returns to base or gets in BT range I was going to reset the time as the argument in that func applies negative figures. I suppose as more devices are made wifi or LoRa capable then this need would diminish anyhow. Brilliant piece of kit all the same. Posted at 2016-08-07 by tve Something I do with the esp8266 is to sync the clock to UTC using NTP and then receive periodic MQTT messages with the TZ offset. By separating the two I end up with a nice monotonic UTC clock for calculations and when I want to display time I add the TZ offset. Sync'ing the TZ offset is not time critical, so no special protocol necessary (I happen to use MQTT). Posted at 2016-08-08 by @allObjects @tve, great solution - (another) excellent separation of concern(s)! (as another discussion about separation of concerns). Posted at 2016-08-15 by @gfwilliams Just a quick idea - if you have WiFi access, I just grab the Posted at 2016-08-15 by DrAzzy Hmm... See, I've got a computer that has the clock set to the wrong time zone and the wrong time, such that it thinks it's in the UK and set to the time it's currently set to in the US. Needs to be corrected every couple months cause the clock drifts since I can't sync the time. That is running a webserver that returns the current time using a PHP page. It sucks - I recommend doing it some better way. I'd love to move the stuff on that system onto the raspberry pi. How do you put in a time-zone offset? I get time like this - but I can't figure out how to adjust the time that it gets from the server.
Posted at 2016-08-15 by @gfwilliams Once you've parsed the date into a Date object, it's got a Posted at 2016-08-15 by DrAzzy I don't parse it to a date object, I just feed it to the Clock constructor... ? So what I need to do is create a Date, a new clock with blank time, and then parse the string to a Date, and then adjust the ms field of Date, and then pass that to setClock? Posted at 2016-08-16 by @gfwilliams The clock module actually just passes arguments on to
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2016-08-01 by CoffeeCups
Espruino 1.4 flash v1.86 / 262144 I have the Serial over BT working fine, my question is when my board is deployed, how can I fine tune the system clock?
I think I understand I can send the exact time when I send my code over to the board by clicking the correct IDE setting, and could add hours on to adjust for daylight saving or TZs etc.
My concern is if the battery is changed/disconnected how would I go about sending the correct time and date to the system over BT?
I read about Clock but I have doubts that this var eg clk is just that, a var I keep persisting, or does it indeed update the system clock?
Beta Was this translation helpful? Give feedback.
All reactions