SPI vrs I2C

Hi,

My question in short is about the pros and cons of the communication types as a whole.

I'm 6 months into Arduino so still a noob as such, I'm tinkering with two boards, the Nano328 and the Mega2560 (they are both clones but I don't think that is relevant to my question)

I built my first device using 0.96 cheap OLED, BME280, RGB LED and three buttons on the nano. It worked well other than I could not for love nor money get the OLED running at 64x128. Yes I know it was me not sorting the library out. it ran fine in program as 32x128 with every second pixel only lol.

Then my laptop died, which was sad as I'd only just got the Mega. A few months later I got a desktop and three days after that was given a laptop! Happy days!!!

So I set about tinkering, and sort the library out for the I2C 0.96 OLED, and also get an SPI 1.44 TFT display that's been awaiting playing with working too. I load the edited library for the OLED to reload the sketch for my first device and I'm plum out of luck. 106% of the nano's memory (due to the increase in buffer size, I think?)

The standard display libraries (adafruit & sparkfun) with sketches for the nano look like this..

The OLED's ssd1306 128x64 i2c compiles at 57% of program space and a shocking 74% of dynamic memory...for a small monocrome item?

The 1.44x1.44 TFT SPI (over twice a big display area and with 256 colours) compiles at 46% of program space and ONLY 23% of dynamic memory?

So I'm left thinking but not knowing that the cost of I2C against SPI on the nano is a massive loss in space. The use of only 2 wires must need so much more software to run?

Or am I still missing something? as always lol

use u8x8 fonts they use less memory

u8g2 offers variable font sizes but chew up memory.

or, try the ESP8266 with lots more memory

So I'm left thinking but not knowing that the cost of I2C against SPI on the nano is a massive loss in space. The use of only 2 wires must need so much more software to run?

Neither SPI or I2C libraries impose much of a code or ram overhead - as they are both implemented in hardware in both of the AVR devices you have. If you post your code (with links to the actual libraries used), it would allow others to duplicate the programs and report their findings. Without code all that anyone can say is "that's a lot of memory".

Agreed, the problem you have has nothing to do with SPI versus I2C.

In particular, Adafruit libraries tend to be full of unneeded junk. Ones I have looked at handle several different displays and try to cover every conceivable option. That approach is a complete waste of space.

Thanks for the answers,

uploading code would only prove you guyz correct.

I'm a noob and just using the IDE.

So now I'm thinking that the OLED I2C curse maybe be infact due to the Adafuirt bit image?

and nothing to do with a noob's sketch?!?!?!

May thanks for the answers