How do I give my Pi system a Real Time Clock (RTC)? Is this possible? As each time when I power off my Pi, and the next time when it boots, it displays the previous power off time.

Can someone explain me how to initalise or setup a RTC in my Pi?

  • Is your Pi connected to the internet, a local network or no network at all?
    – Craig
    Nov 18, 2015 at 17:31

3 Answers 3


The Raspberry Pi doesn't include a hardware clock out of the box. You will need to purchase such a module (relatively cheap), install it, setup a battery and then set up the software, which is a pretty straightforward procedure.

Something like the JBtek DS3231 RTC Real Time Clock Module for Raspberry Pi.


I can post the setup process if you need me to, but there are plenty tutorials you can find with a google search that document the process extensively.

  • 2
    Setting up the software is not nearly as straightforward as you might think when using recent releases of raspian. I just got mine working yesterday after a lot of messing around, will put up some info soon.
    – greggo
    Nov 17, 2015 at 19:10
  • @greggo Please do, I was almost going to post a link to your earlier question with a warning, lol.
    – goldilocks
    Nov 17, 2015 at 19:37
  • 'plenty tutorials you can find with a google search'. Too many. A lot of it conflicts with others, or is incomplete or obsolete or ...
    – greggo
    Nov 19, 2015 at 4:43

I elected to use a DS1307 hw clock on mine since it was i2c based and I have several other i2c devices on mine already. You can purchase them via Adafruit or various 3rd party locations on eBay/Amazon/etc in a small break-out board ready to plug into your breadboard with on-board battery, etc. They're all pretty cheap. If the break-out board does what you need, then you can always order just the DS1307 chip and do your own supporting circuitry later for your final build even cheaper.

HERE is the one I used for my build.

As far as getting it running, the process is pretty well documented HERE to get the kernel modules loaded, set the time on the RTC, and set Linux to pull the OS time from the RTC upon each boot.

  • Adafruit procedure is missing a couple of things. You need to enable I2C in raspi-config (which is mentioned as a 'first-go-do', but not detailed); and also, the two operations added to /etc/rc.local won't work without a short 'sleep' between them. When I set mine up I removed 'fake-hwclock', but I'm not sure if that' essential.
    – greggo
    Nov 19, 2015 at 4:32

A hardware RTC may or may not be the best solution.

If your RasPi has no network connecition, then yes a hardware RTC is about your only option. But, if you are connecting via ethernet (wifi or wired) you can do a sudo apt-get install ntpdate which will install a daemon that runs on boot when the ethernet connection is established. This will set the RasPi internal clock each time it boots and its network connection establishes.

Most Raspian distros already do this. If yours already does, the above command won't do anything. But if yours does not, it should hook you up to a NTP (Network Time Protocol) server. Settings are contained in /etc/default/ntpdate.

Also check /etc/ntp.conf for proper configuration.

With those two, you shouldn't ever need any hardware RTC module.

  • Exactly, which is one of the rationales for not including a RTC in the Pi's design in the first place. Reduces cost and is in many cases not necessary as the Pi will be networked.
    – Ghanima
    Nov 18, 2015 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.