Thursday, August 11, 2022

Connecting Nokia 5110 LCD Display with ESP8266 NodeMCU

Must Read
Aizaz khan
Aizaz khanhttps://myelectricsparks.com/aizaz-khan/
Aizaz was the first person to get a byline on his blog on technology from his home in Bannu in 2017. Then, he went on to a career in breaking things professionally at my electric sparks which is where he eventually took over the kit as a hardware editor. Today, as the senior editor of hardware for my electric sparks, he spends time reporting about the most recent developments in the hardware industry and technology. If he's not reporting on hardware or electronics, you'll see him trying to be as remote from the world of technology as possible through camping in the wild.
In this article, we will tell you about  Nokia 5110 LCD Display with ESP8266 NodeMCU, how it works, its important connections between ESP8266 and Nokia 5110 LCD.
We had explained it in detail through NodeMcu Development Board for better understanding you can also know about this board from here (Source).
Also, we had explained “how to stable the contrast of Nokia 5110 LCD Display using a potentiometer.

ESP8266 Nokia 5110 LCD Image

“How to Interface Nokia 5110 LCD Display with ESP8266 Devkit Development Board” remember to read that as well.

A Brief Note on Connecting Nokia 5110 LCD Display with ESP8266 NodeMCU

The most used Nokia 5110 LCD Display based on the LCD display is PCD8544 LCD Display with graphical display of 84 × 48 pixels and power supply needed is 3.3V. When connected with ESP8266 it won’t create a problem.
One of the easiest and simplest Display devices that can be used with ESP8266 and it also requires few settings.

Nokia 5110 LCD Display

 

The PCD8544 Control is used SPI (Serial interface) to communicate with Microcontroller (Source).

The given image presents the Pinout of the Nokia 5110 LCD Display.

 

Interfacing Nokia 5110 LCD with Arduino 2
Nokia 5110 LCD with Pinout
The description of all Nokia 5110 LCD pins ???? is given below. There may be a slight difference in their names but the interface is quite similar to SPI.
In this Article SPI peripheral of ESP8266 is used for connecting with Nokia 5110.
 
Pin Name Description
RST Reset
CE Chip Enable
DC Data / Command Selection
DIN Data Input
CLK Clock
VCC Supply Voltage (3.3V)
BL Backlight Supply
GND Ground

NodeMCU ESP8266 Nokia 5110 LCD Interface

As explained above, the serial connections interface of the Nokia 5110 LCD is the same as SPI.  At first, the SPI pins of the ESP8266 NodeMCU Board need to be identified. There are two SPI Interfaces of ESP8266 SoC.
1: SPI
2: HSPI
The first one, SPI is used for interface SPI Flash on ESP-12E Module and the Second one, GPIO pins 12 – 15 are linked with HSPI in the Pinouts of NodeMCU ESP8266.

NodeMCU Pinout Image

HSPI Pin GPIO Pin NodeMCU Pin
HSPI_SCK GPIO 14 D5
HSPI_MISO GPIO 12 D6
HSPI_MOSI GPIO 13 D7
HSPI_CS GPIO 15 D8

For connection purposes, the MOSI, SCK, and CS pins are used. The other two extra pins ???? are RST and D/C are of Nokia 5110 LCD. These pins ???? are not linked with SPI hardware and any free GPIO pin can be used.

So the result of the connection looks the same as the connection given in the below table. These connections are between NodeMCU ESP8266 and Nokia 5110 LCD

Nokia 5110 LCD NodeMCU ESP8266
RST D2 (GPIO 4)
CE (CS) D8 (GPIO 15)
DC D1 (GPIO 5)
DIN (MOSI) D7 (GPIO 13)
CLK (SCK) D5 (GPIO 14)
VCC 3.3V
BL 3.3V (through 220Ω resistor)
GND GND

After reading the above table, you might know that BL’ Pin of Nokia 5110 LCD is supplied 3.3V through 220Ω current-limited resistor for safety measures and it also enables the Backlights.

Components Required For Connecting Nokia 5110 LCD Display with ESP8266 NodeMCU

NodeMCU ESP8266 Development Board Nokia 5110 LCD Display 220Ω Resistor Breadboard Connecting Wires 10 KΩ Potentiometer (for setting contrast)

Circuit Diagram for Connecting Nokia 5110 LCD Display with ESP8266 NodeMCU

The given image shows all the important connections for the ESP8266 Nokia 5110 LCD interface.

Nokia 5110 LCD Contrast NodeMCU

Displaying Text on Nokia 5110

On Nokia 5110 LCD had the easiest way to display text. As the simple functions are revealed to the users as  ‘Adafruit_PCD8544’ library significantly reduces the complexity of the PCD8544 LCD Controller IC and exposes.

Some of the essential functions are:

Begin: Fixes SPI interface setting and initialize the display. Display: the display will be Updated Print:  Displaying text on the screen. clear display: Clears the entire display. SetContrast: The Contrast level of the display is controlled. SetCursor: Set the cursor location of the text.
EXTRA FUNCTIONS:
There are many extra functions as well some of them are:
•Displaying Text •ASCII Characters • Customisation of Characters • Setting the font size • Changing Font etc
And Displaying basic graphics,  for example, individual pixels, line, circle, rectangle, triangle, etc are allowed by the ‘Adafruit_GFX’ library.

