How to install OLED 128x64 - compile error - (Solved)

Hey all,

Im a trying to install OLED 128x64 with SSD1306 on a Particle Electron but i do get compile error.

Here is my setup:

OLED 128x64 and Particle Electron

Pin-out
(OLED) -> (Particle Electron)
GND -> GND
VCC -> 3V3
SCL -> D1
SDA -> D0


Compile error.

lib/Adafruit_SSD1306/src/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 lib/Adafruit_SSD1306/src/Adafruit_GFX.h:4,
                 from lib/Adafruit_SSD1306/src/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/wiring/platform-10-m//libwiring.a(spark_wiring_random.o): In function `randomSeed(unsigned int)':
/spark/compile_service/shared/workspace/10_electron_0.6.0_102_1/firmware/wiring/src/spark_wiring_random.cpp:5: multiple definition of `random(int)'
../../../build/target/user/platform-10/libuser.a(ssd1306_128x64_i2c.o):/src/ssd1306_128x64_i2c.cpp:30: first defined here
collect2: error: ld returned 1 exit status
make: *** [d5d750bc7ce445a4a4e2fc428880759167a14435d1599cd694248d45dcdd.elf] Error 1
Error: Could not compile. Please review your code.

I do just use the sample ssd1306-128x64-i2c.ino with no changes only I2C addr 0x3C (for the 128x64)


When i do try the OLED sample surfsoon-oled and again only change the I2C addr to 0x3C
Now the OLED do sign Adafruit logo and no more -it looks like it works or?

sample surfsoon-oled - Code change:

Line 18: oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3D (for the 128x64) 

But what can i do to fix the error
Thanks
BG
Meg

All fixed now.

I did use Adafruit_SSD1306 examples for ssd1306_128x64_i2c (ssd1306_128x64_i2c.ino) from github:

I did only change some few line of code:

From:
static const unsigned char PROGMEM logo16_glcd_bmp =
{ B00000000, B11000000,
B00000001, B11000000,
B00000001, B11000000,
B00000011, B11100000,
B11110011, B11100000,
B11111110, B11111000,
B01111110, B11111111,
B00110011, B10011111,
B00011111, B11111100,
B00001101, B01110000,
B00011011, B10100000,
B00111111, B11100000,
B00111111, B11110000,
B01111100, B11110000,
B01110000, B01110000,
B00000000, B00110000 };

To:

static const unsigned char PROGMEM logo16_glcd_bmp =
{ 0B00000000, 0B11000000,
0B00000001, 0B11000000,
0B00000001, 0B11000000,
0B00000011, 0B11100000,
0B11110011, 0B11100000,
0B11111110, 0B11111000,
0B01111110, 0B11111111,
0B00110011, 0B10011111,
0B00011111, 0B11111100,
0B00001101, 0B01110000,
0B00011011, 0B10100000,
0B00111111, 0B11100000,
0B00111111, 0B11110000,
0B01111100, 0B11110000,
0B01110000, 0B01110000,
0B00000000, 0B00110000 };

And did change this part:
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64)

Now it’s working

Thanks
Meg Zamani

2 Likes