Problem getting SSD1306 to work on core


#1

Hi All,

I am attempting the most basic test. I have copied the Adafruit_GFX h and cpp libs to the core IDE, and the Adafruit_SSD1306 files too. Using the “+” method of adding libraries.

I have also simply copied the test code from the SSD1306 library area with NO changes at all.

It doesn’t compile. Here are the errors. Where am I going wrong? I have had my display work previously and now it won’t.

How can I do an absolute basic SSD1306 test?

thanks
Steve


In file included from ../inc/spark_wiring.h:29:0,
from ../inc/application.h:29,
from Adafruit_GFX/Adafruit_GFX.h:4,
from Adafruit_GFX/Adafruit_GFX.cpp:34:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
#warning "Defaulting to Release Build"
^
In file included from ../inc/spark_wiring.h:29:0,
from ../inc/application.h:29,
from Adafruit_GFX.h:4,
from Adafruit_GFX.cpp:34:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
#warning "Defaulting to Release Build"
^
In file included from ../inc/spark_wiring.h:29:0,
from ../inc/application.h:29,
from Adafruit_SSD1306/Adafruit_GFX.h:4,
from Adafruit_SSD1306/Adafruit_GFX.cpp:34:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
#warning "Defaulting to Release Build"
^
In file included from ../inc/spark_wiring.h:29:0,
from ../inc/application.h:29,
from Adafruit_SSD1306/Adafruit_GFX.h:4,
from Adafruit_SSD1306/Adafruit_SSD1306.cpp:19:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
#warning "Defaulting to Release Build"
^
In file included from ../inc/spark_wiring.h:29:0,
from ../inc/application.h:29,
from Adafruit_GFX.h:4,
from Adafruit_SSD1306.cpp:19:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
#warning "Defaulting to Release Build"
^
In file included from ../inc/spark_wiring.h:29:0,
from ../inc/application.h:29,
from the_user_app.cpp:2:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
#warning "Defaulting to Release Build"
^
In file included from the_user_app.cpp:26:0:
Adafruit_SSD1306.h:109:7: error: redefinition of 'class Adafruit_SSD1306'
class Adafruit_SSD1306 : public Adafruit_GFX { 
^
In file included from the_user_app.cpp:2:0:
Adafruit_SSD1306.h:109:7: error: previous definition of 'class Adafruit_SSD1306'
class Adafruit_SSD1306 : public Adafruit_GFX { 
^
make: *** [the_user_app.o] Error 1

Flash unsuccessful.

#2

First a tip. If you click the button up above the comment box that looks like </>, you can make code/output text look pretty.

Something like this

Second, I’m a little unclear as to what you’re doing? Are you just directly adding the github repo, or copying and pasting the text. The spark is different enough that #include directives often have to be modified. The error that you are getting at the end error: redefinition of 'class Adafruit_SSD1306' is a result of a file being included more than once. That can be rectified by a statement in your header file that looks like:

#ifndef __OUR_LIBRARY_H
#define __OUR_LIBRARY_H
//all code goes here

#endif

#3

OK thanks for the code tip. I will edit to clean up.
I have basically copied the code from the individual GITHUB files to the IDE.


#4

Well, just glancing at the github code, you’ll at least need to change the beginning of the header file from

#if ARDUINO >= 100
 #include "Arduino.h"
 #define WIRE_WRITE Wire.write
#else
 #include "WProgram.h"
  #define WIRE_WRITE Wire.send
#endif

#ifdef __SAM3X8E__
 typedef volatile RwReg PortReg;
 typedef uint32_t PortMask;
#else
  typedef volatile uint8_t PortReg;
  typedef uint8_t PortMask;
#endif

#include <SPI.h>
#include <Adafruit_GFX.h>

to:

#include "application.h"
#include <Adafruit_GFX.h>

typedef volatile uint8_t PortReg;
typedef uint8_t PortMask;

Also, you’ll have to modify similar things in the GFX library, and probably source code files (cpp) .


#5

@InventorSteve, as you found out, the present library was posted before many new changes to the IDE were made. This makes it difficult to compile as-is. Unfortunately, the original github repo is not available for posting any pull requests for changes. I created the original library for this display and I will put up a new library that uses the Adafruit_mfGFX (multi-font) library I also posted. I’ll try and get that done today. :smile:


#6

Thanks again for taking the time to respond.
I did manage to get it to work by stripping back to absolute basic code. Not Perfect but it got me moving again.
Steve


#7

Peekay123 Are there any updates on a working SSD1306 library?


#8

There are a few threads about the SSD1306; I’m posting to this one since the last post is relatively recent.

I’m also trying to get this working. In fact, I do have it working with my Adafruit 128x32 I2C display, but the display’s output is squished, probably because the Adafruit_SSD1306.h file has “#define SSD1306_128_64”. I’ve tried to copy that .h file into a tab in the on-line editor, but when I comment out the #define line for that .h file and compile, I get

hotfishies.cpp:26:1: error: 'Adafruit_SSD1306' does not name a type
   3 pins are required to interface (2 I2C and one reset)
  hotfishies.cpp: In function 'void setup()':
  hotfishies.cpp:65:3: error: 'display' was not declared in this scope
     0B00011111, 0B11111100,
  hotfishies.cpp:65:17: error: 'SSD1306_SWITCHCAPVCC' was not declared in this scope
     0B00011111, 0B11111100,

and so on. I must be missing something simple/fundamental but I can’t figure it out… Whassupwiddat?

BTW here’s the first few lines of my program, with the last line resulting in the first error shown above.

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

#define OLED_RESET D4
Adafruit_SSD1306 display(OLED_RESET);

edit: I’ve seen this more than once: the error listing includes text from the comment header. I"m assuming this is a bug in the editor and not related to my problem.

/*********************************************************************
This is an example for our Monochrome OLEDs based on SSD1306 drivers

  Pick one up today in the adafruit shop!
  ------> http://www.adafruit.com/category/63_98

This example is for a 128x32 size display using I2C to communicate
**3 pins are required to interface (2 I2C and one reset)**
....

thanks,

Dave.


#9

@blave, as you know, the web IDE does not allow changes to the library files. If you want to modify the #define, you will need to copy ALL the library files to tabs in your code so it will work. Otherwise, I strongly suggest using Spark CLI or DEV to compile “locally” (using the cloud compile server). With CLI or DEV, you simple copy all files (library files and example code or your own app) to a single directory and compile the directory. :smile:


#10

I’m having a similar issue as Inventor Steve. I’m trying to use the SSD1306 128x64 display and have copied in my Particle IDE tabs:

ssd1306-128x64-i2c.ino
Adafruit_GFX.h
Adafruit_GFX.cpp
Adafruit_SSD1306.h
Adafruit_SSD1306.cpp

I have coped the code directly to these tabs without changing anything and I’m having the following errors and not sure what to do at this point. I have seen the other post pertaining to the SSD1306 but can’t make sense of how it might apply to my errors.

Adafruit_GFX.cpp:37:0: warning: "pgm_read_byte" redefined [enabled by default]
 #define pgm_read_byte(addr) (*(const unsigned char *)(addr))
 ^
In file included from ../wiring/inc/spark_wiring.h:37:0,
                 from ./inc/application.h:36,
                 from Adafruit_GFX.h:4,
                 from Adafruit_GFX.cpp:34:
../wiring/inc/spark_wiring_arduino.h:32:0: note: this is the location of the previous definition
 #define pgm_read_byte(x)  (*(x))
 ^
Adafruit_SSD1306/Adafruit_GFX.cpp:36:0: warning: "pgm_read_byte" redefined [enabled by default]
 #define pgm_read_byte(addr) (*(const unsigned char *)(addr))
 ^
In file included from ../wiring/inc/spark_wiring.h:37:0,
                 from ./inc/application.h:36,
                 from Adafruit_SSD1306/Adafruit_GFX.h:4,
                 from Adafruit_SSD1306/Adafruit_GFX.cpp:34:
../wiring/inc/spark_wiring_arduino.h:32:0: note: this is the location of the previous definition
 #define pgm_read_byte(x)  (*(x))
 ^
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::invertDisplay(bool)':
Adafruit_SSD1306/Adafruit_GFX.cpp:420: multiple definition of `Adafruit_GFX::drawLine(short, short, short, short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):Adafruit_GFX.cpp:421: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::drawRoundRect(short, short, short, short, short, unsigned short)':
Adafruit_SSD1306/Adafruit_GFX.cpp:462: multiple definition of `Adafruit_GFX::drawRect(short, short, short, short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):Adafruit_GFX.cpp:463: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::drawFastVLine(short, short, short, unsigned short)':
Adafruit_SSD1306/Adafruit_GFX.cpp:470: multiple definition of `Adafruit_GFX::drawFastVLine(short, short, short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):Adafruit_GFX.cpp:471: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::drawFastHLine(short, short, short, unsigned short)':
Adafruit_SSD1306/Adafruit_GFX.cpp:476: multiple definition of `Adafruit_GFX::drawFastHLine(short, short, short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):Adafruit_GFX.cpp:477: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::fillRect(short, short, short, short, unsigned short)':
Adafruit_SSD1306/Adafruit_GFX.cpp:482: multiple definition of `Adafruit_GFX::fillRect(short, short, short, short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):Adafruit_GFX.cpp:483: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::fillScreen(unsigned short)':
Adafruit_SSD1306/Adafruit_GFX.cpp:489: multiple definition of `Adafruit_GFX::fillScreen(unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):Adafruit_GFX.cpp:490: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::invertDisplay(bool)':
Adafruit_SSD1306/Adafruit_GFX.cpp:727: multiple definition of `Adafruit_GFX::invertDisplay(bool)'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):Adafruit_GFX.cpp:728: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::Adafruit_GFX(short, short)':
Adafruit_SSD1306/Adafruit_GFX.cpp:297: multiple definition of `Adafruit_GFX::Adafruit_GFX(short, short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):Adafruit_GFX.cpp:298: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::Adafruit_GFX(short, short)':
Adafruit_SSD1306/Adafruit_GFX.cpp:297: multiple definition of `Adafruit_GFX::Adafruit_GFX(short, short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):Adafruit_GFX.cpp:298: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::drawCircle(short, short, short, unsigned short)':
Adafruit_SSD1306/Adafruit_GFX.cpp:311: multiple definition of `Adafruit_GFX::drawCircle(short, short, short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):Adafruit_GFX.cpp:312: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::drawCircleHelper(short, short, short, unsigned char, unsigned short)':
Adafruit_SSD1306/Adafruit_GFX.cpp:345: multiple definition of `Adafruit_GFX::drawCircleHelper(short, short, short, unsigned char, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):Adafruit_GFX.cpp:346: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::fillCircleHelper(short, short, short, unsigned char, short, unsigned short)':
Adafruit_SSD1306/Adafruit_GFX.cpp:388: multiple definition of `Adafruit_GFX::fillCircleHelper(short, short, short, unsigned char, short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):Adafruit_GFX.cpp:389: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::fillCircle(short, short, short, unsigned short)':
Adafruit_SSD1306/Adafruit_GFX.cpp:381: multiple definition of `Adafruit_GFX::fillCircle(short, short, short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):Adafruit_GFX.cpp:382: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::drawRoundRect(short, short, short, short, short, unsigned short)':
Adafruit_SSD1306/Adafruit_GFX.cpp:495: multiple definition of `Adafruit_GFX::drawRoundRect(short, short, short, short, short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):Adafruit_GFX.cpp:496: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::fillRoundRect(short, short, short, short, short, unsigned short)':
Adafruit_SSD1306/Adafruit_GFX.cpp:510: multiple definition of `Adafruit_GFX::fillRoundRect(short, short, short, short, short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):Adafruit_GFX.cpp:511: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::drawTriangle(short, short, short, short, short, short, unsigned short)':
Adafruit_SSD1306/Adafruit_GFX.cpp:522: multiple definition of `Adafruit_GFX::drawTriangle(short, short, short, short, short, short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):Adafruit_GFX.cpp:523: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::fillTriangle(short, short, short, short, short, short, unsigned short)':
Adafruit_SSD1306/Adafruit_GFX.cpp:531: multiple definition of `Adafruit_GFX::fillTriangle(short, short, short, short, short, short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):Adafruit_GFX.cpp:532: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::drawBitmap(short, short, unsigned char const*, short, short, unsigned short)':
Adafruit_SSD1306/Adafruit_GFX.cpp:608: multiple definition of `Adafruit_GFX::drawBitmap(short, short, unsigned char const*, short, short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):Adafruit_GFX.cpp:609: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::drawChar(short, short, unsigned char, unsigned short, unsigned short, unsigned char)':
Adafruit_SSD1306/Adafruit_GFX.cpp:641: multiple definition of `Adafruit_GFX::drawChar(short, short, unsigned char, unsigned short, unsigned short, unsigned char)'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):Adafruit_GFX.cpp:642: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::write(unsigned char)':
Adafruit_SSD1306/Adafruit_GFX.cpp:621: multiple definition of `Adafruit_GFX::write(unsigned char)'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):Adafruit_GFX.cpp:622: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::setCursor(short, short)':
Adafruit_SSD1306/Adafruit_GFX.cpp:675: multiple definition of `Adafruit_GFX::setCursor(short, short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):Adafruit_GFX.cpp:676: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::setTextSize(unsigned char)':
Adafruit_SSD1306/Adafruit_GFX.cpp:680: multiple definition of `Adafruit_GFX::setTextSize(unsigned char)'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):Adafruit_GFX.cpp:681: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::setTextColor(unsigned short)':
Adafruit_SSD1306/Adafruit_GFX.cpp:686: multiple definition of `Adafruit_GFX::setTextColor(unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):Adafruit_GFX.cpp:687: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::setTextColor(unsigned short, unsigned short)':
Adafruit_SSD1306/Adafruit_GFX.cpp:690: multiple definition of `Adafruit_GFX::setTextColor(unsigned short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):Adafruit_GFX.cpp:691: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::setTextWrap(bool)':
Adafruit_SSD1306/Adafruit_GFX.cpp:695: multiple definition of `Adafruit_GFX::setTextWrap(bool)'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):Adafruit_GFX.cpp:696: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::getRotation()':
Adafruit_SSD1306/Adafruit_GFX.cpp:700: multiple definition of `Adafruit_GFX::getRotation()'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):Adafruit_GFX.cpp:701: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::setRotation(unsigned char)':
Adafruit_SSD1306/Adafruit_GFX.cpp:703: multiple definition of `Adafruit_GFX::setRotation(unsigned char)'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):Adafruit_GFX.cpp:704: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::width()':
Adafruit_SSD1306/Adafruit_GFX.cpp:721: multiple definition of `Adafruit_GFX::width()'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):Adafruit_GFX.cpp:722: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::height()':
Adafruit_SSD1306/Adafruit_GFX.cpp:725: multiple definition of `Adafruit_GFX::height()'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):Adafruit_GFX.cpp:726: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):(.rodata._ZTV12Adafruit_GFX+0x0): multiple definition of `vtable for Adafruit_GFX'
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):(.rodata._ZTV12Adafruit_GFX+0x0): first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o): In function `Adafruit_SSD1306::stopscroll()':
Adafruit_SSD1306/Adafruit_SSD1306.cpp:459: multiple definition of `Adafruit_SSD1306::drawFastHLine(short, short, short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o):Adafruit_SSD1306.cpp:460: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o): In function `Adafruit_SSD1306::drawFastHLineInternal(short, short, short, unsigned short)':
Adafruit_SSD1306/Adafruit_SSD1306.cpp:528: multiple definition of `Adafruit_SSD1306::drawFastVLine(short, short, short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o):Adafruit_SSD1306.cpp:529: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o): In function `Adafruit_SSD1306::drawPixel(short, short, unsigned short)':
Adafruit_SSD1306/Adafruit_SSD1306.cpp:96: multiple definition of `Adafruit_SSD1306::drawPixel(short, short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o):Adafruit_SSD1306.cpp:97: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o): In function `Adafruit_SSD1306::Adafruit_SSD1306(signed char, signed char, signed char, signed char, signed char)':
Adafruit_SSD1306/Adafruit_SSD1306.cpp:124: multiple definition of `Adafruit_SSD1306::Adafruit_SSD1306(signed char, signed char, signed char, signed char, signed char)'
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o):Adafruit_SSD1306.cpp:125: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o): In function `Adafruit_SSD1306::Adafruit_SSD1306(signed char, signed char, signed char, signed char, signed char)':
Adafruit_SSD1306/Adafruit_SSD1306.cpp:124: multiple definition of `Adafruit_SSD1306::Adafruit_SSD1306(signed char, signed char, signed char, signed char, signed char)'
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o):Adafruit_SSD1306.cpp:125: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o): In function `Adafruit_SSD1306::Adafruit_SSD1306(signed char, signed char, signed char)':
Adafruit_SSD1306/Adafruit_SSD1306.cpp:134: multiple definition of `Adafruit_SSD1306::Adafruit_SSD1306(signed char, signed char, signed char)'
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o):Adafruit_SSD1306.cpp:135: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o): In function `Adafruit_SSD1306::Adafruit_SSD1306(signed char, signed char, signed char)':
Adafruit_SSD1306/Adafruit_SSD1306.cpp:134: multiple definition of `Adafruit_SSD1306::Adafruit_SSD1306(signed char, signed char, signed char)'
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o):Adafruit_SSD1306.cpp:135: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o): In function `Adafruit_SSD1306::Adafruit_SSD1306(signed char)':
Adafruit_SSD1306/Adafruit_SSD1306.cpp:142: multiple definition of `Adafruit_SSD1306::Adafruit_SSD1306(signed char)'
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o):Adafruit_SSD1306.cpp:143: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o): In function `Adafruit_SSD1306::Adafruit_SSD1306(signed char)':
Adafruit_SSD1306/Adafruit_SSD1306.cpp:142: multiple definition of `Adafruit_SSD1306::Adafruit_SSD1306(signed char)'
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o):Adafruit_SSD1306.cpp:143: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o): In function `Adafruit_SSD1306::ssd1306_command(unsigned char)':
Adafruit_SSD1306/Adafruit_SSD1306.cpp:272: multiple definition of `Adafruit_SSD1306::ssd1306_command(unsigned char)'
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o):Adafruit_SSD1306.cpp:273: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o): In function `Adafruit_SSD1306::begin(unsigned char, unsigned char)':
Adafruit_SSD1306/Adafruit_SSD1306.cpp:149: multiple definition of `Adafruit_SSD1306::begin(unsigned char, unsigned char)'
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o):Adafruit_SSD1306.cpp:150: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o): In function `Adafruit_SSD1306::invertDisplay(unsigned char)':
Adafruit_SSD1306/Adafruit_SSD1306.cpp:265: multiple definition of `Adafruit_SSD1306::invertDisplay(unsigned char)'
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o):Adafruit_SSD1306.cpp:266: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o): In function `Adafruit_SSD1306::startscrollright(unsigned char, unsigned char)':
Adafruit_SSD1306/Adafruit_SSD1306.cpp:297: multiple definition of `Adafruit_SSD1306::startscrollright(unsigned char, unsigned char)'
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o):Adafruit_SSD1306.cpp:298: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o): In function `Adafruit_SSD1306::startscrollleft(unsigned char, unsigned char)':
Adafruit_SSD1306/Adafruit_SSD1306.cpp:312: multiple definition of `Adafruit_SSD1306::startscrollleft(unsigned char, unsigned char)'
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o):Adafruit_SSD1306.cpp:313: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o): In function `Adafruit_SSD1306::startscrolldiagright(unsigned char, unsigned char)':
Adafruit_SSD1306/Adafruit_SSD1306.cpp:327: multiple definition of `Adafruit_SSD1306::startscrolldiagright(unsigned char, unsigned char)'
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o):Adafruit_SSD1306.cpp:328: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o): In function `Adafruit_SSD1306::startscrolldiagleft(unsigned char, unsigned char)':
Adafruit_SSD1306/Adafruit_SSD1306.cpp:344: multiple definition of `Adafruit_SSD1306::startscrolldiagleft(unsigned char, unsigned char)'
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o):Adafruit_SSD1306.cpp:345: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o): In function `Adafruit_SSD1306::stopscroll()':
Adafruit_SSD1306/Adafruit_SSD1306.cpp:358: multiple definition of `Adafruit_SSD1306::stopscroll()'
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o):Adafruit_SSD1306.cpp:359: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o): In function `Adafruit_SSD1306::dim(bool)':
Adafruit_SSD1306/Adafruit_SSD1306.cpp:364: multiple definition of `Adafruit_SSD1306::dim(bool)'
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o):Adafruit_SSD1306.cpp:365: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o): In function `Adafruit_SSD1306::ssd1306_data(unsigned char)':
Adafruit_SSD1306/Adafruit_SSD1306.cpp:382: multiple definition of `Adafruit_SSD1306::ssd1306_data(unsigned char)'
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o):Adafruit_SSD1306.cpp:383: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o): In function `Adafruit_SSD1306::display()':
Adafruit_SSD1306/Adafruit_SSD1306.cpp:403: multiple definition of `Adafruit_SSD1306::display()'
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o):Adafruit_SSD1306.cpp:404: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o): In function `Adafruit_SSD1306::clearDisplay()':
Adafruit_SSD1306/Adafruit_SSD1306.cpp:446: multiple definition of `Adafruit_SSD1306::clearDisplay()'
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o):Adafruit_SSD1306.cpp:447: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o):(.rodata._ZTV16Adafruit_SSD1306+0x0): multiple definition of `vtable for Adafruit_SSD1306'
../../../build/target/user/platform-6/libuser.a(Adafruit_SSD1306.o):(.rodata._ZTV16Adafruit_SSD1306+0x0): first defined here
../../../build/target/wiring/platform-6-m//libwiring.a(spark_wiring_random.o): In function `randomSeed(unsigned int)':
/mnt/compile-service-shared-workspace/6_platform_6_20_4/firmware/wiring/src/spark_wiring_random.cpp:5: multiple definition of `random(int)'
../../../build/target/user/platform-6/libuser.a(ssd1306_128x64_i2c.o):ssd1306_128x64_i2c.cpp:33: first defined here
collect2: error: ld returned 1 exit status
make: *** [b3f40aec0d6a68a783957755ef8289493bd84e3dbb18511c0352fff7059e.elf] Error 1

#11

Try the suggestions in this thread
Adafruit SSD1306 [SOLVED]

Although this mainly deals with SPI the code alterations are still valid for I2C too.
Just use the Web IDE library with the example - no need to add file tabs and copy-paste the lib code (unless you need to alter the lib for other reasons).

Don’t import Adafruit_GFX library as it is already present in the SSD library (and in your project as seperate project files).
This is most likely the reason for all these

... multiple definition of  ...

BTW: This is a bit ambigous

There are two Particle IDEs - Particle Build (aka Web IDE) and Particle Dev
Which one are you using?
The suggestions above apply to Particle Build, which I’d recommend for starters.


#12

Thanks for the quick reply. I’m using the Particle Build and the reason I’m adding .h and .cpp files into new tabs manually is because I get this error if I try “using this example”:

ssd1306_128x64_i2c.cpp:19:26: fatal error: Adafruit_GFX.h: No such file or directory
 int random(int maxRand);
                          ^
		
	

	
		compilation terminated.
make[1]: *** [../build/target/user/platform-6ssd1306_128x64_i2c.o] Error 1
make: *** [user] Error 2

	



    
  

  

  
    Error: Could not compile. Please review your code.

I’m not understanding this error because the Adafruit_GFX.h, Adafruit_GFX.cpp, Adafruit_SSD1306.h, Adafruit_SSD1306.cpp files are all included in the “Included Libraries” see pic.

Then if I take the suggestions from ScruffR in “Adafruit SSD1306 [SOLVED]” and change includes to the following I get errors about “pgm_read_byte” in the wiring.h.

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

I gets errors both ways…


#13

I think you have missed this part of the quoted post

The message about pgm_read_byte is not an error but a warning which does not cause your build to fail.
Only errors do like this one


#14

The code compiles now however nothing displays. So I tried another route from Carsten4207 on the thread titled “OLED 128x64 i2c help and advice”. I’m not sure why it doesn’t display anything but for the sake of momentum I don’t care. Thanks for your help, the little guy is working and I can continue on with the project.

OLED 128x64 i2c help and advice.

#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);
}


#15

I see, your breakout looks different to mine. I’ve actually got a combined SPI/I2C board for which the original address works.
That shows once more that SSD1306 is not SSD1306 :wink:

However, good to know you got yours working :+1:


#16

For the record…


#17

You need 4.7k pull up resistors on SDA and SCL. I have the same display and posted my wiring in one of the many OLED display threads. I’m sure there is a way to find my posts and find it.


#18

Thank you Luke for your reply. Can you explain why I would need them?


#19

If it is working (hard to tell from your last post) then leave it be but I have that same display and it didn’t work without pullup resistors. I don’t exactly know the electrical “why” but received that suggestion when I was trying to get mine to work and that fixed it for me.


#20

Sorry yes it is working without the resistors.