Teensy3 and SSD1306 SPI help!

Status
Not open for further replies.

ebnewt

New member
Hello PJRC!

So I have been poking around the forums and trying to set up the SSD1306 128x32 SPI display for the past few days with extremely limited success. Initially I was using the unedited Adafruit 1306 and GFX libraries and for a short time was able to have the display output a garbled/glitchy splash screen.

I have since changed the SSD1306.h over to Nick Gammon's hardware SPI to see if that would have any positive effect. At this point I'm now unable to get the Display to power up with either hardware or software SPI. Any sage advice from teensy/arduino veterans?

Code:
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define OLED_DC 8
#define OLED_CS 10
#define OLED_CLK 13
#define OLED_MOSI 11
#define OLED_RESET 7
#define LED 6

Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);

void setup(){
  pinMode(LED, OUTPUT);
  Serial.begin(9600);
  
  display.begin(SSD1306_SWITCHCAPVCC);
  display.display();
}

void loop(){
  digitalWrite(LED,HIGH);
  delay(200);
  digitalWrite(LED,LOW);
  delay(200);
}
 
I haven't tried the SSD1306 but I've managed to get the Adafruit GFX to work with a Teensy 3 and their 1.8" TFT and 128x128 OLED displays. Both software and hardware SPI worked.

Try getting the software SPI to work first. Can you view the clock, data, etc lines on a scope? Try slowing down the Teensy 3 clock speed and see if it helps. I found that at faster clocks speeds it sometimes threw off the timing of the LCD control signals. Since I had only one SPI device, tying the CS line directly to the active state would solve some timing problems.
 
You may want to try U8glib which supports the SSD1306. It also supports both hardware and software SPI. I have not tried it with the Teens 3 yet but it does support your display and from other threads on this forum, seems to work fine with hardware SPI.
 
Last edited:
image.jpg
Got the display to power on once again with software SPI, but only once. Hopefully the image will show up, I'm on the road for turkey Memorial Day. I'll give U8glib a try when I return. Unfortunately my scope is on lend.
 
ebnewt,

I have used an Xprotolab Portable from Gabotronics and it is great for debugging protocols AND it's very inexpensive. I've used mine for SPI, I2C and UART debugging. I highly recommend his products!

Paul
 
So I have been poking around the forums and trying to set up the SSD1306 128x32 SPI display for the past few days with extremely limited success. Initially I was using the unedited Adafruit 1306 and GFX libraries and for a short time was able to have the display output a garbled/glitchy splash screen.

Odd, I have the Adafruit 128x64 OLED which is also driven by SSD1306 and it works with the stock Adafruit libraries. Slowly, as the graphics implementation is inefficient and its using bit-banged SPI, but it does work I recall.

Powering up the display does require SPI (its not a simple hardware backlight, it requires instructions to switch on the voltage converter) do don't worry that you have broken it. It's probably just that SPI is not working.

Do you have another SPI device you could use with Nick Gammon's SPI library, to verify that you have SPI set up correctly? Are you using pull-up resistors and if so of what value? Do you have a scope or logic analyser to check the SPI data on the wire?
 
Do you have another SPI device you could use with Nick Gammon's SPI library, to verify that you have SPI set up correctly? Are you using pull-up resistors and if so of what value? Do you have a scope or logic analyser to check the SPI data on the wire?

I have a sd card breakout I could wire up to test spi, though the slight irony being I wanted to get the teensy hooked up to the display first for debugging purposes, then tackle the sd card...

I was under the assumption that no pull-ups were required on SPI as long as open drain wasn't enabled on those pins?

I'll throw a 10k pull up on the MOSI, SS, and SCK (forgive me if this isn't correct, I'm more of a software guy) when I get back from Thanksgiving. I don't need to do anything with the DC or Reset pins correct, or should those be pulled up as well?

Unfortunately the oscilloscope is on long term lend. I might have to look into getting a Xprotolab..
 
I got mine working with the Teensy 3.1 and hardware SPI
I posted over here:
http://forums.adafruit.com/viewtopic.php?f=25&t=46997

I used the Adafruit library with Nick Gammon's mods for hardware SPI and these pins

DC 9
CS 10
CLK 13
MOSI 11
RESET 14


Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);

//Setup display
display.begin(SSD1306_SWITCHCAPVCC);
display.setTextSize(1);
display.setTextColor(WHITE);


Next I want to try the U8GLIB library.

Hope this helps.


Edit:
Only thing with this setup CLK conflicts with use the LED.

Also it seems to work better than with the ATmega32u4, I don't get my issue with the whole display shift up after awhile.
 
Well it seems like it's been a while since the last post, but in case anyone runs into this again, I got my 128x64 SPI OLED from ElectroDragon for pretty cheap and just needed it to display
the temperature readings from a GY-906 infrared thermometer running on I2C. I used the Adafruit_SSD1306 library for the OLED and initially had trouble with it. I discovered that a change of
the RST lead from 13 to 14 got everything working, so I guess the Teensy pin 13 (LED_BUILTIN) was an issue for the library.

// If using software SPI (the default case):
#define OLED_MOSI 9
#define OLED_CLK 10
#define OLED_DC 11
#define OLED_CS 12
#define OLED_RESET 14
 
Status
Not open for further replies.
Back
Top