<p><em>First of all let me state that I do not own the module! The analysis below is based on old patches that worked in a version of Marlin in 2015, and translated to the latest version of Marlin of the 1.1.x branch. This is 1.1.9; this is the last version of the 1.1.x branch, all new development takes place in branch bugfix-2.0.x (dated May 2019).</em></p>

<hr>

<p>The reported patches are compatible with an earlier version of Marlin Firmware (a version from 2015). Clearly this doesn't work anymore, but that should not be a problem, if it worked then it should work now provided we configure it correctly. The display you have requires U8GLIB_SSD1306, so the U8GLIB library need to be installed in your Arduino IDE!</p>

<p>Let's follow <a href="http://img.banggood.com/file/products/20161003040825SKU475616.pdf" rel="nofollow noreferrer">this installation guide</a> for the older version as an example.</p>

<p>First, from patch 1 it becomes clear that you'll need to define that you are using a display that is identified by its name/type, you should uncomment the following line in your <a href="https://github.com/MarlinFirmware/Marlin/blob/1.1.x/Marlin/Configuration.h" rel="nofollow noreferrer">configuration.h</a> in the section:</p>

<pre>
//=============================================================================
//======================== LCD / Controller Selection =========================
//========================   (Character-based LCDs)   =========================
//=============================================================================

</pre>

<pre>
//#define MKS_12864OLED_SSD1306  // Uses the SSD1306 controller
</pre>

<p>to:</p>

<pre>
#define MKS_12864OLED_SSD1306  // Uses the SSD1306 controller
</pre>

<p>as you are using the SSD1306 controller according to <a href="http://img.banggood.com/file/products/20161003040825SKU475616.pdf" rel="nofollow noreferrer">this reference</a>.</p>

<p>That is about the only thing you add in the <code>configuration.h</code> file! You only activate the name of the controller type (as in defining a constant) so that it is caught in other source or header files to do/trigger something.</p>

<p>With this change, you automatically activated the rest of patch as that is implemented in <a href="https://github.com/MarlinFirmware/Marlin/blob/1.1.x/Marlin/Conditionals_LCD.h" rel="nofollow noreferrer">Conditionals_LCD.h</a>!</p>

<p>Next, we need to address patch 2. This is addressed in <a href="https://github.com/MarlinFirmware/Marlin/blob/bugfix-1.1.x/Marlin/ultralcd_impl_DOGM.h" rel="nofollow noreferrer">ultralcd_impl_DOGM.h</a>; here you will find:</p>

<pre>
#elif ENABLED(MKS_12864OLED_SSD1306)
  // MKS 128x64 (SSD1306) OLED I2C LCD
  U8GLIB_SSD1306_128X64 u8g(DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, DOGLCD_A0);      // 8 stripes
  //U8GLIB_SSD1306_128X64_2X u8g(DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, DOGLCD_A0); // 4 stripes</pre>

<p>which clearly differs from the patch:</p>

<pre>
U8GLIB_SSD1306_128X64 u8g(23, 17, 16, 25); // SW SPI Com: SCK = 23, MOSI = 17, CS = 16, A0 = 25
</pre>

<p>as such that it uses numbers instead of constants. So we need to define these constants first. These constants are defined by the board you are using, more specifically the pin layout. </p>

<p>Looking at the <a href="https://github.com/MarlinFirmware/Marlin/blob/1.1.x/Marlin/pins_RAMPS.h" rel="nofollow noreferrer">pin layout of your RAMPS board</a>:</p>

<pre>
      #if ENABLED(MKS_12864OLED) || ENABLED(MKS_12864OLED_SSD1306)
        #define LCD_PINS_DC     25   // Set as output on init
        #define LCD_PINS_RS     27   // Pull low for 1s to init
        // DOGM SPI LCD Support
        #define DOGLCD_CS       16
        #define DOGLCD_MOSI     17
        #define DOGLCD_SCK      23
        #define DOGLCD_A0       LCD_PINS_DC
</pre>

<p>you'll find that the pins are correctly configured with the fore mentioned:</p>

<pre><code>U8GLIB_SSD1306_128X64 u8g(DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, DOGLCD_A0);      // 8 stripes
</code></pre>

<p>We move on to patch 3. This patch deals with the reset/initialization of the OLED display. This is also already taken care of in <a href="https://github.com/MarlinFirmware/Marlin/blob/bugfix-1.1.x/Marlin/ultralcd_impl_DOGM.h" rel="nofollow noreferrer">ultralcd_impl_DOGM.h</a>:</p>

<pre>
  #if PIN_EXISTS(LCD_RESET)
    OUT_WRITE(LCD_RESET_PIN, LOW); // perform a clean hardware reset
    _delay_ms(5);
    OUT_WRITE(LCD_RESET_PIN, HIGH);
    _delay_ms(5); // delay to allow the display to initalize
  #endif
</pre>

<p>Next to patch 4, in <a href="https://github.com/MarlinFirmware/Marlin/blob/1.1.x/Marlin/pins_RAMPS.h" rel="nofollow noreferrer">pins_RAMPS.h</a> you see that pin 25 and 27 are correctly defined (apart from the name LCD_PINS_RS<strong>T</strong>, now without <strong>T</strong>, but that is fine!):</p>

