Adafruit SSD1306 [SOLVED]

I have mine on I2C and its plenty fast. I also have one wire temp sensor and dht11 on it. I can snap a pic if you want to replicate my setup. All breadboard right now.

Nothing there really helps me. Looks like there’s a lot of problems with different parts of the Adafruit library. To get further, I forked the SPI library and converted it for Particle, but then I quickly run up against another library that either can’t be found and/or needs to be updated. I knew the Photon wasn’t an arduino, but I thought arduino libraries would would work. Sigh.

It’s not an I2X issue, it’s an Adafruit library issue.

Post your code and I’ll see if I can help. Also layout your pin mappings if you don’t mind.

A bit sacrilegious but I prefer to use Particle Dev [Download here][1] work local, compile in Particle Cloud and flash straight from the IDE. Then to use a lib I find the lib I want, download it from github, put it in the same folder as my main program (whatever.ino) and edit it to suit my needs. Don’t create subfolders, it won’t compile… Here is an example of an nRF24 scanner I wrote, that uses a 128x64 oled and the lib that @peekay123 ported.

You can see the file layout and the adafruit #defines and display.begin statements are all you need to start outputting to your oled after that. For “hello world” you would add the line

display.println("Hello World");
display.display();

. display.println means write with a carriage return after it and display.display() tells the display to update with the data in the buffer which you sent with the display.println command. Does that help?
[1]: https://www.particle.io/dev

Hey Luke,

if i have an OLED 0.96inch 12864 display module blue, am i able to use this same Adafruit library that @peekay123 ported? and if so (and i know this is asking a lot) where can i find a step by step setup (setup pins, import adafruit lib correctly in particle dev etc) ?? Thanks with any help. Ive had my new photon kit for 2 weeks now and cant seem to get the oled working. Im still new to this micro controller process so I’ve only been able to do the blink led part but beyond that, its all still real confusing for me.

I see similar requests quite often, I’ll try to do an unofficial tutorial tomorrow. I’m no expert and Particle is the first microcontroller I used as well but the community was helpful and got me through it. As general advice:
search lots and often, ask questions when you have error, ask questions that indicate you’ve tried/researched throughly and be willing to fail. I’m a try it and see kind of guy and its served me well on here! Happy to help in the ways I can…stay tuned.

1 Like

The Adafruit_SSD1306 library that can be found in Particle Build (Web IDE) does work for the display coming with the kit.

If building in Particle Build (Web IDE) you need to change the includes in the demos to

// e.g.  ssd1306-128x64-spi.ino

#include "Adafruit_SSD1306/Adafruit_GFX.h"
#include "Adafruit_SSD1306/Adafruit_SSD1306.h"

If building with Particle Dev or CLI just leave them as they are

For all IDEs do the wiring like this

// use hardware SPI
// OLED_D0 -> A3 (SPI CLK)
// OLED_D1 -> A5 (SPI MOSI)
#define OLED_DC     D3
#define OLED_CS     D4
#define OLED_RESET  D5

and you need to remove the function (which is some sort of residue of former firmware needs ;-))

int random(int maxRand) {
    return rand() % maxRand;
}
3 Likes

Thanks @ScruffR , I’m trying that out now. Will let you know if i can get up and working.

It didn’t work for me. Got Error: “build didn’t produce binary Error: Command…” . Thanks for the help alot (I’ve been trying to get at least something “Hello World” on the screen for 2 weeks), i didn’t think it would be this difficult to get products from the Photon kit up and working. I guess Blink LED is the only good deed for beginners.

can you post some more of your error output?

What IDE are you using?

just a quick check (probably not the issue), because so far I have done this everytime I create a new module for the particle… Make sure to use .cpp NOT .c.

1 Like

@ScruffR using Particle Dev. I will re-hook things up and screen shot errors. It was in red at the bottom of Particle Dev. Steps i took: I downloaded the github repo for the library and just changed the things you said change and that error is what came up. I will post screen shots in a sec. brb

