OLED Display "4-SPI"/I2C?

I have 3 of these displays and until now I haven't gotten any of them working. First I thought it was the obscure library for the ESP8266. Then I switched over to an Arduino Pro with the Adafruit lib. Tried 3.3V, tried 5V (only with one, at the end ...), reduced the pull-ups to 1K and checked the waveform with the oscilloscope. The only thing the protocol decoder gets out is "W:078", repeated in short distance three times. The I2C address is 0x78.

I was about to file them under DOA and looked for new ones, then I noticed the offer above that says "4-SPI(default)/I2C". What the hell is 4-SPI on a board that only has VCC/GND + 2 data pins ( is it clock + MOSI, without CS and MISO?), and how do I switch it to I2C? I can only see a jumper for the I2C address ...

Hm, I start to suspect the the SPI thing is just bullshit and I have a device with SH1106 ...

Well, your link clearly says SH1106. Do your displays match the photos in the link? i.e. pcb traces, which resistors are mounted.

I do not have your display. But I am sure that they should work just fine. There are several SH1106 libraries. The 7-bit I2C Slave address will be 0x3C. (8-bit = 0x78)

Many of the Ebay displays do not connect D2. So the I2C device can never ACK. There are libraries that take this into account.

David.

Ok, it is not an SH1106, and it is already I2C, and it is not DOA ... It does not look exactly like the one in the offer, on closer look. Got it working with the ESP with the U8G2 lib and the constructor.

U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);

Now I only need to figure out how to set addresses and have two displays.

What I did not get is how 0x3C is 0x78 :o Where does the factor of 2 come from? I think this was mostly the issue. With 0x3c it also works with another lib, where I can set the address too and so should be able to have 2 displays.

The convention on Arduino is to use 7-bit I2C addresses e.g. 0x68 for a DS1307 The underlying hardware uses an 8-bit address with the lsb signifying Write/Read e.g. 0xD0/0xD1 (W/R) for a DS1307

The two most common problems on I2C are: 1. using the wrong Slave address (and not looking at return value) 2. omitting external pull-up resistors.

Obviously most Arduino users are too tight to pay $0.02 for two pull-up resistors. Arduino library authors enable the AVR internal pullups to reduce tear production.

This will might work on some slow I2C devices. It is not reliable. It is well outside the official I2c specification.

David.

Thanks, I didn't know that convention. SO I guess it is trial and error with those questionable China parts? It seems more correct to write 0x3C, as the address space is only 7 bit ...

As I wrote, I have the pull ups under control. I checked the flanks in the oscilloscope and adjusted. On the breadboard, 4k7 looked pretty terrible, I had to get down to 1k for decent rising flanks.

The OLED Slave Address is either 0x3C or 0x3D. The link shows how to select 0x3C/0x3D. They just mark it as 8-bit 0x78/0x7A.

Now that you have it working, does an I2C sniffer detect 0x3C ? i.e. do you see an ACK on the SDA line with your Logic Analyser?

David..

Yes, sure, everything is hunky dory. The only issue is that I did not know that anyone would make an address from a 7-bit address space "8-bit" by adding a 0 to the least significant digit. It still sounds pretty stupid but I'll keep that in mind.

ElCaron: Yes, sure, everything is hunky dory. The only issue is that I did not know that anyone would make an address from a 7-bit address space "8-bit" by adding a 0 to the least significant digit. It still sounds pretty stupid but I'll keep that in mind.

In the U8g2 library documentation, I have mentioned, that U8g2 expects the I2C address multiplied by 2:

https://github.com/olikraus/u8g2/wiki/u8g2reference#seti2caddress

The problem this: The address space is only 7 bit, however on the bus these 7 bits have to be send as the upper seven bit of one byte. The lowest bit denotes read or write access. So these 7 bits have to be shiftet sooner or later. For U8g2 I decided to shift at all, but let the user proved the already shifted address.

Oliver