<pre><code>  #if ENABLED(MKS_12864OLED) || ENABLED(MKS_12864OLED_SSD1306)
    #define LCD_PINS_DC     25   // Set as output on init
    #define LCD_PINS_RS     27   // Pull low for 1s to init
</code></pre>

<p>The only difference is that pins</p>

<pre><code>    #define LCD_PINS_D5
    #define LCD_PINS_D6
</code></pre>

<p>are not set to -1, so to be consistent, you should change <a href="https://github.com/MarlinFirmware/Marlin/blob/1.1.x/Marlin/pins_RAMPS.h" rel="nofollow noreferrer">pins_RAMPS.h</a> to:</p>

<pre>
      #if ENABLED(MKS_12864OLED) || ENABLED(MKS_12864OLED_SSD1306)
        #define LCD_PINS_DC     25   // Set as output on init
        #define LCD_PINS_RS     27   // Pull low for 1s to init
        // DOGM SPI LCD Support
        #define DOGLCD_CS       16
        #define DOGLCD_MOSI     17
        #define DOGLCD_SCK      23
        #define DOGLCD_A0       LCD_PINS_DC
        #define LCD_PINS_D5     -1
        #define LCD_PINS_D6     -1
      #else
        #define LCD_PINS_RS     16
        #define LCD_PINS_ENABLE 17
        #define LCD_PINS_D4     23
        #define LCD_PINS_D5     25
        #define LCD_PINS_D6     27
      #endif
</pre>

<p>A conclusion from the analysis above is that you enable the display in your configuration file and add the 2 values of -1 for D5 and D6, but I don't think they cause problems if they're not initialized to -1. Be sure that the cables are connected correctly. Some modules have reported upside down connectors.</p>

CC BY-SA 4.0
2019-05-08T21:03:30.087Z
2019-05-10T21:56:48.460Z
2019-05-10T21:56:48.460Z
0scar
<p>I've bought <a href="https://reprap.org/wiki/MKS_12864OLED" rel="noreferrer">MKS 12864OLED</a> and connected to my DIY 3d printer with Mega/RAMPS combination. In Marlin's configuration.h file there are these lines to uncomment:</p>

<pre><code>// MKS OLED 1.3" 128 × 64 FULL GRAPHICS CONTROLLER
// http://reprap.org/wiki/MKS_12864OLED
//
// Tiny, but very sharp OLED display
//
//#define MKS_12864OLED          // Uses the SH1106 controller (default)
//#define MKS_12864OLED_SSD1306  // Uses the SSD1306 controller
</code></pre>

<p>I'm not sure to choose between 'SH1106' or 'SSD1306'... either way, the LCD module is not working.</p>

<p><a href="https://i.sstatic.net/LRFIX.jpg" rel="noreferrer"><img src="https://i.sstatic.net/LRFIX.jpg" alt="enter image description here"></a>
<a href="https://i.sstatic.net/oBNjU.jpg" rel="noreferrer"><img src="https://i.sstatic.net/oBNjU.jpg" alt="enter image description here"></a></p>

CC BY-SA 4.0
2019-02-12T20:44:44.447Z
Maybe you need to set more constants? E.g: #define U8GLIB_SSD1306? Also post a picture of your module front and back, e.g. is it exactly the same?
0scar
CC BY-SA 4.0
2019-02-12T20:54:43.977Z
if I uncomment that too,it says: #error "Please select no more than one LCD controller option."
2012User
CC BY-SA 4.0
2019-02-12T22:54:57.693Z
Are you aware that your module is different than the MKS from RepRap.org? You have a 0.96" display, the MKS is 1.3".
0scar
CC BY-SA 4.0
2019-02-13T00:11:43.933Z
AFAICT, he has a https://www.reprap.me/mks-12864-oled-0-96in.html
Trish
<marlin><troubleshooting><reprap><full-graphic-smart-controller>
MKS 12864OLED Display setup
2012User
# MKS 12864OLED Display setup

(Asked by: username_0 on 2019-02-12)

I've bought MKS 12864OLED and connected to my DIY 3d printer with Mega/RAMPS combination. In Marlin's configuration.h file there are these lines to uncomment:
// MKS OLED 1.3" 128 × 64 FULL GRAPHICS CONTROLLER
// http://reprap.org/wiki/MKS_12864OLED
//
// Tiny, but very sharp OLED display
//
//#define MKS_12864OLED          // Uses the SH1106 controller (default)
//#define MKS_12864OLED_SSD1306  // Uses the SSD1306 controller

I'm not sure to choose between 'SH1106' or 'SSD1306'... either way, the LCD module is not working.

**Tags:** marlin, troubleshooting, reprap, full-graphic-smart-controller
> **Comments:**
> **username_1**: Maybe you need to set more constants? E.g: #define U8GLIB_SSD1306? Also post a picture of your module front and back, e.g. is it exactly the same?  
> **username_0**: if I uncomment that too,it says: #error "Please select no more than one LCD controller option."  
> **username_1**: Are you aware that your module is different than the MKS from RepRap.org? You have a 0.96" display, the MKS is 1.3".  
> **username_2**: AFAICT, he has a https://www.reprap.me/mks-12864-oled-0-96in.html  

