How to wire 2.42 I2C oled screen to Wemos D1 mini

In this article I will cover how to wire up a generic 2.42 inch I2C OLED Screen to a D1 mini. It isn’t super hard, however there isn’t much info on this on the internet so I figured I would write this article.

First off I will be using the u8g2 library, it works great with most OLED screens, offers lots of options and makes it really easy once you figure the libraries out.

I will be using a Wemos D1 mini for this, but you could easily use an Arduino or esp32 or any other mcu. Here is an article about Arduino SPI and how it works as a hint if you are using Arduino. I bought my screen off Amazon for about $16USD, it doesn’t have a name and there wasn’t anything on the back to indicate who made it. The driver for this screen was marked on the back as ICSSD1309.

This is a really nice screen, it is like a MEGA version of the tiny .96 128×64 screens. This screen is able to be connected by either SPI or I2C. They come setup for SPI if you want to use I2C you need to perform some surgery and remove some resistors and add some. I didn’t feel like doing that so I just stuck with SPI. Others have noted how online and in the product listing. I mix up the two constantly, but SPI means more wires and I2C means less wires( much more in this article).

First off one thing that bothers me is all of the different names for pins, so I will make a list of those first. Lack of standardization and consistency make these sort of things suck to new comers.

I found this article to be very helpful overall in explaining OLED screens and pins etc.

The Pin list

More information about Pinouts for various esp8266 MCU’s here.

The screen pins

  • GND = ground, this is always the ground
  • G = also stands for ground, D1 mini only has a G
  • VCC = (Voltage Common Collector) this could be either positive or negative voltage, but for D1/Arduino it is always positive. This is the line you supply the 3.3v or 5v to. Much more details here. For this project I use the 5v pin from D1 mini.
  • SCK = Serial clock you will also see SCLK in some pinout references or even SC. SCK is the serial clock for SPI, which is what we will need for this project. D1 mini calls it SCLK and it is on the D5 pin which is the SCLK pin on D1 minis.
  • SDA = Serial Data, this pin is used to exchange data between the master and slave device. For this project I connect it to pin D2 which is SDA pin on D1 mini. It is usually used for I2C, but we use it here too. More info about SDA here.
  • RES = Reset pretty simple, this doesn’t seem to be used, but I connected it to the D1 RST pin which is the reset pin. I hate inconsistencies.
  • RST = RES = reset pin
  • DC = Data/Command This is the best info I could find on this pin. More info here. A little more info on this obscure pin here.
  • CS = Chip select, when you use more than one SPI device it needs a way to select which device you want to use. More in depth information here in this article.

D1 mini Constants

When working with D1 mini it is much easier to just use the constants than to try to follow along with the actual GPIO numbering BS. Here is a nice article about D1 mini pins.

To use the constants you must choose the right board in the Arduino IDE. You will know which one when you go to compile and it does or doesn’t work. I always compile before transferring the sketch. Normally

Click the tools tab then choose “board” then choose your board from the list. To use constants with the D1 mini in the above pinout image use LOLIN (WEMOS) D1 mini (clone) option.

Wiring things up

Now for the wiring of the screen. Connect the following screen pins to the following wemos d1 mini pins. Screen on the left, wemos pins on the right

  • GND -> (wemos) G pin
  • VCC -> (wemos) 5v pin, 3.3v may work too.
  • SCK -> (wemos) D5 pin. This is the d1 mini SCLK pin from above
  • SDA -> (wemos) D2 pin. This is the d1 mini SDA pin from above
  • RES -> (wemos) RST pin. No constant for this one,code doesn’t need it anyways.
  • DC -> (wemos) D1 pin. This is the d1 mini default SCL pin
  • CS -> (wemos) D8 pin. This is the d1 mini default CS pin

The code

Now you just need some simple code to test it. Most examples have long BS example code to try to look smart. I don’t need an ego boost, so I’ll keep it simple.

First you need to find the library in your IDE to be able to use it. Click tools. Then click manage libraries. In the search bar type “u8g2” and click install.

Now create a new Sketch and copy and paste this code to test it.

#include <U8g2lib.h>

U8G2_SSD1309_128X64_NONAME2_1_4W_SW_SPI u8g2(U8G2_R0, D5, D2, D8, D1);
void setup() {
  // put your setup code here, to run once:
  pinMode(D1, OUTPUT);

void loop(void) {
  do {
    //keep this the same as it pages through the data generating the screen
    u8g2.drawStr(0,20,"ip address");
   //u8g2.drawStr(0,60,"Last line!");
  } while ( u8g2.nextPage() );

Note the constructor U8G2_SSD1309_128X64_NONAME2_1_4W_SW_SPI u8g2(U8G2_R0, D5, D2, D8, D1)

You are feeding it the pins from above . Below is the constructor

U8G2_SSD1309_128X64_NONAME2_1_4W_SW_SPI(rotation, clock, data, cs, dc [, reset])

U8G2_R0 is a constant from the u8g2 library. There is a long list of constructors in the library for different screens, this is a very useful library. This constructor was about 40% down the long list under the heading SSD1309 128X64_NONAME2, this uses a 128 bytes buffer, there is another for 256 and even 1024. Play around if you like.

The whole library starting page is here. Here is a list of all fonts. NOTE you must include _tr at the end of the name for some stupid reason.






This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: