This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF Connect SDK: How to get the system timestamp(epoch time) on nRf52840dk

Hi nRF support team,

In my application, I need to show system date and time, so I am trying to get the system epoch time by using the nRF Connect SDK on nRF52840 dev kit.

Can you please let me know, what needs to configure to get the system epoch time OR sample code to get system epoch time?

Thanks in advance.
Regards,
Kalyan

Parents
  • Kalyan,

    You might want to look at https://github.com/NordicPlayground/nrf5-calendar-example

    To do this "right" you need to get the time from an internet connected device that accesses the time server(s) and sets the RTC.  I've downloaded the time from a USB connected terminal (TeraTerm) which has the capability of sending the system time to the UART connection via running a simple macro.  Not sure something like this works for you, but once you set the time the RTC will maintain it fairly effectively (as long as power is on).  I've also downloaded system time from a BLE connected Android tablet, but that used a custom BLE service to send time from the tablet.

    Note there's a transmission delay setting the time this way, so it will be slightly off but not by much.

    Max (online user, not a Nordic support person)

  • I agree with on this one. You can use something like the RTS (Real time service) to fetch the current time, and then use the RTC (real time counter), which is not the same as a Real Time Clock. Whenever the nRF is not running, it does not keep track of time. That would require that the RTC is running, which it is not when it is powered off. Basically, whenever the application is starting from scratch, the nRF has no way of knowing what time it is before checking with a device that either is connected to the internet, or that has an RTC

    Best regards,

    Edvin

  • Hi Edvin, Maxx44,

    Thanks for the clarification.

    Can you please share the working sample code to get system epoch time from Zephyr or nRF connect sdk.

    Regards,

    Kalyan

Reply Children
Related