1.8″ GLCD with ESP8266 (NodeMCU)

In future I am planning some DS18B20 temperature measuring with ESP8266 and to show the values I will be using 1.8″ GLCD. Like the one on the photo below (top and bottom view):

I program ESP8266 using Sloeber which is basically Arduino using Eclipse. I like Eclipse a lot.

I am using Adafruit_ST7735 and Adafruit_GFX libraries.

First we need to connect everything. Below is connection table:

GLCD ESP8266
1 – RST D0
2 – CS D1
3 – D/C D2
4 – DIN D7
5 – CLK D5
6 – VCC +3V3
7 – BL +3V3
8 – GND GND

Now we start coding. First we select File -> New -> Arduino Sketch in Sloeber…

 

…next we give name to project (anything you want that doesn’t exist already) and click Next (do not click Finish!!!)

…if we didn’t do ESP8266 project before we need to set some settings (your COM port might be different from mine). Again click Next (NOT Finish to continue)…

…here we choose empty project (Default ino file) and click Finish…

…and here we have project created:

I use dark theme for ease on the eyes. You can change this by clicking Window -> Preferences and under General -> Appearance select Dark:

While in these settings also check that you have checked both checkboxes marked below:

Now we start creating our program. First we add includes for GLCD libraries. Sloeber needs Arduino.h included:

We also need to define a few pins:

Next we need a couple of color definitions for later:

Finally need to define object (I am self thaught coder so I am not sure if this is the correct naming convention, please correct me in comments if you know what is right) for GLCD:

Now we can add Setup code (rotation is optional, I just happen to have display oriented this way):

If we try to compile at this moment we get a couple of errors. Let’s correct them!

We need to exclude drivers for ST7789 GLCD:

Right click each of two files marked green and choose Properties:

Select “Exclude resource from build” and click Apply and Close:The files will become dimmed and crossed over:

Now the project will compile and you can program your NodeMCU:

If you would like some nice custom font here is tutorial for that.

UPDATE:

I have another different LCD display that looks like this:

This display has ST7789 controller. And for this specific one, the libraries are not OK!!! The colors are inverted if you dont chage this (RGB->BGR) and whole screen is shifted for a few pixels.

Let’s correct that!

First we need to comment out include for ST7735 and add include for ST7759 (you may also noticed I changed font from last time):

We also now need to include .cpp and .h files in the library. See above where we disabled them, just do reverse procedure.

Now the project will argue about tft.initR we need to change it to:

Just comment out the line with initR and uncomment the one you see above and change resolution to 128 x 160.

Also we need to change the declaration (uncomment ST7789 and comment ST7735):

If you try program now the colors would be inverted. We can correct this in Adafruit_ST7789.cpp at line 69. Change from ST77XX_INVON to ST77XX_INVOFF.

There is one more thing to be corrected, in this same file. At line 102 there is an if statement for different resolutions we will ad the missing one and correct the offset at the same time. Replace the current code with this:

Now the display should work properly.

Thank you for reading!

Slemi

Leave a Reply

Your email address will not be published. Required fields are marked *

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