@ScruffR #1. Here is my setup with the oled. using your #define D3, D4 & D5 hookup.

#2. Here was the first error after i tried to compile code “No such file” but i deleted the Adafruit_SSD1306

#3. Here is what i had next after I compile but the error is “build didn’t produce binary Error: Comman…”

#4. This is how my folder looks in Particle Dev with the downloaded repo from github. Thanks a lot for your help.

OK, my suggestion to change the #include statements refered to Particle Build (Web IDE). (I’ve added a more explicit comment to reflect this even more clearly)
In Particle Dev you keep the original includes.

And …

… and I think this is the issue …

in Particle Dev you need to remove all non .h/.cpp files except the one .ino you actually want to build.
If you have more than one .ino the compiler doesn’t know which example you actually want in your firmware.

It’s a bit confusing that you don’t get a clearer error message from Dev (yet?).

1 Like

Ok, i will try this and see if that works. Thanks again for the help.

Code compiles with no errors now but Oled Screen is still blank lol I flash the code to my Core and its just blank oled screen. Is it something else I’m suppose to do to have the “Hello World” show up on the screen?

Cut and paste the setup() and loop() code please.

1 Like

#1. setup() & loop() code:

void setup()   {
  Serial.begin(9600);

  // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
  display.begin(SSD1306_SWITCHCAPVCC);
  // init done

  display.display(); // show splashscreen
  delay(2000);
  display.clearDisplay();   // clears the screen and buffer

  // draw a single pixel
  display.drawPixel(10, 10, WHITE);
  display.display();
  delay(2000);
  display.clearDisplay();

  // draw many lines
  testdrawline();
  display.display();
  delay(2000);
  display.clearDisplay();

  // draw rectangles
  testdrawrect();
  display.display();
  delay(2000);
  display.clearDisplay();

  // draw multiple rectangles
  testfillrect();
  display.display();
  delay(2000);
  display.clearDisplay();

  // draw mulitple circles
  testdrawcircle();
  display.display();
  delay(2000);
  display.clearDisplay();

  // draw a white circle, 10 pixel radius
  display.fillCircle(display.width()/2, display.height()/2, 10, WHITE);
  display.display();
  delay(2000);
  display.clearDisplay();

  testdrawroundrect();
  delay(2000);
  display.clearDisplay();

  testfillroundrect();
  delay(2000);
  display.clearDisplay();

  testdrawtriangle();
  delay(2000);
  display.clearDisplay();

  testfilltriangle();
  delay(2000);
  display.clearDisplay();

  // draw the first ~12 characters in the font
  testdrawchar();
  display.display();
  delay(2000);
  display.clearDisplay();

  // draw scrolling text
  testscrolltext();
  delay(2000);
  display.clearDisplay();

  // text display tests
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.println("Hello, world!");
  display.setTextColor(BLACK, WHITE); // 'inverted' text
  display.println(3.141592);
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.print("0x"); display.println(0xDEADBEEF, HEX);
  display.display();
  delay(2000);

  // miniature bitmap display
  display.clearDisplay();
  display.drawBitmap(30, 16,  logo16_glcd_bmp, 16, 16, 1);
  display.display();

  // invert the display
  display.invertDisplay(true);
  delay(1000);
  display.invertDisplay(false);
  delay(1000);

  // draw a bitmap icon and 'animate' movement
  testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_HEIGHT, LOGO16_GLCD_WIDTH);
}


void loop() {

}

@LukeUSMC its the same code from @peekay123 Github https://github.com/pkourany/Adafruit_SSD1306

I'll have to test with Paul's (peekay123) code, since I used the WebIDE one - maybe there is a difference in the wiring.


Edit:
OK, I have tried Paul's code as is in https://github.com/pkourany/Adafruit_SSD1306/blob/master/ssd1306_128x64_spi.ino
and it works as expected.

So I'd take a closer look at your wiring.

If your photo from above is still the state you are using it, you've missed this part of my previous post

2 Likes

Will try it now. Thanks