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:
- A way to generate actual Code 39 or Code 128 barcodes in Arduino (or pre-converted patterns).
- Tips for optimizing barcode width/spacing for Nokia 5110's 84x48 resolution.
- Suggestions on a lightweight barcode library for ESP32 (if any exist).
Any advice, code snippets, or links would be super helpful!
Thanks in advance!
VJ