---

## 1 answers

### Answer by username_1 on 2019-05-08. Score: 3 | Accepted answer

First of all let me state that I do not own the module! The analysis below is based on old patches that worked in a version of Marlin in 2015, and translated to the latest version of Marlin of the 1.1.x branch. This is 1.1.9; this is the last version of the 1.1.x branch, all new development takes place in branch bugfix-2.0.x (dated May 2019).

The reported patches are compatible with an earlier version of Marlin Firmware (a version from 2015). Clearly this doesn't work anymore, but that should not be a problem, if it worked then it should work now provided we configure it correctly. The display you have requires U8GLIB_SSD1306, so the U8GLIB library need to be installed in your Arduino IDE!
Let's follow this installation guide for the older version as an example.
First, from patch 1 it becomes clear that you'll need to define that you are using a display that is identified by its name/type, you should uncomment the following line in your configuration.h in the section:

//=============================================================================
//======================== LCD / Controller Selection =========================
//========================   (Character-based LCDs)   =========================
//=============================================================================



//#define MKS_12864OLED_SSD1306  // Uses the SSD1306 controller

to:

#define MKS_12864OLED_SSD1306  // Uses the SSD1306 controller

as you are using the SSD1306 controller according to this reference.
That is about the only thing you add in the configuration.h file! You only activate the name of the controller type (as in defining a constant) so that it is caught in other source or header files to do/trigger something.
With this change, you automatically activated the rest of patch as that is implemented in Conditionals_LCD.h!
Next, we need to address patch 2. This is addressed in ultralcd_impl_DOGM.h; here you will find:

#elif ENABLED(MKS_12864OLED_SSD1306)
  // MKS 128x64 (SSD1306) OLED I2C LCD
  U8GLIB_SSD1306_128X64 u8g(DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, DOGLCD_A0);      // 8 stripes
  //U8GLIB_SSD1306_128X64_2X u8g(DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, DOGLCD_A0); // 4 stripes
which clearly differs from the patch:

U8GLIB_SSD1306_128X64 u8g(23, 17, 16, 25); // SW SPI Com: SCK = 23, MOSI = 17, CS = 16, A0 = 25

as such that it uses numbers instead of constants. So we need to define these constants first. These constants are defined by the board you are using, more specifically the pin layout. 
Looking at the pin layout of your RAMPS board:

      #if ENABLED(MKS_12864OLED) || ENABLED(MKS_12864OLED_SSD1306)
        #define LCD_PINS_DC     25   // Set as output on init
        #define LCD_PINS_RS     27   // Pull low for 1s to init
        // DOGM SPI LCD Support
        #define DOGLCD_CS       16
        #define DOGLCD_MOSI     17
        #define DOGLCD_SCK      23
        #define DOGLCD_A0       LCD_PINS_DC

you'll find that the pins are correctly configured with the fore mentioned:
U8GLIB_SSD1306_128X64 u8g(DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, DOGLCD_A0);      // 8 stripes

We move on to patch 3. This patch deals with the reset/initialization of the OLED display. This is also already taken care of in ultralcd_impl_DOGM.h:

  #if PIN_EXISTS(LCD_RESET)
    OUT_WRITE(LCD_RESET_PIN, LOW); // perform a clean hardware reset
    _delay_ms(5);
    OUT_WRITE(LCD_RESET_PIN, HIGH);
    _delay_ms(5); // delay to allow the display to initalize
  #endif

Next to patch 4, in pins_RAMPS.h you see that pin 25 and 27 are correctly defined (apart from the name LCD_PINS_RST, now without T, but that is fine!):
  #if ENABLED(MKS_12864OLED) || ENABLED(MKS_12864OLED_SSD1306)
    #define LCD_PINS_DC     25   // Set as output on init
    #define LCD_PINS_RS     27   // Pull low for 1s to init

The only difference is that pins
    #define LCD_PINS_D5
    #define LCD_PINS_D6

are not set to -1, so to be consistent, you should change pins_RAMPS.h to:

      #if ENABLED(MKS_12864OLED) || ENABLED(MKS_12864OLED_SSD1306)
        #define LCD_PINS_DC     25   // Set as output on init
        #define LCD_PINS_RS     27   // Pull low for 1s to init
        // DOGM SPI LCD Support
        #define DOGLCD_CS       16
        #define DOGLCD_MOSI     17
        #define DOGLCD_SCK      23
        #define DOGLCD_A0       LCD_PINS_DC
        #define LCD_PINS_D5     -1
        #define LCD_PINS_D6     -1
      #else
        #define LCD_PINS_RS     16
        #define LCD_PINS_ENABLE 17
        #define LCD_PINS_D4     23
        #define LCD_PINS_D5     25
        #define LCD_PINS_D6     27
      #endif

A conclusion from the analysis above is that you enable the display in your configuration file and add the 2 values of -1 for D5 and D6, but I don't think they cause problems if they're not initialized to -1. Be sure that the cables are connected correctly. Some modules have reported upside down connectors.


---

