Grove128x64 OLED Display

@peekay123 can you have a look at the include file at
http://www.seeedstudio.com/wiki/File:OLED_Display12864.zip

it is the include for the Grove 128x64 OLED display at
http://www.seeedstudio.com/wiki/Grove_-_OLED_Display_0.96"#With_Arduino

I have a grove photon starter board, but want to make the connections more direct. I have looked at other community comments but I am not sure if I can just use the Adafruit include files.

I have a simple .ino but it dies on the include. Any suggestions:

#include <SeeedOLED.h>
// using Grove 128x64 OLED 
// http://www.seeedstudio.com/wiki/Grove_-_OLED_Display_0.96%22#With_Arduino

// black GND 
// red 3v3 
// white SDA    D0 needs resistors 1.5K to 10K since 5V serial
// yellow SCL   D1 needs resistors 1.5K to 10K since 5V serial

void setup()
{
  //Wire.begin();
  if ( !Wire.isEnabled() ) {
     Wire.begin();
  }
  SeeedOled.init();  //initialze SEEED OLED display
  DDRB|=0x21;        
  PORTB |= 0x21;

  SeeedOled.clearDisplay();          //clear the screen and set start position to top left corner
  SeeedOled.setNormalDisplay();      //Set display to normal mode (i.e non-inverse mode)
  SeeedOled.setPageMode();           //Set addressing mode to Page Mode
  SeeedOled.setTextXY(0,0);          //Set the cursor to Xth Page, Yth Column  
  SeeedOled.putString("Hello World!"); //Print the String

}

void loop()
{
  
}

You can give the Adafruit_SSD1306 library a try. It uses the same I2C address 0x3C as the SSD1308 from Seeed, so it might be worth a try.

Porting the 1308 lib doesn’t look to complicated either.

  • replace #include "Arduino.h" with #include "Particle.h"
  • remove #include "Wire.h" and "#include <avr/pgmspace.h>
  • wherever you find #if defined(ARDUINO) && ARDUINO >= 100 change it to #if defined(SPAR) || (defined(ARDUINO) && ARDUINO >= 100)

This should get you started.

BTW: This won’t run on Particles

  DDRB|=0x21;        
  PORTB |= 0x21;

Thanks @ScruffR . I will try both the Adafruit and porting the Grove library SeeedOLED.h .

By the way what is the following lines setting, I haven’t seen |= before?.

DDRB|=0x21;        
PORTB |= 0x21;

These are the registers of an Atmel AVR chip to set multiple pin modes for a whole port at once
DDRB is the Data Direction Register for port B.

DDRB |= 0x21; is short for DDRB = DDRB | 0b00100001; (binary OR - not to be mixed up with the boolean OR operator ||).
This sets the two bits (refering to the respective pins and set them as OUTPUT) and leaves the others untouched.

And PORTB sets the actual values of the pins HIGH or LOW for all OUTPUT pins or attaches/detaches PULLUP resistors for INPUT pins.

2 Likes

Thanks @ScruffR for the explanations and help.

@peekay123 is awesome. I tried porting the Grove file and it compiled but did not work. @peekay123 ported files at

worked immediately. Very fancy what the display can do. Remember to include the extra 4 files both .h and .cpp versions.

P.S. I never found the pins for the I2C format so guessed at it from my other file.

 SDA    D0 
 SCL   D1 

Never did figure out the reset Pin D4 but things worked so I am happy. I also did not use the protective resistors since the OLED works with 3V3.

I have re-writeen the .ino for beginners.

/*********************************************************************
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 128x64 size display using I2C to communicate
3 pins are required to interface (2 I2C and one reset)

Adafruit invests time and resources providing this open source code, 
please support Adafruit and open-source hardware by purchasing 
products from Adafruit!

Written by Limor Fried/Ladyada  for Adafruit Industries.  
BSD license, check license.txt for more information
All text above, and the splash screen must be included in any redistribution
*********************************************************************/



// Added by Jeremy Ellis
// using Grove 128x64 OLED 
// http://www.seeedstudio.com/wiki/Grove_-_OLED_Display_0.96%22#With_Arduino

