<?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>NRF52840 date time example</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/91066/nrf52840-date-time-example</link><description>So, I am working on nrf52840 with nrf connect sdk and I want to get date and time in my project, I found a library in nrf connect sdk -&amp;gt;libraries-&amp;gt;other libraries-&amp;gt;date-time, I tried to add the configuration in my prj.conf, but an error occur.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 30 Dec 2024 05:57:34 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/91066/nrf52840-date-time-example" /><item><title>RE: NRF52840 date time example</title><link>https://devzone.nordicsemi.com/thread/516443?ContentTypeID=1</link><pubDate>Mon, 30 Dec 2024 05:57:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aa201217-3d49-4029-9abb-418478803915</guid><dc:creator>lara</dc:creator><description>&lt;p&gt;iam using nrf52833dk..can i sync the data and time while connecting with bluetooth.&lt;/p&gt;
&lt;p&gt;while connecting with central,it should sync the time and date of central.can we do this?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 date time example</title><link>https://devzone.nordicsemi.com/thread/382134?ContentTypeID=1</link><pubDate>Thu, 18 Aug 2022 06:25:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:34a42a59-5480-40d7-a99b-5f3d413c147f</guid><dc:creator>Jay_Lin</dc:creator><description>&lt;p&gt;Thanks for the reply I am using nrf52840 which can&amp;#39;t use Date-time, thanks alot though&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 date time example</title><link>https://devzone.nordicsemi.com/thread/381979?ContentTypeID=1</link><pubDate>Wed, 17 Aug 2022 10:47:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4f972c3a-57e9-4537-b37e-11862f356c02</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;To use the DATE_TIME library with other nRF devices than nRF9160, you need to specify these configurations:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_DATE_TIME=y
CONFIG_DATE_TIME_MODEM=n
CONFIG_DATE_TIME_NTP=n&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;And then supply the time manually. Here&amp;#39;s a small snippet on how to do that:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/*
 * Copyright (c) 2012-2014 Wind River Systems, Inc.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;date_time.h&amp;gt;
#include &amp;lt;sys/printk.h&amp;gt;

