Particle IoT

Interface Photon with OLED (SPI)

particle logo

Interface Photon with OLED

Want your Photon to display sensor reading or any other information. OLED display can be a perfect fit for this purpose. This is a 0.96 inch blue OLED display module. The display module can be interfaced with any microcontroller using SPI/IIC protocols. It is has a resolution of 128x64.

OLED (Organic Light-Emitting Diode) is a self light-emitting technology composed of a thin, multi-layered organic film placed between an anode and cathode. In contrast to LCD technology, OLED does not require a backlight. OLED possesses high application potential for virtually all types of displays and is regarded as the ultimate technology for the next generation of flat-panel displays.

Features:

  • OLED Driver IC: SSD1306
  • Resolution: 128 x 64
  • Visual Angle: >160°
  • Input Voltage: 3.3V ~ 6V
  • Compatible I/O Level: 3.3V, 5V
  • Mini Size: 2.7 x 2.8cm
  • Only Need 2 I/O Port to Control
  • Pixel Color: Blue
  • Full Compatible with Arduino
  • Working temperature: -30°C ~ 70°C
  • Module volume ( generous ): 27.0 x 27.0 x 4.1mm
  • Factory configured for SPI protocol (can be easily changed to IIC)

Setting up SPI/I2C Connection with GMS096A OLED Module

For the SPI setup, the module comes in 4 wire SPI configuration by default and to make it work with the arduinos you can use these libraries from Adafruit.

For the I2C setup it demands a little bit of work on the module. Start with resoldering the resistor from position R3 to R1 and then short the R8 resistor with some solder tin (0 Ohm resistor). The R6 and R7 pullup resistors are already soldered, nothing to do there. Once done, the module is ready for I2C communication! The CS Pin is not necessarily needed, so just connect it to GND. The DC Pin selects the address. For standard address wire it to GND. The RES-pin needs a low pulse at startup and high voltage during operation (as in SPI mode), a 100nF capacitor to GND and a 10k res to Vcc would be ideal!

Step 1: Materials Needed

  1. A Breadboard (http://amzn.to/2r7ysO5)
  2. Power Supply unit (http://amzn.to/2s8aWRE)
  3. Jumper Wires (http://amzn.to/2txKJuT)
  4. OLED Display(http://amzn.to/2sxy75n)

Step 2: Connect Photon with OLED (SPI)

Connect Photon with OLED as shown in the diagram.

  • D0 ---- SDA
  • D1 ---- SCK
  • D2 ---- DC
  • D3 ---- CS
  • D4 ---- RES

Step 3: Software integration for OLED

Login to the url https://build.particle.io.

Opens up the Web IDE. On the lefthand side you will see the Libraries option. Click on it and search for Adafruit_SSD1306. You have to do some modification in the example code. Please refer the video for implementation


Customise the display

Modify the example code as shown to get customised output.


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

// Uncomment this block to use hardware SPI
// If using software SPI (the default case):
#define OLED_MOSI   D0
#define OLED_CLK    D1
#define OLED_DC     D2
#define OLED_CS     D3
#define OLED_RESET  D4
Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);

#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);
    // init done
    display.display(); // show splashscreen
    delay(2000);
    display.clearDisplay();   // clears the screen and buffer
    
    // text display tests
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.setCursor(0,0);
    display.println("Hello, world!");
    display.println("");
    display.println("www.sarathiblog.com");
    display.display();
    delay(2000);
}
void loop() {
    
}
                              

Will get us the following output.