← All projects
Displays Intermediate

The Nokia 5110 Display (PCD8544): a Thermometer With Min, Max and a Humidity Bar

The screen from the legendary phone: 84×48 pixels, under 1 mA of current, and easy to read in sunlight. We connect it over software SPI, set the contrast, and find out why it will not last long on an Arduino Uno without resistors.

Difficulty
Intermediate
Time
45 min
Category
Displays
Updated

About the project

The Nokia 5110 is an 84×48 monochrome LCD with a PCD8544 controller. Unlike an OLED it does not emit light, so it draws almost nothing (0.3 mA without the backlight) and reads perfectly in bright light. For a battery device or an outdoor thermometer it is one of the best choices.

What you need

  • ESP32 DevKit
  • A Nokia 5110 module (a red or blue board with 8 pins)
  • An AHT20 sensor (temperature and humidity)

Wiring

Nokia 5110 ESP32
RST GPIO17
CE (CS) GPIO5
DC GPIO16
DIN GPIO23
CLK GPIO18
VCC 3V3
BL 3V3 (or a GPIO to control the backlight)
GND GND
AHT20 VIN → 3V3, GND → GND, SDA → GPIO21, SCL → GPIO22

The pin order differs from board to board — go by the labels. On some red modules the backlight comes on when BL is connected to GND.

3.3 V only

The PCD8544 runs from 2.7–3.3 V, and its inputs are 3.3 V too. With an ESP32 there is no problem. With an Arduino Uno connect VCC to 3.3V and put 10 kΩ resistors in the CLK, DIN, DC and RST lines (1 kΩ on CE), or use a level shifter. Without them the display often works, but it slowly darkens and dies. The simulator warns about 5 V on any pin.

Contrast

Contrast varies a lot between batches. Too little and the image is pale, too much and the whole screen turns grey. Start with setContrast(55) and move in steps of 5 between 40 and 70. The simulator shows what the extremes look like.

Code

// Thermometer on a Nokia 5110 (PCD8544): big digits, min/max and a humidity bar
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
#include <Adafruit_AHTX0.h>

const int PIN_CLK = 18, PIN_DIN = 23, PIN_DC = 16, PIN_CE = 5, PIN_RST = 17;
Adafruit_PCD8544 display(PIN_CLK, PIN_DIN, PIN_DC, PIN_CE, PIN_RST);   // software SPI
Adafruit_AHTX0 aht;
float tMin = 100, tMax = -100;

void setup() {
  Serial.begin(115200);
  display.begin();
  display.setContrast(55);   // 40–70 depending on the module
  display.clearDisplay();
  display.display();
  if (!aht.begin()) {
    display.setCursor(0, 0);
    display.print("No AHT20");
    display.display();
    while (true) delay(1000);
  }
}

void loop() {
  sensors_event_t hum, temp;
  aht.getEvent(&hum, &temp);
  float t = temp.temperature;
  if (t < tMin) tMin = t;
  if (t > tMax) tMax = t;

  display.clearDisplay();
  display.setTextColor(BLACK);
  display.setTextSize(1);
  display.setCursor(0, 0);
  display.print("Temperature");
  display.setTextSize(2);
  display.setCursor(0, 11);
  display.print(t, 1);
  display.print("C");
  display.setTextSize(1);
  display.setCursor(0, 29);
  display.print(tMin, 1);
  display.print(" / ");
  display.print(tMax, 1);
  int w = map((int)hum.relative_humidity, 0, 100, 0, 84);   // humidity as a bar at the bottom
  display.drawRect(0, 40, 84, 8, BLACK);
  display.fillRect(0, 40, w, 8, BLACK);
  display.display();
  delay(1000);
}

display() sends the whole buffer — 504 bytes — to the display. Before that call every print() and fillRect() draws only into the ESP32's memory, so the screen does not flicker.

Good to know

  • Hardware SPI. The Adafruit_PCD8544(DC, CS, RST) constructor uses hardware SPI (on an ESP32, CLK 18 and DIN 23). It is faster, but a thermometer would not show the difference.
  • Fonts. Size 1 gives 14 characters × 6 lines, size 2 gives 7 × 3. The built-in GFX font has no Cyrillic: you need a custom font for that.
  • Backlight. Its 4 LEDs draw 10–20 mA. Connect BL to a GPIO and switch the backlight on for 10 seconds after a button press.