SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
By BlindAssassin111

So I recently purchased a 128x64 pixel SH1106(originally thought it was the SSD1306, but didn't read far enough down on the purchase page :/) and I had no luck with the adafruit library for the 1306 obviously because the RAM differs enough between the two that made it not compatable and more effort than I wanted to put in to make the display actually work.

Now onto the problem, I am using the newer u8g2 library and I tried the "GraphicsTest.ino" example and uncommented the line for the SH1106, but the display was still not working properly, so I then tried the code for the I2C SSD1306 and everything seems to work fine.

Now I said "seems" as it will display but the display is shifted by 2 pixel columns and the first 2 get cut off, while the last 2 get filled with random trash. This is caused by the ram of the SH1106 being 132x64 instead of 128x64 like the SSD1306, at least from my research.
Code: Select all
U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE);   // All Boards without Reset of the Display

U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
The reason for me switching to the SSD1306 line was that my board has no reset, and the way it was defined in the example shows that the SH1106 should have a reset, when in fact it doesn't, the SSD1306 does, and due to other pin issues. But that is not my problem, or is it?

So what needs to be changed in either the library or the code in order to fix the column issue? I tried shifting over just the drawing stuff in the example, and it will display entirely on the screen, but the last 2 columns are still filled with trash. BTW, by trash I mean it looks like the old static from TV's of old. ;P (old enough to have experienced real static, not the false static used nowadays)

Thanks to anybody who helps, I have been away from arduino for a couple years now and actually decided to take an EE micro-controllers course at my university for a senior elective, I am a ME major, and have been using the TI launchpad MSP430, which made me want to pick up a new project and have fun with this stuff again, but with arduino as I really don't feel like not using the libraries people have made to support the OLEDs that I am using, and because I don't want to try it in assembly (the only language we have used to program the launchpad). Have a great day/night or both, I won't tell you how to live ;P.

P.S. Sorry if the above is hard to read, wrote this after being up for quite some time and just can't think straight, but needed to get this out asap.
By drojf
I think you uncommented the wrong line (you should just change "SSD1306" to "SH1106"):
Code: Select all
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0);   //gives garbage on the SH1106
U8G2_SH1106_128X64_NONAME_F_HW_I2C  u8g2(U8G2_R0);   //works fine on SH1106
If you are using software I2C then use the software I2C constructor but just change the name. The full list of constructors is available here: ... -reference

My board is 128x64 I2C, it has 4 pins, GND, VCC, SCL, and SDA (no reset).

I realize it's been a year but maybe someone will find this information useful.