ESP8266, NodeMCU

NodeMCU and Nokia 5110 LCD

I’m using a NodeMCU 1.0 (ESP8266/ESP-12E) and a Nokia 5110 LCD (driven by PCD8544). Both are 3.3V so you can connect them directly. The following libraries are required:

  • Adafruit GFX Library
  • Adafruit PCD8544 Nokia 5110 LCD library

NOTE 1: The code in the library needs for this to work because it doesn’t include support for the ESP8266. The code change is small don’t worry, it is explained below.

NOTE 2: This method uses the hardware SPI on the NodeMCU. I tried using the software SPI and it didn’t work for me.

Here are the steps:

  1. Open Arduino IDE
  2. Click on Tools and then Manage Libraries
  3. Search for “Adafruit”
  4. Install “Adafruit GFX Library” and “Adafruit PCD8544 Nokia 5110 LCD library”
  5. Go to directory where the libraries are installed (normally C:\Users\USERNAME\Documents\Arduino\libraries\Adafruit_PCD8544_Nokia_5110_LCD_library)
  6. Edit Adafruit_PCD8544.cpp
  7. Look for the line “#include <avr/pgmspace.h>” and replace with this:
#ifdef ESP8266
  1. Edit Adafruit_PCD8544.h
  2. Look for the line “#ifdef __SAM3X8E__” and add this before the “#else” line:
#elif defined(ESP8266)
  typedef volatile uint32_t PortReg;
  typedef uint32_t PortMask;  
  1. From the Examples menu, open the “Adafruit PCD8544 Nokia 5110 LCD library\pcdtest” sketch. This sketch is a demo of the graphics capabilities.
  2. Look for the line “Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);” and comment it out
  3. Look for the line “// Adafruit_PCD8544 display = Adafruit_PCD8544(5, 4, 3);” and uncomment it and change it “Adafruit_PCD8544 display = Adafruit_PCD8544(D0, D1, D2);”
  1. Connect the wiring like this:
Nokia LCD--------------NodeMCU
  1. Compile and download
  2. Voila! 🙂

TIP: I noticed that the display was a bit dark. I fixed it by changing the contrast from 50 to 40. Look for the line “display.setContrast(50);” in the setup routine.