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

Using RTC to control the real timestamp

Hi Dev Team,

I had a task to work on that required a timsetamp to schedule a certain event, like for example I wanted my modem to start off every morning at 10:00:00 and switch off at 10:05:00.

What could be the best way to achieve this kind of functionality ?

Regards,

Adeel.

Parents Reply Children
  • Hi Torbjorn,

    Is  there any possibility of an example for nRF9160DK. I am using NCS v1.3.0 nRF Connect for desktop and running the asset tracker application. 

    I tried using the date_time.h library to try and get the time either using NTP or through MODEM. I can use the AT+CCLK command to fix the time manually and then read it but I would like the network to get the current time for me.   

    Regards,

    Adeel.

  • Hi Adeel

    My bad, I thought you were using an nRF52 series device. 

    I don't have a lot of experience with the nRF9160, but I got a tip from a colleague that the SNTP library might provide what you need:

    Best regards
    Torbjørn
  • Hi Torbjorn,

    I am trying to use the date_time.h library that incorporates SNTP in it. When i try to run it, I get the following errors that I am unable to solve.

     2020-08-20T11_12_42.702Z-log.txt

    Could you let me know the methods to solve this error that I am getting. This is using the date_time.h library.

    Regards,

    Adeel.

  • Hi Adeel

    Looking at the log it appears you are disabling the modem before this issue occurs:

    2020-08-20T11:13:04.559Z DEBUG modem << AT send: AT+CFUN=0

    Can you confirm whether or not this was intentional?

    After disabling the modem you can see that you get detached, and at this point the data connection is lost. 

    Best regards
    Torbjørn

  • Hi Tobjorn,

    Yes, I was trying to turn off my modem for a certain time and then turn it back on later. Even when it is turned back on (AT+CFUN = 1), I still get the same error. 

    2020-08-20T11:13:36.441Z DEBUG modem << AT send: AT+CFUN=1
    2020-08-20T11:13:36.546Z DEBUG modem << AT ret: OK
    2020-08-20T11:13:37.283Z DEBUG modem << [00:01:05.495,147] [1;31m<err> date_time: sntp_query, error: -1[0m
    2020-08-20T11:13:37.294Z DEBUG modem << [00:01:05.503,540] [1;31m<err> date_time: getaddrinfo, error: -11[0m
    2020-08-20T11:13:37.302Z DEBUG modem << [00:01:05.513,458] [1;31m<err> date_time: getaddrinfo, error: -11[0m
    2020-08-20T11:13:37.312Z DEBUG modem << [00:01:05.522,064] [1;31m<err> date_time: getaddrinfo, error: -11[0m
    2020-08-20T11:13:37.319Z DEBUG modem << [00:01:05.530,700] [1;31m<err> date_time: getaddrinfo, error: -11[0m
    2020-08-20T11:13:37.329Z DEBUG modem << [00:01:05.538,482] [1;31m<err> date_time: Not getting time from any NTP server[0m

    Is there any procedure or a way to use the date_time library. Is there any specific example to use that library ?

Related