SSD1306 says Height incorrect

I am running Windows 10 and I have purchased an Arduino UNO. I have successfully run blink and a number of the basic programs. I then purchased the SSB1306 display, and downloaded the SSD and GFX programs from github I went to ‘Add ZIP library’ which I used. This produced entries in the ‘recommended libraries’ section of the menu. When selected this placed a file called Adafruif_SSD1306.h as an include file. This seems to compile but as I could not select the type of display or change displays address I was not surprised that it did not work my display. I tried going to the folder containing the unzipped files and selecting the correct display. This produced the expected program, displayed in the IDE. When I compile the file I get an error message: Line 53 and 54 #if (SSD1306_LCDHEIGHT != 64) and # error ("Height incorrect, please fix Adafruit_SSD1306.h!"). When checking the offending file the line #define SSD1306_LCDHEIGHT 64 seems to suggest that it is correct.

What am I doing wrong?

In Adafruit_SSD1306.h

  1. uncomment #define SSD1306_128_64
  2. comment #define SSD1306_128_32
  3. comment #define SSD1306_96_16

In the example ssd1306_128x64_i2c

  1. add #define SSD1306_LCDHEIGHT 64

on top of

#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif

Suerte.

1 Like

DroidDuino: thanks! It works, your great!

thanks DroidDuino. it work and sucsess

Yup, thanks a lot. I was following the instructions from:

and ran into this snag.

A quick google search put me here, and you delivered :wink:

I have also hit the same snag but as I'm unfamiliar with the .h file language and what constitutes a comment marker could someone please point me in detail at the places in the file and explain what I need to do or possibly send me a corrected .h file for an I2C 128x64 display.

Many thanks in advance & anticipation !

Hi, all you need to do is edit the h-file so that rows 73-75 look like this

#define SSD1306_128_64
// #define SSD1306_128_32
// #define SSD1306_96_16

I.e you have to select one of the possible oled pixel maps. Your display is 128*64.
If not then select one of the 2 other choices. Commenting is done by //.

is there a way to shrink the code? It's too big for my duemilanove

moorebrb:
is there a way to shrink the code? It's too big for my duemilanove

Probably not

moorebrb:
is there a way to shrink the code? It's too big for my duemilanove

The Duemilanove has a "bigger" bootloader than the Uno. So it has less room for the User sketch. If you have an external programmer (or another Arduino) you can simply call it a "Uno" and burn the Uno Bootloader.

Most example sketches are fairly small. So will easily fit in the target Arduino.
Sometimes, an example tries to show "everything" that you can do with that library.
The library author tries to squeeze it into a Uno and tests on the Uno. So the identity change might solve your size problem.

The other culprit is the "String" class. Especially with pre v1.6.9 Arduino Release.
Update to the current v1.8.2 and the size might be smaller.

If upgrading the IDE and changing to "Uno" does not fix it, you have to apply the usual tricks e.g.

  1. avoid floating point maths
  2. avoid String class
  3. use appropriate width of any variable or array e.g. use uint8_t instead of int
  4. place anonymous strings in Flash e.g. with F() macro.

Much of this might be above your head. Upgrading to v1.8.2 of the IDE is the first step.

David.

The Duemilanove has a "bigger" bootloader than the Uno.

...And often half the RAM

AWOL:
...And often half the RAM

Go on. Explain.

Duemilanove and Uno both use an ATmega328P. Same 32kB Flash, 2kB SRAM, 1kB EEPROM.

Duemilanove Bootloader is 2048 B Flash and Uno Bootloader is 512B. Hence Duemilanove has got less Flash for the User sketch. Whatever RAM might be used in a Bootloader is irrelevant. The AVR starts with a "clean slate" when it leaves the Bootloader.

David.

Edit. Oops, I see that there were some early Duemilanove with a mega168. I have only seen Duemilanove with mega328. Yes, a mega168 version has got half the SRAM.

My 2009 has a 168 processor.

Explanation delivered.