Code

Given below is the simplest code for displaying and Connecting Nokia 5110 LCD Display with ESP8266 NodeMCU.
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>

/* Declare LCD object for SPI
 Adafruit_PCD8544(CLK,DIN,D/C,CE,RST);*/
Adafruit_PCD8544 display = Adafruit_PCD8544(14, 13, 5, 15, 4); /*D5, D7, D1, D8, D2 */
int contrastValue = 60; /* Default Contrast Value */

void setup()
{
  /* Initialize the Display*/
  display.begin();

  /* Change the contrast using the following API*/
  display.setContrast(contrastValue);

  /* Clear the buffer */
  display.clearDisplay();
  display.display();
  delay(100);
  
  /* Now let us display some text */
  display.setTextColor(WHITE, BLACK);
  display.setTextSize(1);
  display.setCursor(15,1);
  display.println("|ESP8266|");
  display.setCursor(15,13);
  display.println("|NodeMCU|");
  //display.setTextSize(1);
  display.setTextColor(BLACK);
  display.setCursor(22,25);
  display.println("|Nokia|");
  display.setCursor(25,37);
  display.println("|5110|");
  display.display();
  //delay(2000);
}

void loop()
{
  
}

ESP8266 Nokia 5110 LCD

Adjust Contrast of Nokia 5110

Before moving forward, your should know how to adjust the contrast of the Nokia 5110 LCD?

For Adjust purposes 10 KΩ Potentiometer is attached to set the contrast. Then follow the given steps.

STEPS:

1: At first, add any text to LCD for displaying. 2: After that connect the POT to the ADC pin of ESP8266 3: Then study the Analog Input value on the potentiometer. 4: Now after checking the value, now use ADC to convert it to a digital value. 5: At the end, map the results of ADC to a suitable contrast value.
The above steps are the simplest way to adjust the contrast of the display. There are also other methods such as push buttons, serial connection, etc.

 NOTE :

ADC Channel has only ESP8266 with a resolution value of 10 bits and its output range is from 0 to 1023. So for conversion of range to a more suitable range for contrast (0 to 100), Arduino “map” function is used.

Circuit Diagram

The given image shows the Nokia 5110 LCD Display and potentiometer for connections of adjustment of contrast.

Nokia 5110 LCD Contrast NodeMCU

Code

#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>

#define analogPin A0 /* ESP8266 Analog Pin ADC0 = A0 */

/* Declare LCD object for SPI
 Adafruit_PCD8544(CLK,DIN,D/C,CE,RST);*/
Adafruit_PCD8544 display = Adafruit_PCD8544(14, 13, 5, 15, 4); /*D5, D7, D1, D8, D2 */
int contrastValue = 60; /* Default Contrast Value */

int adcValue = 0;  /* Variable to store Output of ADC */

void setup()
{
  /* Initialize the Display*/
  display.begin();

  /* Change the contrast using the following API*/
  display.setContrast(contrastValue);

  /* Clear the buffer */
  display.clearDisplay();
  display.display();
  delay(100);
  
  /* Now let us display some text */
  display.setTextColor(WHITE, BLACK);
  display.setTextSize(1);
  display.setCursor(15,1);
  display.println("|ESP8266|");
  display.setCursor(15,13);
  display.println("|NodeMCU|");
  //display.setTextSize(1);
  display.setTextColor(BLACK);
  display.setCursor(22,25);
  display.println("|Nokia|");
  display.setCursor(25,37);
  display.println("|5110|");
  display.display();
  //delay(2000);

}

void loop()
{
  adcValue = analogRead(analogPin);
  contrastValue = map(adcValue, 0, 1023, 0, 100);
  setContrast();
  //displayText();  
}


void setContrast()
{
  display.setContrast(contrastValue);
  display.display();
}

 

The given image shows a low contrast setting on Nokia 5110 LCD.

Low Contrast Nokia 5110 LCD NodeMCU

Similarly, the contrast value can be increased just by turning the potentiometer. The given image shows a high contrast setting.

High Contrast Nokia 5110 LCD NodeMCU

If you are interested in Programming Raspberry Pi Pico using C | Getting Started with C SDK then must visit this article

Conclusion

This article is based on a simple project to understand completely how to Connect the Nokia 5110 LCD Display with ESP8266 NodeMCU, Pinout of Nokia 5110 LCD, and its important connections and steps for adjusting the contrast of Nokia 5110 using POT.
Comments down below for any questions and also give us feedback about our article.
- Advertisement -spot_img

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest News

When Will The Galaxy Buds 2 Pro Be Available?

Samsung fans rejoice! The Korean just held its latest Unpacked event, and we’re all excited about what the company is going to be launching soon. Along with the new Galaxy Watch 5 and the new foldable phones, Samsung also announced the new Galaxy Buds 2 Pro, and these new earbuds will be available come August 26th.

More Articles Like This