Setting up and Real Time Clock (RTC) on a Raspberry Pi

Daniel Ellis Research
3 min readSep 25, 2022

A simple guide on how to add a timekeeping module to the PI using its I2C ports. NOTE this tutorial is for current release Raspberry Pi OS’s.

Photo by Aron Visuals on Unsplash

1 — Insert the Module

Most Pi compatible RTCs just slot directly onto the GPIO pins. If it is a 2x3 RTC, just plug it in at the very top, similarly with a 1x5 (plug it in on the left rail). Should you have a clock with individual headers, the communication ones go onto the 2nd and 3rd pins on the left rail from the top and the others to a 3/5V pin and a ground.

Source https://cdn.shopify.com/s/files/1/0174/1800/products/3386_1024x1024.jpg?v=1539264393

2 — Determine the Port

We can use the i2cdetect function to determine the id of our real time clock chip.

sudo i2cdetect -y 10  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
70…

--

--

Daniel Ellis Research

Research Software Engineer specialising in High-Performance Computing and Data Visualisation. — PhD in Atmospheric Chemistry and Masters in Theoretical Physics.