My apologies. My grovel and your Post arrived at the same time.

We will wait to hear from moorebrb to find what MCU is fitted to his Duemilanove.
If it is a mega168, it is probably cheaper to buy a new Uno clone than to buy a replacement ATmega328P chip.

One thing is certain. A mega168 is severely limited. And not worth the aggravation.

David.

david_prentice:
My apologies. My grovel and your Post arrived at the same time.

We will wait to hear from moorebrb to find what MCU is fitted to his Duemilanove.
If it is a mega168, it is probably cheaper to buy a new Uno clone than to buy a replacement ATmega328P chip.

One thing is certain. A mega168 is severely limited. And not worth the aggravation.

David.

Sadly guys, it's the ATmega168 :frowning: . I'll be purchasing a new one, I'll try the IDE for the hell of it, but I doubt it will work. Thank you for your help though! I really appreciate it!

"If it is a mega168, it is probably cheaper to buy a new Uno clone than to buy a replacement ATmega328P chip.

One thing is certain. A mega168 is severely limited. And not worth the aggravation."

How is 1/2 the memory "severely limited"? It is plenty for a lot of sketches.

'328P chips are pretty low cost, just a couple of dollars. Buy a few, along with 16 MHz crystal, 22pF caps, 0.1uF (100nF) caps, 10K resistor, use them for standalone projects. www.dipmicro.com has all that for very little money.

hey guys!!
I have the same problem as many have in "ssd1306_128x64_i2c" example .according to your guidance , I added #define SSD1306_LCDHEIGHT 64 into my code and error disappeared and also I changed the header file by uncommenting ""#define SSD1306_128_32"" and commenting ""#define SSD1306_128_64"" but I only see some dots on a part of screen(most of the screen) and some animations on the other part.the size is about 1/5 of the screen.it seems that the code is working because i can see the inversion of the screen and some characters.but there is still a problem with resolution maybe.someone help me please.

Help!

I have the same problem as many have in "ssd1306_128x64_spi".

I added #define SSD1306_LCDHEIGHT 64 into my code of the sketch.

I changed the header file by uncommenting ""#define SSD1306_128_32"" and commenting ""#define SSD1306_128_64"" .

The result is some lines displayed on a part of screen(most of the screen) say 2/3rds.

Some animations on the other part of the screen, say about 1/3 of the screen.

It seems that the code is working because at least on the top part of the screen.

How do I get the use of the full screen?

The screen is a Keyestudio V2.0 1.3" OLED unit.

Just want to thank pragma for his solution. Worked like a charm also for the suggestion of Notepad++ which works great for editing .h files.

drjohn:
Help!

I have the same problem as many have in "ssd1306_128x64_spi".

I added #define SSD1306_LCDHEIGHT 64 into my code of the sketch.

I changed the header file by uncommenting ""#define SSD1306_128_32"" and commenting ""#define SSD1306_128_64"" .

The result is some lines displayed on a part of screen(most of the screen) say 2/3rds.

Some animations on the other part of the screen, say about 1/3 of the screen.

It seems that the code is working because at least on the top part of the screen.

How do I get the use of the full screen?

The screen is a Keyestudio V2.0 1.3" OLED unit.

@drjohn Did you ever resolve how to access the full screen area of your OLED?

I'm experiencing the exact same issue with the device I purchased. Only 2/3 of the screen is being addressed. Short of delving deep into the code I presume the issue is that these cheaper screens are of a different resolution to that which the code is written for. The demo displays correctly but with a pronounced moiré effect.

If as you suggested I change the header file by uncommenting "#define SSD1306_128_32" and commenting "#define SSD1306_128_64" the text demo portion of the code displays at the expected resolution [see attached top image]. While if the reverse, with "#define SSD1306_128_64" un-commented the text is only half the height and the smallest font unintelligible [see second image].

Pity its a great little screen for great price but unfortunately not particularly usable at present.

32 line.jpg

64 line.jpg