Our RTC module from the Hardware posting “speaks” I2C and the Raspberry has some GPIO-pins for just that. Unfortunalety, in the default configuration the Raspberry does not understand I2C. We need to modify some files, have some packages installed and then we are ready to go.
One word of warning: I strongly discourage you from connecting anything to the Raspberry’s GPIO header when the Raspberry is running and/or connected to power. Before fiddling with hardware halt the system, disconnect the power and after you’ve done that, connect what you want.
In order to have I2C on the Raspberry we need to make sure that the proper kernel modules are loaded. Linux/Unix has the ability to dynamically load modules when they are needed but there also numerous modules that are loaded on boot. Think of a kernel module as a low-level driver for some specific hardware. To then interact with hardware, the so called “devices” are added to the filesystem. These are special “files” that serve as the connection between programs and the real hardware. One example was the parallel printer device from my Parallel Printer post.
The Raspberry has a file that blacklists modules the kernel should ignore. This means that even when the kernel detects new hardware, the module does not get loaded. This is to prevent special cases, where one or more modules support the same device which would cause erratic behaviour. The modprobe man page explains this even better. Continue reading