Hi all,
In my project i want to get the timestamp with help of RTC. but when i am printing timestamp it is giving timestamp after power on of the device but i want epoch time for current date and time. how i can get that?
Thanks,
Revati
Hi all,
In my project i want to get the timestamp with help of RTC. but when i am printing timestamp it is giving timestamp after power on of the device but i want epoch time for current date and time. how i can get that?
Thanks,
Revati
Hi,
The RTC peripheral in the nRF52840 is a real time counter only, and the counter is reset on every reset. If you need to keep the current date and time after powering the device off and on again you need something else, like a dedicated calendar RTC IC. Alternatively, if you don't always need a date and time after reset, you could for instance connect to a phone with the current time service (CTS), to get the time and keep the current time in firwmare. But it will be loest upon the next reset.
what i want is whenever any api init is fail for dump log it should print time and date how i can do that?
Hi,
You can enable time stamps in the logger module if you like (see log Logging). This will just refer to time since boot/reset though. As mentioned the nRF has no way of maintaining the clock when it is powered off or reset, so if you need that, you need something external to tell it the time.
Hi,
What are different external ways to tell the time can you tell ?
One is using an external Real Time Clock IC. The other I can think of is if your application connects regularly to a phone via Bluetooth, it can get the time from there using the current time service as demonstrated in the Bluetooth: Peripheral CTS client sample.
One is using an external Real Time Clock IC. The other I can think of is if your application connects regularly to a phone via Bluetooth, it can get the time from there using the current time service as demonstrated in the Bluetooth: Peripheral CTS client sample.
My application is not connecting to Bluetooth it is device which is used in landfill so can you suggest any other better option
If we will connect Bluetooth to device then i will be able to get current reference time
If you connect with a Bluetooth device with a current time service server (like a mobile phone), then yes. But you also have the problem that if the nRF is reset you will need to set the time again. If you need to keep track of time over a long time and also if there are (intentional or unintentional) resets, you may be better of considering adding an external real time clock IC.