11 years ago.

Possibility of ms and UTC+1?

Hi.

I tried your NTPClient and it works perfecty. Now i have two questions to use it for my own needs.

I record analog values with the mbed and send it via UDPconnection. I want to create a timestamp for each value. There are about 40 values per second, so it will be great if there is the posssibility to add microsecconds to the timestamp, is it possible? Another problem is, that i need the "UTC+1" time, not the UTC. Of course it is possible to maipulate the time string, but is there any other possibility to get the UTC+1 instead of the UDP.

Thank you in advance for any answer. Best regards.

Question relating to:

1 Answer

11 years ago.

Regarding the timestamp, I would just run a Timer in parallel that you reset at the beginning of each second, then you can read the timer to get the ms timestamp (and of course take into account since the timer is a bit less accurate it is possible it counts a bit further than 1 second in one RTC second, so your code needs to be able to handle that).

For some shameless promotion of one of my libraries: http://mbed.org/users/Sissors/code/RTC/. You can use that to attach an interrupt that resets the timer every new second.

Accepted Answer

Thanks for that answer. I think this is an acceptable solution. At the time i implemented a counter which counts from 0 to 39 to make the UDP-Packages within one sencond identifiable, but this is a quite better solution.

Any solutions for the UTC+1 problem?

posted by Stiff Master 26 Apr 2013

I haven't used one the NTPclient myself, but I just had a random thought. If you add directly after NTP update (you could also add it in the library itself when it sets the time, but probably nicer to keep that intact):

set_time(time(NULL) + 3600);

Then you simply move your clock one our forward compared to the time the NTPclient just set (probably a good idea to check if the NTP return code is positive before doing it). And the RTC code of the mbed will calculate all stuff again for you such as day, month, etc.

posted by Erik - 26 Apr 2013

problem is, NTP return code don't work. unplug the cable and it still returns 0

posted by Thomas Olsson 03 Jan 2014