Two wire vs. three wire serial interface for RTC

The main difference between SPI (3-wire interface) and I2C (2-wire interface) is, that you have to send an address when using I2C. So it won't be as fast as SPI because you have to send more data.

When using SPI you will need an extra pin for the chip enable signal. This will be required for each slave. So it's faster, but you need more output pins.

I would prefer I2C because speed doesn't matter in this scenario.

The ATMega microcontroller has hardware peripherals for both methods so it's up to you


The first runs off I2C. Timing information is in Figure 5 on page 7 of the datasheet.

The second runs off SPI. Timing information is in Figure 4 on page 8 of the datasheet.

It looks like the ATmega8 has TWI and SPI just like all the other ATmega parts, you can use both with it, simultaneously if you choose. My preference would be SPI. It's a bit easier to work with, and as a protocol tends to be a bit less temperamental.


It depends on a few factors:

  1. Hardware design: If you are using only this chip with your microcontroller, anyone of them will do. But if your design consists of two or more devices that use I2C interface then it makes sense to use I2C RTC so that you don't have to do additional interfacing, just add the RTC to existing bus. Same applies to SPI but keep in mind when you add more devices to the SPI bus, you need one extra SS signal per device. It also depends on the hardware peripherals that you have in your microcontroller. If your micro has hardware SPI peripheral but not I2C then it make sense to use SPI device over an I2C device. Same goes with I2C peripheral.

  2. Software design: Another deciding factor is whether you are implementing either protocol in software. I2C involves a bit more work than SPI. You can also find some code implementations over the web. If you already have a I2C code with high confidence, use it. Same applies if you are pretty confident with a piece of code for SPI that you found over the web.

  3. Your understanding: The choice also depends upon your understanding of either protocols and how well-versed you are with these. If you have used anyone of them before, it makes sense to use prior experience.