void main(void)
{
	// Set time to 8th of June, 2022, 16:00
	// unix timestamp: 1654704000000
	struct tm time = 
	{
  		.tm_sec = 00,
  		.tm_min = 00,
  		.tm_hour = 16,
  		.tm_mday = 8,
  		.tm_mon = 6-1,
  		.tm_year = 2022-1900,
  		.tm_wday = 3,
	};
	int err = date_time_set(&amp;amp;time);
	/* your err handling here */
	
	printk(&amp;quot;Hello World! %s\n&amp;quot;, CONFIG_BOARD);
	int64_t unix_timestamp = 0;

	// Wait 10 seconds to see that the timestamp increments 10 seconds
	k_sleep(K_SECONDS(10));

	err = date_time_now(&amp;amp;unix_timestamp);
	/* your err handling here */
	
	// Use https://www.epochconverter.com/ to convert to human readable
	printk(&amp;quot;unix timestamp: %lld&amp;quot;, unix_timestamp);
}&lt;/pre&gt;&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: NRF52840 date time example</title><link>https://devzone.nordicsemi.com/thread/381937?ContentTypeID=1</link><pubDate>Wed, 17 Aug 2022 09:01:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4416bd67-ae83-4cb8-9413-c3c4c46c9d4d</guid><dc:creator>nRF5xFanboy</dc:creator><description>&lt;p&gt;&lt;span&gt;Hello Jay_Lin,&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; If there is no additional hardware involved then you can not have real world date&amp;amp;time &lt;br /&gt;With the &lt;span&gt;nrf52840dk you can only have &amp;quot;systems tics counter&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You need a modem&amp;nbsp; &amp;nbsp;+ sim-card&lt;br /&gt;For example:&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;a href="https://www.conrad.nl/nl/p/sos-electronic-arduino-mc60gsm-gps-1925472.html?utm_source=google&amp;amp;utm_medium=surfaces&amp;amp;utm_campaign=shopping-feed&amp;amp;utm_content=free-google-shopping-clicks&amp;amp;utm_term=1925472&amp;amp;adcampaign=gshop&amp;amp;tid=14579472676_122103879770_pla-304375124321_pla-1925472&amp;amp;gclid=CjwKCAjwo_KXBhAaEiwA2RZ8hL9boviQGXVCdF7HGNy9fEt0hANdcVzmH7xv0gVGdmEnsR13i1ODPRoC29EQAvD_BwE"&gt;https://www.conrad.nl/nl/p/sos-electronic-arduino-mc60gsm-gps-1925472.html?utm_source=google&amp;amp;utm_medium=surfaces&amp;amp;utm_campaign=shopping-feed&amp;amp;utm_content=free-google-shopping-clicks&amp;amp;utm_term=1925472&amp;amp;adcampaign=gshop&amp;amp;tid=14579472676_122103879770_pla-304375124321_pla-1925472&amp;amp;gclid=CjwKCAjwo_KXBhAaEiwA2RZ8hL9boviQGXVCdF7HGNy9fEt0hANdcVzmH7xv0gVGdmEnsR13i1ODPRoC29EQAvD_BwE&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Can you please mark my answer as solution, thanks! ;-)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 date time example</title><link>https://devzone.nordicsemi.com/thread/381930?ContentTypeID=1</link><pubDate>Wed, 17 Aug 2022 08:53:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:369019cb-2bbf-40ad-a4ff-3f973e2749f5</guid><dc:creator>Jay_Lin</dc:creator><description>&lt;p&gt;Yes I am using nrf52840dk, thanks for the solution I will do some study&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 date time example</title><link>https://devzone.nordicsemi.com/thread/381927?ContentTypeID=1</link><pubDate>Wed, 17 Aug 2022 08:45:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d21bca83-c4c8-49f8-bc6a-e91531a9dc3e</guid><dc:creator>nRF5xFanboy</dc:creator><description>&lt;p&gt;Hello Jay_Lin,&lt;br /&gt;&lt;br /&gt;* don&amp;#39;t be sorry foor noob questions.*&amp;nbsp;&lt;br /&gt;&lt;br /&gt;What hardware are you using ?&lt;br /&gt;&lt;br /&gt;If this is only a nordic development kit nrf52840DK ?&amp;nbsp; (like the picture here)&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1660725714062v1.png" /&gt;&lt;br /&gt;If yes, then you can never have date&amp;amp;time&amp;nbsp; because this board is unable to&amp;nbsp;synchronize with a possible time server present on the internet (or another time source like a cellular network)&lt;br /&gt;it needs a modem&amp;nbsp;to establish connection to get the real world date &amp;amp; time&lt;br /&gt;&lt;br /&gt;An alternative solution is to connect a gps receiver and obtain time from there.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 date time example</title><link>https://devzone.nordicsemi.com/thread/381920?ContentTypeID=1</link><pubDate>Wed, 17 Aug 2022 08:33:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:827ffb98-b569-43d3-bbe8-b1f4a1faf301</guid><dc:creator>Jay_Lin</dc:creator><description>&lt;p&gt;I edit the post the config I add below #TIme is causing the problem when I delete them It build. what is modem? sorry for noob question&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 date time example</title><link>https://devzone.nordicsemi.com/thread/381915?ContentTypeID=1</link><pubDate>Wed, 17 Aug 2022 08:25:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:916bf6f3-3aab-4f23-aa43-fe9e251564f6</guid><dc:creator>nRF5xFanboy</dc:creator><description>&lt;p&gt;&lt;span&gt;Which config?&lt;br /&gt;Can you provide a configuration key+value you talking about in the proj.conf&lt;br /&gt;&lt;br /&gt;The error at the bottom&amp;nbsp;tells you&amp;nbsp; the missing dependencies&amp;nbsp;&amp;nbsp;&lt;br /&gt;what modem do you&amp;nbsp;use?&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 date time example</title><link>https://devzone.nordicsemi.com/thread/381912?ContentTypeID=1</link><pubDate>Wed, 17 Aug 2022 08:19:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6c7629f2-9381-4a22-9888-dcb1ae08c54f</guid><dc:creator>Jay_Lin</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/nrf5xfanboy"&gt;nRF5xFanboy&lt;/a&gt;&amp;nbsp;I am using vscode, I have a question when I delete the config relate to Time it build and work, but when I add config relate to Time it shows error is it still the problem about board configuration?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 date time example</title><link>https://devzone.nordicsemi.com/thread/381910?ContentTypeID=1</link><pubDate>Wed, 17 Aug 2022 08:08:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b9886355-cdde-4f77-a395-be3de3bf014f</guid><dc:creator>nRF5xFanboy</dc:creator><description>&lt;p&gt;Hello Jay_lin&lt;br /&gt;&lt;br /&gt;The error tells you what to do -&amp;gt; please add a path to find your board definition.&lt;br /&gt;&lt;br /&gt;What toolchain are you using?&lt;br /&gt;segger embedded studio or&amp;nbsp;visualCode?&lt;/p&gt;
&lt;p&gt;When you are using SES then you can&amp;nbsp;adapt the file: cmakelist.txt to add the missing board root path&lt;br /&gt;&lt;br /&gt;set(BOARD_ROOT $ENV{EXAMPLE_BASE}})&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;where:&lt;br /&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;EXAMPLE&lt;/span&gt;&lt;span&gt;_BASE&amp;nbsp; &amp;nbsp;can be&amp;nbsp; c:\cm\ncs\projects\my_project\boards&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;br /&gt;When you are using visualCode then you can manually add a board&amp;nbsp;configuration to build with.&lt;br /&gt;&lt;br /&gt;Perhaps the next website helps:&lt;br /&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/develop/west/build-flash-debug.html#west-building-config"&gt;developer.nordicsemi.com/.../build-flash-debug.html&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>