Title: Displaying Barcode on Nokia 5110 LCD Using ESP32

Hi everyone,

I'm working on a small project where I want to generate and display a barcode on a Nokia 5110 LCD using an ESP32 board.

Hardware Setup:

  • ESP32 Dev Board (38-pin)
  • Nokia 5110 LCD (PCD8544 controller)
  • Powered via 3.3V (to avoid over-voltage)
  • Connected as follows:
Nokia 5110 ESP32 GPIO
CE 22
RST 21
DC 17
DIN 23
CLK 18
VCC 3.3V
GND GND
BL GND

Libraries Used:

  • Adafruit_GFX
  • Adafruit_PCD8544

Installed via the Arduino Library Manager.

What I’ve Done So Far:

I created a test sketch that simulates a barcode by drawing vertical lines based on a string of 1s and 0s:

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

Adafruit_PCD8544 display(22, 21, 17, 23, 18); // CE, RST, DC, DIN, CLK

void drawBarcode(String pattern) {
  int x = 0;
  for (int i = 0; i < pattern.length(); i++) {
    if (pattern[i] == '1') {
      display.drawFastVLine(x, 0, 48, BLACK);
    }
    x += 1;
    if (x >= 84) break; // avoid overflow
  }
}

void setup() {
  display.begin();
  display.setContrast(60);
  display.clearDisplay();

  // Fake barcode pattern
  String barcode = "101100111000111001011000111011100101010";
  drawBarcode(barcode);

  display.display();
}

void loop() {}

Looking For:

  1. A way to generate actual Code 39 or Code 128 barcodes in Arduino (or pre-converted patterns).
  2. Tips for optimizing barcode width/spacing for Nokia 5110's 84x48 resolution.
  3. Suggestions on a lightweight barcode library for ESP32 (if any exist).

Any advice, code snippets, or links would be super helpful!

Thanks in advance! :blush:
VJ

I moved your topic to a more appropriate forum category @vishwjeet1231.

The Nano Family > Nano ESP32 category you chose is only used for discussions directly related to the Arduino Nano ESP32 board.

In the future, when creating a topic please take the time to pick the forum category that best suits the subject of your question. There is an "About the _____ category" topic at the top of each category that explains its purpose.

Thanks in advance for your cooperation.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.