In this article, we will tell you about Nokia 5110 LCD Display with ESP8266 NodeMCU, how it works, and its essential connections between ESP8266 and Nokia 5110 LCD.
We explained it in detail through NodeMcu Development Board for better understanding. You can also know about this board from here (Source).
Also, we explained “how to stable the contrast of the Nokia 5110 LCD Display using a potentiometer.
A Brief Note on Connecting Nokia 5110 LCD Display with ESP8266 NodeMCU
The most used Nokia 5110 LCD Display based on the LCD is the PCD8544 LCD Display with a graphical display of 84 × 48 pixels, and the power supply needed is 3.3V. When connected with ESP8266, it won’t create a problem.
It is one of the easiest and simplest Display devices that can be used with ESP8266 and requires few settings.
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.
The description of all Nokia 5110 LCD pins is given below. There may be a slight difference in their names, but the interface is similar to SPI.
In this Article, the 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. 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.
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 |
The MOSI, SCK, and CS pins are used for connection purposes. The other two extra pins, RST and D/C, are of Nokia 5110 LCD. These pins are not linked with SPI hardware; 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 the BL’ Pin of the Nokia 5110 LCD is supplied with a 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
Circuit Diagram for Connecting Nokia 5110 LCD Display with ESP8266 NodeMCU
The image shows all the essential connections for the ESP8266 Nokia 5110 LCD interface.
Displaying Text on Nokia 5110
On Nokia 5110 LCD had the easiest way to display text. The simple functions are revealed to the users as the ‘Adafruit_PCD8544’ library significantly reduces the complexity of the PCD8544 LCD Controller IC and exposes.
Some of the essential functions are:
- Begin: Fixes the 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.
- Set Cursor: Set the cursor location of the text.
EXTRA FUNCTIONS:
•Displaying Text •ASCII Characters • Customisation of Characters • Setting the font size • Changing Font And Displaying basic graphics, such as individual pixels, lines, circles, circles, rectangles, triangles, etc is allowed by the ‘Adafruit_GFX’ library.
Suggested article: Water level indicator without IC
Code
Below is the most straightforward code for displaying and Connecting the 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()
{
}
NodeMCU-ESP8266-Nokia-5110-LCD-Text.ino by GitHub
“How to Interface Nokia 5110 LCD Display with ESP8266 Devkit Development Board” Also, Remember to read that.
Adjust Contrast of the 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: Afterr checking the value, 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 display’s contrast. 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 image shows the Nokia 5110 LCD Display and potentiometer for connections of contrast adjustment.
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();
}
NodeMCU-ESP8266-Nokia-5110-LCD-Contrast.ino by GitHub
The given image shows a low contrast setting on Nokia 5110 LCD.
Similarly, the contrast value can be increased just by turning the potentiometer. The given image shows a high-contrast setting.
If you are interested in Programming Raspberry Pi Pico using C | Getting Started with C SDK, then you 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 essential connections and steps for adjusting the contrast of the Nokia 5110 using POT.
Comments below for any questions and give us feedback about our article.