When you switch on your PC or Mac, do you have to change its time? Highly unlikely! Do you have to on your Raspberry Pi? Possibly.
Each time your Raspberry Pi boots it connects to what is called an NTP – Network Time Protocol – server and asks it the time. But what happens if your Pi is not connected to the internet? You’re out of luck (or is that time?). Your Pi has no way of knowing what time it is.
But there is a solution in the form of a ‘Real Time Clock’ or RTC board. These inexpensive add-on boards plug on top of your Pi’s GPIO pins and contains a clock chip and a tiny battery that tell the Raspberry Pi what time it is. The Pi Hut sells such a board.
Setting up I2C
The RTC board uses what is known as the I2C (pronounced ‘eye squared see’) protocol to communicate between itself and the Raspberry Pi. The I2C allows the Raspberry Pi to communicate with a lot of different devices at the same time that are also connected to the same I2C pins on the Raspberry Pi.
Simon Monk has written very good instructions about how to set up your Raspberry Pi to be able to use i2c on the Adafruit site. Follow the full instructions, including checking that everything has worked by going through the manual instructions too.
Plugging in the Board
It is always best to turn your Raspberry Pi off before plugging anything onto the GPIO pins. Always do this using the sudo halt or sudo shutdown -h now commands.
Now plug the board onto your Raspberry Pi GPIO pins on the inside corner with the RTC board pointing inwards, as shown below.