Hi,
I have tried all the possible solutions mentioned on the forum. Re-checked & re-downloaded both SSD1306 & GFX library
Verified the .h file and made sure that the pins are connected properly.
However, for the OLED display 128x64 I am getting the following error with both UNO & Pro Micro
ssd1306_128x64_spi:65: error: #error ("Height incorrect, please fix Adafruit_SSD1306.h!");
The moment I change the
#if (SSD1306_LCDHEIGHT != 64) to 32 it works but the display is stretched out in height.
How can I solve this. What am I missing?
128x64 OLED Display Error
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: 128x64 OLED Display Error
What do you have in Adafruit_SSD1306.h between lines 54 and 57?
The compiler has to handle the display buffer differently based on the size of the screen, so you have to tell it the screen size in the header file. The most recent version of the header defaults to the 128x64 display though, so that value should be set properly for your device.
The compiler has to handle the display buffer differently based on the size of the screen, so you have to tell it the screen size in the header file. The most recent version of the header defaults to the 128x64 display though, so that value should be set properly for your device.
- iroboticist
- Posts: 4
- Joined: Sun Feb 09, 2014 2:36 am
Re: 128x64 OLED Display Error
Code: Select all
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#ifdef __SAM3X8E__
typedef volatile RwReg PortReg;
typedef uint32_t PortMask;
#else
typedef volatile uint8_t PortReg;
typedef uint8_t PortMask;
#endif
#include <SPI.h>
#include <Adafruit_GFX.h>
#define BLACK 0
#define WHITE 1
#define SSD1306_I2C_ADDRESS 0x3C // 011110+SA0+RW - 0x3C or 0x3D
// Address for 128x32 is 0x3C
// Address for 128x64 is 0x3D (default) or 0x3C (if SA0 is grounded)
/*=========================================================================
SSD1306 Displays
-----------------------------------------------------------------------
The driver is used in multiple displays (128x64, 128x32, etc.).
Select the appropriate display below to create an appropriately
sized framebuffer, etc.
SSD1306_128_64 128x64 pixel display
SSD1306_128_32 128x32 pixel display
-----------------------------------------------------------------------*/
#define SSD1306_128_64
#define SSD1306_128_32
/*=========================================================================*/
#if defined SSD1306_128_64 && defined SSD1306_128_32
#error "Only one SSD1306 display can be specified at once in SSD1306.h"
#endif
#if !defined SSD1306_128_64 && !defined SSD1306_128_32
#error "At least one SSD1306 display must be specified in SSD1306.h"
#endif
#if defined SSD1306_128_64
#define SSD1306_LCDWIDTH 128
#define SSD1306_LCDHEIGHT 64
- iroboticist
- Posts: 4
- Joined: Sun Feb 09, 2014 2:36 am
Re: 128x64 OLED Display Error
So the library seems fine
I am using an Arduino Micro but also tried an UNO. Both have same issue
I am using an Arduino Micro but also tried an UNO. Both have same issue
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: 128x64 OLED Display Error
You need to comment out the 128x32 option. It's a "select one or the other" thing.
-
- Posts: 2
- Joined: Sun Jul 13, 2014 2:34 pm
Re: 128x64 OLED Display Error
Hello,
I am also using an adafruit 1306 OLED 128x64 screen, and I am having the exact same problem that iRoboticist had. I am using a teensy 3.1, but it still did not work when I used the screen with an arduino uno. However, I am sure that I have commented out the line " #define SSD1306_128_32" from the .h file in the library, and I am still getting the height error. When I comment out the height error from the example spi sketch, it loads to the screen, but it appears that every other line is being skipped, so the image looks stretched out, and only the top half is displayed. I've tried every solution I can think of and I am completely stumped. Is there any other solution or another problem I could be having?
Thank you!
I am also using an adafruit 1306 OLED 128x64 screen, and I am having the exact same problem that iRoboticist had. I am using a teensy 3.1, but it still did not work when I used the screen with an arduino uno. However, I am sure that I have commented out the line " #define SSD1306_128_32" from the .h file in the library, and I am still getting the height error. When I comment out the height error from the example spi sketch, it loads to the screen, but it appears that every other line is being skipped, so the image looks stretched out, and only the top half is displayed. I've tried every solution I can think of and I am completely stumped. Is there any other solution or another problem I could be having?
Thank you!
- Franklin97355
- Posts: 23910
- Joined: Mon Apr 21, 2008 2:33 pm
Re: 128x64 OLED Display Error
Could you post clear pictures of your board and the connections to it? What program are you running to test this?
-
- Posts: 2
- Joined: Sun Jul 13, 2014 2:34 pm
Re: 128x64 OLED Display Error
I've attached a photo of my wiring. I'm using the SPI wiring from the example sketch, and I am connecting the 3.3V pin on the screen to the 3.3V on the arduino. The pins connected are:
DATA to 9
CLK to 10
DC to 11
RST to 13
CS to 12. I'm using the arduino IDE downloaded from the website, and a windows 8 computer to program it.
I've also attached the .h file from the library that iRoboticist modified to get the screen to work.
I tried having it serial print SSD1306_LCDHEIGHT in the loop, and it printed 32. Shouldn't it be printing 64 if I define it as 64 in the .h file? The weirdest thing about this is that I had it working on the uno without the height error or stretch. Then I switched to the teensy, and then the screen did not work, and when I switched back to the uno, it still did not work.
Thank you and I appreciate any help I could get!
DATA to 9
CLK to 10
DC to 11
RST to 13
CS to 12. I'm using the arduino IDE downloaded from the website, and a windows 8 computer to program it.
I've also attached the .h file from the library that iRoboticist modified to get the screen to work.
I tried having it serial print SSD1306_LCDHEIGHT in the loop, and it printed 32. Shouldn't it be printing 64 if I define it as 64 in the .h file? The weirdest thing about this is that I had it working on the uno without the height error or stretch. Then I switched to the teensy, and then the screen did not work, and when I switched back to the uno, it still did not work.
Thank you and I appreciate any help I could get!
- mark1davison
- Posts: 6
- Joined: Sun Sep 07, 2014 5:46 am
Re: 128x64 OLED Display Error
Exactly the same issue here. Even with #define SSD1306_128_64 in the .h file it still throws the LCDHEIGHT error. I was orignially trying it on a teensy 3.1 but even if I switch back to an Uno R3 I get the exact same issue. If I remove the error code it compiles and runs but misses out every other line and stretches everything as per previous comments.
With both #define SSD1306_128_32 and #define SSD1306_128_64 in the .h file I don't get an #error "Only one SSD1306 display can be specified at once in SSD1306.h" but looking at the .h file I should do?
Even hard coding in #define SSD1306_LCDWIDTH 128 and #define SSD1306_LCDHEIGHT 64 into the .h file doesn't help
With both #define SSD1306_128_32 and #define SSD1306_128_64 in the .h file I don't get an #error "Only one SSD1306 display can be specified at once in SSD1306.h" but looking at the .h file I should do?
Even hard coding in #define SSD1306_LCDWIDTH 128 and #define SSD1306_LCDHEIGHT 64 into the .h file doesn't help
- mark1davison
- Posts: 6
- Joined: Sun Sep 07, 2014 5:46 am
Re: 128x64 OLED Display Error
I guess it is the process of spelling out what is and isn't working in an 'issue' post that helps you sort your own problem !
My issue was that I was editing the .h file in my user libraries but the IDE was using the .h file from the libraries installed in C:\Program Files (x86)\Arduino\libraries. Not sure if it was teensyduino that installed them or they came with the ardunio IDE, but either way that was the issue. I deleted the files from C:\Program Files (x86)\Arduino\libraries and just used the most upto date ones that I'd downloaded to my user libraries !
My issue was that I was editing the .h file in my user libraries but the IDE was using the .h file from the libraries installed in C:\Program Files (x86)\Arduino\libraries. Not sure if it was teensyduino that installed them or they came with the ardunio IDE, but either way that was the issue. I deleted the files from C:\Program Files (x86)\Arduino\libraries and just used the most upto date ones that I'd downloaded to my user libraries !
- adafruit_support_bill
- Posts: 88089
- Joined: Sat Feb 07, 2009 10:11 am
Re: 128x64 OLED Display Error
Multiple copies of a library is a sure way to confuse the Arduino IDE. It loads all the libraries at startup, and if there are multiples you can't guarantee which one it will use.
- thedirty530
- Posts: 1
- Joined: Wed Jan 20, 2016 11:53 pm
Re: 128x64 OLED Display Error
Same issue here...It will not recognize display as 128x64. It will only work if SSD1306.h file is defined to 128x32, where graphics are distorted. Very frustrating problem with no accurate solution on Adafruit & Arduino website forums. Been at it for months now....this would be a great topic for a tutorial. I've got the u8glib library to work perfectly so I think i'm gonna stick with that.
Last edited by thedirty530 on Thu Jan 21, 2016 12:22 am, edited 1 time in total.
- Franklin97355
- Posts: 23910
- Joined: Mon Apr 21, 2008 2:33 pm
Re: 128x64 OLED Display Error
Glad you have something that works for you. Perhaps others will find this post helpful.I've got the u8glib library to work perfectly so I think i'm gonna stick with that.
- jack_b3
- Posts: 5
- Joined: Sun Sep 16, 2012 11:41 am
Re: 128x64 OLED Display Error
I have the same issue on a project that was working very well, the only thing I can think of is something in the latest version of the IDE.
- adafruit_support_bill
- Posts: 88089
- Joined: Sat Feb 07, 2009 10:11 am
Re: 128x64 OLED Display Error
The latest is not always the greatest. We are recommending that people stick with 1.6.5 until the problems in 1.6.6 and 1.6.7 can be resolved by the Arduino team.the only thing I can think of is something in the latest version of the IDE.
Please be positive and constructive with your questions and comments.