Skip to content

Repository files navigation

ESP8266 - 128x64 OLED Wiring

Aim

Get a 128x64 OLED I2C Module working with a clone of the WeMos D1 Mini. Reuse the Adafruit SSD1306 library to run the demo visualisation.

Parts

  • WeMoS D1 Mini Clone (purchase on AliExpress marked as "Mini ESP8266")
         

  • OLED Module (purchase on AliExpress marked as "GM009605")
         
    Note: The "SCK" Pin maps to I2C "SCL"

  • 2x 10k Ohm 5% Resistors as Pull Up

Fritzing Breadboard Layout

Important Note Regarding Pin Definitions between ESP8266 and the Arduino IDE

The ESP2866 doesn't actually have any hardware I2C pins – those labeled on the Thing are the default, but you can actually use any two pins as SDA and SCL. Calling Wire.begin() will assume pins 2 and 14 are SDA and SCL, but you can manually set them to any other pin by calling Wire.begin([SDA], [SCL]).
(ref: Sparkfun: "Libraries Available/Not Available and the Differences")

Coding

Required Files

  • Arduino IDE v1.6.10 (see the Sparkfun guide on how to enable ESP8266 support in the IDE)
    • Download and install the Adafruit_SSD1306 and Adafruit_GFX libraries
    • Updated ssd1306_128x64_i2c example sketch (available once the Adafruit_SSD1306 library is installed and running)

Manual Update/ Patching

  1. Navigate to where the Adafruit_SSD1306.h (On Windows 10: C:\Users[username]\Documents\Arduino\libraries)

  2. Locate the following code and update as outlined to avoid the Arduino IDE error "#error("Height incorrect, please fix Adafruit_SSD1306.h!")";

    //#define SSD1306_128_64
    #define SSD1306_128_32
    // #define SSD1306_96_16

to:

```C++
#define SSD1306_128_64
//#define SSD1306_128_32
// #define SSD1306_96_16
```
  1. Save and close the Adafruit_SSD1306.h file

Arduino IDE Code

1. Within the Arduino IDE, load the ssd1306_128x64_i2c.ino example sketch from under File | Examples | Examples from Libraries | Adafruit SSD1306 2. Update the code snippet as follows;
```C++ 
#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
```

to:

```C++ 
#define SSD1306_LCDHEIGHT 64
#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
```
  1. Update the code snippet as follows;

    Wire.begin();
    Serial.begin(9600);

to:

```C++ 
Wire.begin(D1,D3); // sda, scl             
Serial.begin(57600);
```
  1. Update the code snippet as follows to change the address for the OLED display from 0x3D to 0x3C;

    display.begin(SSD1306_SWITCHCAPVCC, 0x3D);  // initialize with the I2C addr 0x3D (for the 128x64)

to:

```C++ 
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x64)
```

About

Getting the GM009605 OLED running on the ESP8266

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages