<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Datetime/RTC example</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/55046/datetime-rtc-example</link><description>Hi, 
 Are there any examples utilizing the nRF9160 RTC? I want to timestamp my data that I send to the cloud because my use-case involves queuing up data for extended periods of time (a few hours) and then sending it all at once. It would be nice if I</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 19 Aug 2020 09:26:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/55046/datetime-rtc-example" /><item><title>RE: Datetime/RTC example</title><link>https://devzone.nordicsemi.com/thread/265264?ContentTypeID=1</link><pubDate>Wed, 19 Aug 2020 09:26:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:44db8c8e-2db7-4cd1-aff3-5e397378e700</guid><dc:creator>Adeel</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I had been following your post and needed a bit of help to get things going for me.&lt;/p&gt;
&lt;p&gt;I was looking at this example and wanted to know how did you link the NTP time to the AT+CCLK command to get the real time instead of manually entering the AT+CCLK command.&lt;/p&gt;
&lt;p&gt;Also, the NTP sample does not run in my SES (NCS v1.3.0) :(&lt;/p&gt;
&lt;p&gt;Thanks &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Datetime/RTC example</title><link>https://devzone.nordicsemi.com/thread/223625?ContentTypeID=1</link><pubDate>Wed, 04 Dec 2019 13:51:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:71e1cd39-0bfb-45b2-8a45-4614bd184022</guid><dc:creator>jlangballeswift</dc:creator><description>&lt;p&gt;Hi Hakon,&lt;/p&gt;
&lt;p&gt;Maybe this is a separate issue but even when accounting for the timezone difference from CCLK, it is still inaccurate unless it has been set properly. I expected it to automatically get the correct time from the cellular network but it looks like it doesn&amp;#39;t do that.&lt;/p&gt;
&lt;p&gt;What I ended up doing is using &lt;a href="https://github.com/Rallare/fw-nrfconnect-nrf/tree/nrf9160_samples/samples/nrf9160/ntp"&gt;this sample&lt;/a&gt;&amp;nbsp;to get the time using NTP, which I then use to set the modem RTC with AT+CCLK=___. Then I was able to get accurate timestamps from the AT+CCLK? command.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Datetime/RTC example</title><link>https://devzone.nordicsemi.com/thread/223535?ContentTypeID=1</link><pubDate>Wed, 04 Dec 2019 10:04:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8ddf77d4-3128-473d-a245-dc61e1009c6e</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>[quote user="jlangballeswift"]My question relates more to the actual getting of the current time. I can read the RTC off of the modem using &amp;quot;AT+CCLK?&amp;quot; but this time is not accurate until I set it with &amp;quot;AT+CCLK=___&amp;quot;. For example, right now when I read the time with AT+CCLK, it is 5 hours ahead. What are my options for getting the current time so I can set it in the modem and use it throughout? Of these, what would be the most reliable?[/quote]
&lt;p&gt;&amp;nbsp;It is given with a offset at the end, as per the AT specification here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ref_at_commands/REF/at_commands/mob_termination_ctrl_status/cclk_read.html?cp=2_1_3_28_1"&gt;https://infocenter.nordicsemi.com/topic/ref_at_commands/REF/at_commands/mob_termination_ctrl_status/cclk_read.html?cp=2_1_3_28_1&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You can override this by setting it back with your time + timezone.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user="jlangballeswift"]I&amp;#39;m thinking that on boot, I would want to request the current time and then save it in the modem. What is the most reliable way of doing this?[/quote]
&lt;p&gt;You have several ways, as mentioned; ntp and gps. You can also query the lte network for time, and use AT+CCLK.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Datetime/RTC example</title><link>https://devzone.nordicsemi.com/thread/223394?ContentTypeID=1</link><pubDate>Tue, 03 Dec 2019 15:20:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:78925597-918f-47dc-a590-9821fd90ddfb</guid><dc:creator>jlangballeswift</dc:creator><description>&lt;p&gt;My question relates more to the actual getting of the current time. I can read the RTC off of the modem using &amp;quot;AT+CCLK?&amp;quot; but this time is not accurate until I set it with &amp;quot;AT+CCLK=___&amp;quot;. For example, right now when I read the time with AT+CCLK, it is 5 hours ahead. What are my options for getting the current time so I can set it in the modem and use it throughout? Of these, what would be the most reliable?&lt;/p&gt;
&lt;p&gt;I&amp;#39;m thinking that on boot, I would want to request the current time and then save it in the modem. What is the most reliable way of doing this?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Datetime/RTC example</title><link>https://devzone.nordicsemi.com/thread/223322?ContentTypeID=1</link><pubDate>Tue, 03 Dec 2019 12:37:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:736b3a9c-4f6a-499b-8fc5-94903964b41c</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I believe zephyr logging API supports setting an actual timestamp:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/zephyrproject-rtos/zephyr/blob/06ab394f05c0d7561a815cbaf4e7131fe91510f1/include/logging/log_ctrl.h#L65"&gt;https://github.com/zephyrproject-rtos/zephyr/blob/06ab394f05c0d7561a815cbaf4e7131fe91510f1/include/logging/log_ctrl.h#L65&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You could get the time via GPS, or NTP, then set it via this function.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>