Hi,
I want to get current time for thingy91 in asset_tracker application.
Could someone please provide me a sample or hint on how to get it.
Hi,
I want to get current time for thingy91 in asset_tracker application.
Could someone please provide me a sample or hint on how to get it.
Hello,
My apologies for the late reply.
You can read the time using the AT command: AT+CCLK? In your AT_CLIENT, simply enter this command to get the output as described in link.
To use the AT command in i.e. asset tracker, please add the following after modem_configure() (line 1015) in nrf\applications\asset_tracker\src\main.c
k_sleep(1*1000); ret = at_cmd_write(ATcmd, response, sizeof(response), NULL); if (ret == 0) printk("%s\n", response); else { printk("CCLK err: %d\n", ret); }
Where k_sleep is a delay to ensure that your application is connected to LTE network, i.e. ensure that you get CEREG: 5 – Registered, roaming before calling CCLK.
Here is my output2019-12-16T11:46:46.018Z DEBUG modem << Connecting to LTE network. This may take several minutes.
2019-12-16T11:46:47.378Z DEBUG modem << +CEREG: 2,"76C1","014ACE00",7,0,0,"11100000","11100000"
2019-12-16T11:46:47.438Z DEBUG modem <<
2019-12-16T11:46:48.364Z DEBUG modem << +CEREG: 5,"76C1","014ACE00",7,,,"11100000","11100000"
2019-12-16T11:46:48.426Z DEBUG modem << Connected to LTE network
2019-12-16T11:46:49.371Z DEBUG modem << +CCLK: "19/12/16,11:46:33+04"
Kind regards,
Øyvind
Hello,
My apologies for the late reply.
You can read the time using the AT command: AT+CCLK? In your AT_CLIENT, simply enter this command to get the output as described in link.
To use the AT command in i.e. asset tracker, please add the following after modem_configure() (line 1015) in nrf\applications\asset_tracker\src\main.c
k_sleep(1*1000); ret = at_cmd_write(ATcmd, response, sizeof(response), NULL); if (ret == 0) printk("%s\n", response); else { printk("CCLK err: %d\n", ret); }
Where k_sleep is a delay to ensure that your application is connected to LTE network, i.e. ensure that you get CEREG: 5 – Registered, roaming before calling CCLK.
Here is my output2019-12-16T11:46:46.018Z DEBUG modem << Connecting to LTE network. This may take several minutes.
2019-12-16T11:46:47.378Z DEBUG modem << +CEREG: 2,"76C1","014ACE00",7,0,0,"11100000","11100000"
2019-12-16T11:46:47.438Z DEBUG modem <<
2019-12-16T11:46:48.364Z DEBUG modem << +CEREG: 5,"76C1","014ACE00",7,,,"11100000","11100000"
2019-12-16T11:46:48.426Z DEBUG modem << Connected to LTE network
2019-12-16T11:46:49.371Z DEBUG modem << +CCLK: "19/12/16,11:46:33+04"
Kind regards,
Øyvind