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

need real time clock tutorial for s130 nr51822

Is there a simple way to have linux time up and running with minimum current consumption and good accuracy?

Preferably, some class with get_unix_time and set_unix_time methods, with a resolution of up to seconds.

  • Hi

    I did a simple example using the time.h library a while back, and you might be able to use that as a basis:
    https://github.com/NordicPlayground/nrf5-calendar-example

    I only included project files for the nRF52 series though, but the code should be backwards compatible with the nRF51822.

    The accuracy will depend on your 32kHz clock source. If you use the external 32k crystal on the nRF51 DK it will be 20ppm at room temperature.

    Best regards
    Torbjørn

  • Since my application implies wide operating temperature, and the 20ppm will render in one minute off the time within a month, or possibly more than ten minutes a year, that's doesn't fit my initial idea. But then I realized that I can manage without real time clock. Thank you for your answer, anyway!

  • Hi

    It's possible to get more accurate crystals, including some that compensate for temperature changes, but if you don't need one at all it's obviously easier :)

    Best regards

  • I DO need to get some clock for my health device., I need to provide timestamps with measurements. However, your example requires that the user input an initial time. No user of a device would ever want to do that every time the device is turned on.

    How would I implement a timer that needs to be set only once and then continues every time the device is turned on. There must be some way to this as I have never used a health device that doesn't keep its time between power cycles.

    I am using an nRF51822 on the corresponding DK. I would like to be using the nRF52 series but that is not in my power to choose. If I could do this entirely by using SoftDevice (s130) sd_* calls that would be even better.

    Thanks

  • Hi

    By "device is turned on" do you mean that the device is woken up from some sleep state (while the chip still has a power supply) or that the device is powered up completely?

    In order for the device to keep track of time when it is off the nRF chip will need to have power, and run an RTC timer in the background (using the 32kHz crystal as a clock source). 

    If you remove power from the device completely there is no way to keep track of time. If you save a timestamp to flash before the device is powered off you can continue from that point when you wake up again, but the time spent without power will obviously not be counted. 

    brianreinhold said:
    I have never used a health device that doesn't keep its time between power cycles.

    Not sure what system you are talking about here, but I don't know of any electronic system that can keep track of time without power. 

    More sophisticated devices with rechargeable batteries might include a secondary smaller battery for the sole purpose of keeping track of time when the main battery is discharged, but then they will probably also use a dedicated RTC chip separated from the main processor. 

    Best regards
    Torbjørn

Related