OLED 128x64 i2c help and advice


#1

Hey guys,
I got this cheap oled screen from china. My photon just arrived and so I decided to help our local Hacklab (maker space) in creating an rfid reader with this oled screen.

I’ve seen a few posts on the subject but am still not sure which library to use with this display? There is an Adafruit library for the 128x64 i2c board but i’m not sure it works the way I think.

Also I’ve seen this sh1106 library and post here, and Digole led library, and another Digole library.

First time working with my photon and this OLED screen so any advice or guidance about what library and examples to use are much appreciated.

Thanks,
David


Problem getting SSD1306 to work on core
#2

@synteny, welcome to Photown! :stuck_out_tongue: If you look near the bottom of this thread, you’ll find posts from someone with the exact same display:


#3

I just tested one of these yesterday. I got mine from Amazon:

I think its the same product as yours. The post from peekay123 has the wiring instructions.

Basically the address on the silkscreen of those boards are wrong. Its actually 0x3C.

Below is the code that works for me (only tested on Photon):

// This #include statement was automatically added by the Spark IDE.
#include "Adafruit_SSD1306/Adafruit_SSD1306.h"
/* ============== MAIN =====================*/

 //Use I2C with OLED RESET pin on D4
 #define OLED_RESET D4
 Adafruit_SSD1306 oled(OLED_RESET);


 unsigned long previousMillis;
 unsigned long interval = 30000;

 void setup() {
  // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
  oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3D (for the 128x64)
  // init done     
     
  //oled.display(); // show splashscreen

  Time.zone(-4);
  
   
}

void loop() {
   oled.clearDisplay();
  delay(200);
  oled.setTextSize(2);
  oled.setTextColor(WHITE);
  oled.setCursor(0,0);
  oled.print(Time.hourFormat12()); oled.print(":"); oled.print(Time.minute()); oled.print(":"); oled.print(Time.second());
  oled.setTextColor(BLACK, WHITE); // 'inverted' text
  
  oled.display();
  
  delay(800);
}

This will print the time (eastern time).


#4

@Carsten4207, thanks for the info. You rock! :wink:


#5

@Carsten4207 +1 on rocking, @peekay123 thanks for the info and the welcome. Man you guys were quick. I can’t wait to get home tonight and see what i can get done. I’ll ping back after with yay or nay and anything added i can add.

Also trying to figure out how to dim some led strip (5050 led strip) that had a remote currently hose.

Was hoping to replace my led remote with a photon magic box I got from the kickstarter :smile:

I mean i kickstarted a few so may as well use them :).


#6

Hi! What is it you connect to the reset pin when there is only 4 pins on the display? :thinking:


#7

That depends on what these pins are :wink:

But assuming they are Vcc, GND, Data & Clock, you just forget about reset (passing a dummy value e.g. -1).


#8

Do youhave a pinout on how its connected to your board? I think i’m trying to do the same thing but not sure what pins to use.


#9

Hi,
I’ve tried your code.
But it ends up to an error.

/firmware/wiring/src/spark_wiring_random.cpp:5: multiple definition of `random(int)’

Besides, there is no [#include “Adafruit_SSD1306/Adafruit_SSD1306.h”] in the library; therefore, I change it to #include “Adafruit_SSD1306.h” from particle library.

I’m using this type of OLED.

I need you and everyone consultation on this matter.

The connection of the OLED to my Particle Photon is

VCC = 3.3V
GND = GND
SCL = A5 / D1
SDA = A4 / D0

Thanks…


#10

You need to comment out the extra definition of random() in the example code.

Usually the full error log provodes you with the place of all conflicting definitions.


#11

Hi,

It looks from this post that I could use SCL = A5, SDA = A4, instead of D0/D1? If so, how do I tell the software to use those pins instead?

Thanks,

Austin


#12

Hey @ScruffR and all,

It looks like I’m in a similar situation at @Syerlac and @synteny. I’m not sure where I’m going wrong.

I have the same board as @Carsten4207 (Link) and I’m running the example code but am getting
"Adafruit_SSD1306.h: No such file or directory".

Any guidance would be greatly appreciated. I’ve reviewed a few i2c related threads and this seems like the closest one.

Was there any suggestion to @darkroom on where SCL and SDA should be wired to on a Photon?

Thanks,
Ian


#13

SDA (D0) and SCL (D1)


#14

Thanks! Do you know why I’m getting an error on the library?


#15

Double check the target version.


#16

Hi @ScruffR,

What am I checking for? Sorry if I’m being dense. I usually don’t have this error when I pull in a library.

Thanks,
Ian


#17

I meant this

The version should be 0.5.3 or later


#18

Thanks. I bumped up the target version but I’m getting the same error.

“No such file or directory”

Is there something I’m overlooking when including a library?


#19

You have clicked on the library, hit the INCLUDE IN PROJECT button and then selected the target project to import the library into?

If you have done that right, your project should look like this

You actually need to have the system “copy” the library references into your project. The #include statement alone is not enough.

One other possibility - if you’ve done it all correctly - is that you are experiencing a Web IDE glitch where you just need to change #include "Adafruit_SSD1306.h" to #include <Adafruit_SSD1306.h> or vice versa. For some reason this sometimes helps resolve the issue. After it built once you can even change it back.


#20

Thank you so much! I really appreciate it!

I can compile now :slight_smile: