I have an OLED Display module with SSD1331 controller and an RePhone board. I’m trying to get them work together via SPI but I have no luck.
The same OLED display with an Arduino Uno board works just fine.
How can I make them work ?
With Arduino Uno i used Adafruit_SSD1331 and Adafruit_GFX libraries.
This is the OLED display:
Nice display.
Since the breakout board has all SPI pins, it should work if you set up correctly.
I would hardwire the CS pin on the display to activate the SPI, so 1 less thing to care about. Also I would check the transmitter’s speed, maybe it’s too fast for the display.
I made those connections:
Display – RePhone breakout
MOSI – Digital 4
SCLK – Digital 2
CS – Digital 14
RST – Digital 13
DC – Digital 15
Since the display is running at 3.3v, I have 2 Logic Level Convertors between the display and the breakout board, first LLC is for MOSI and SCLK, which are at 2.8V on the breakout and the second LLC is for CS, RST and DC, which are at 1.8V.
The transmitter’s speed is the same on RePhone SPI and on Arduino SPI.
CS pin needs to be connected because it’s going LOW - HIGH - LOW when data is sent to the display.
Display – RePhone breakout
MOSI – Digital 4: SPI_SCK
SCLK – Digital 2: CTP_SDA
CS – Digital 14: MICBIAS
RST – Digital 13: ACCDET
DC – Digital 15: AU_VIN1_N
Also, the datasheet says
“Vdd = 2.4V to 3.5V” - you should check if the display works with power supply as low as 2.8V. If yes, throw out the level converters, so one less thing to care about and one less thing that can mess up things.
And to the CS pin: can you please try the display with your uno, with CS pin fixed to GND? I am curious now, because the datasheet is not exact about it. As far as I know, it must work with CS fix pulled to GND.
So my guess is
maybe wrong connected pins
level converter messing things up (the uno uses 5V, you run on 3.3V, so 1.7V diff, but 2.8-3.3V has only 0.5V difference, so maybe it can’t drive the transistors correctly)
And the other:
CS – A4, RST – B4, DC – C4: technically they are used fot the TFT, and 1.8V pins. MAYBE their use can be problematic - I would use pins from A5, A6, B5, B6. Try to redefine the pins.
Well, out of ideas - this kind of magic needs hardware debugging, mostly with oscilloscope.
One very last thing you can try: arduino has very cool minimal programs, like the I2C reader-writer, they must have an SPI master/slave example too. Try it, and if the examples are not working, then it’s not your fault, but the arduino IDE’s.
I downloaded again the library Adafruit_SSD1331 and i got those errors.
Adafruit_SSD1331.cpp:292:64: error: 'digitalPinToPort' was not declared in this scope
sclkportreg = portOutputRegister(digitalPinToPort(_sclk));
Adafruit_SSD1331.cpp:292:65: error: 'portOutputRegister' was not declared in this scope
sclkportreg = portOutputRegister(digitalPinToPort(_sclk));
Adafruit_SSD1331.cpp:293:44: error: 'digitalPinToBitMask' was not declared in this scope
sclkpin = digitalPinToBitMask(_sclk);
Adafruit_SSD1331.cpp:310:36: error: 'digitalPinToBitMask' was not declared in this scope
cspin = digitalPinToBitMask(_cs);
Adafruit_SSD1331.cpp:311:56: error: 'digitalPinToPort' was not declared in this scope
csportreg = portOutputRegister(digitalPinToPort(_cs));
Adafruit_SSD1331.cpp:311:57: error: 'portOutputRegister' was not declared in this scope
csportreg = portOutputRegister(digitalPinToPort(_cs));
I assume you want to use the lib with the rephone, not with the uno:
it’s a classic “I put it to a wrong folder” OR “something is missing” scenario.
Very first I would check the IDE’s folders if they even implement those functions - probably some of the stock .h/.cpp files went on a vacation. (I would use the notepad++'s search text in folders function, pretty handy, you can even filter to file types unlike Windows file search) If the required functions are missing, reinstall the IDE and try again!
Also check the includes. if you found the headers with the required functions, include them, where they are required. Or move to a place where the library can access them.
If all else fails, clean up the mess, reinstall the IDE and redownload the library.
Could you show us “how”? Like you just used the sample application, you connected directly to 2.8V IO, etc. It would be great, because you made me eager to reproduce. (I have a similar display but monochrome, but it’s not working with my uno)
Even if the breakout board have SPI pins i didn’t use them. For some reasons I didn’t make them work, so I used other 2.8V pins.
So, my connections are:
Even more, i updated the example in the Adafruit_SSD1331 library in order to work by default with Rephone. You only need to change the pins, if you want.
Please notice, those libraries are for Arduino IDE for Rephone.