// black GND 
// red 3v3      so do not need the protective resistors below
// white SDA    D0 needs resistors 1.5K to 10K since 5V serial
// yellow SCL   D1 needs resistors 1.5K to 10K since 5V serial



//used pkourany github site
//https://github.com/pkourany/Adafruit_SSD1306

// you must include the following files and the coresponding .cpp files 
// total 4 files

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

#define OLED_RESET D4
Adafruit_SSD1306 display(OLED_RESET);

#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2


#define LOGO16_GLCD_HEIGHT 16 
#define LOGO16_GLCD_WIDTH  16 



#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif

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

  // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3D (for the 128x64)
  // init done
  
  //display.display(); // show splashscreen
 // delay(2000);
  display.clearDisplay();   // clears the screen and buffer
  
  display.setTextSize(2);           // from 1-9 sensible actually can be bigger but useless
  display.setTextColor(BLACK, WHITE); // 'inverted' text
  display.setCursor(0,30);       // 128,64 pixels
  display.clearDisplay();
  display.println("Hello OLED");
  display.display();
  delay(4000);
 

  display.setTextSize(1);
  display.setTextColor(WHITE,BLACK); // Normal text
  display.setCursor(0,0);
  display.clearDisplay();
  display.println("size 1");
  display.println("size 1, line 2");
  display.display();
  delay(4000);
 

  display.clearDisplay();
  display.println("size 2");
  display.display();
  delay(1000);
 
   
  display.setTextSize(3);
  display.clearDisplay();
  display.setCursor(50,4);
  display.println("size 3");
  display.display();
  delay(1000);
 
   
  display.setTextSize(9);
  display.setCursor(0,0);
  display.clearDisplay();
  display.println("9");
  display.display();
  delay(2000);
 
   
  display.setTextSize(1);
  display.setCursor(0,0);
  display.clearDisplay();
  display.println("Good Bye");
  display.display();
  delay(2000);
 
 
  display.clearDisplay();
  display.display();
  
}
1 Like

@rocksetta, good work! Might you be interested in doing a PR against my repo? :smirk:

Done. Added a beginner.ino file and updated the readme.md

1 Like

Hi @ScruffR and @peekay123 I am porting another library this time for the BMP180 Barometer from RobotShop http://www.robotshop.com/ca/en/bmp180-barometer-module.html

I tried the library

#include "Particle_BaroSensor/Particle_BaroSensor.h"

but it has an compile issue with OneWire, even though it is in the header file

#include "OneWire/OneWire.h"

so then I tried an Arduino library at
https://github.com/sparkfun/BMP180_Breakout_Arduino_Library/archive/master.zip

and it also has an issue with the following includes. Lots of information about porting these just wondering what the up-to-date view is on porting these.

#include <Wire.h>
#include <stdio.h>
#include <math.h>

If you are building in Web IDE (which I guess from the include path), then you have to import OneWire library seperately as the include alone does not trigger a file-copy of the required files into your project folder.

Edit:
@rocksetta, sorry I didn't answer all of your questions.

These are already available for Particle.
Wire.h and stdio.h are already included via Particle.h (should be used instead of application.h) and should not be included again,
math.h is available for each platform and can be included as is.

2 Likes

Just thought I’d add here, I ported a more specific version of the Grove 128x64 OLED Display library that uses Seeedstudio’s more lightweight library, if you don’t need all the functions that come with Adafruit_GFX.

In the Particle IDE it’s called Grove_OLED_128x64. It can also be found at https://github.com/esimkowitz/Particle-Grove-OLED.

1 Like

Hello,

Can i get an OLED with Vcc_c=3 or 3.4V? please help me to get a part number associated with such an OLED.

Regards,
Vibha Desai

If you go for the "or 3.4V" part this OLED does state 3.3V as the minimum Vcc.

@vibha, also Digole makes a number of mono and color OLED and LCD “intelligent” displays that work at 3.3v (2.2v to 9v for some). They cost a little more but are great to work with.