DIY Electronic ID Card with a Round Display
Turn your name badge into a glowing gadget! Our electronic ID card shows your name, class and favourite things on a round screen, with a sparkling dot that races around the edge. Press a button to flip to the next page.
- Level: Beginner+
- Time: about 2 hours
- Ages 10+ (with an adult helper)
What are we building?
An electronic ID card is a name badge with a tiny screen inside. The ESP32-C3 is its brain, a round display is its face, and a small rechargeable battery lets you wear it on a lanyard. A push button flips between four pages: Hello, School, Hobbies and ID number.
Design yours: type your details and tap the pages. The code lines below the card update, ready to copy into the Arduino sketch.
What you need
| Part | How many |
|---|---|
| ESP32-C3 SuperMini board | 1 |
| 1.28 inch round display, 240×240, GC9A01, SPI (7 pins) | 1 |
| Small push button | 1 |
| 3.7V LiPo battery (300–500 mAh) with protection | 1 |
| TP4056 charger module with protection (6 pads) | 1 |
| Tiny slide switch | 1 |
| Jumper wires, breadboard, double-sided tape | 1 set |
| Card, thick foam board or a 3D-printed case, plus a lanyard | 1 |
How it works
- SPI: the round display listens to the ESP32-C3 through a fast data line (SPI). Each pixel is a tiny dot of colour.
- Pages: the code draws one page of text at a time. A button press (or a timer) draws the next page.
- Animation: a pink dot circles the screen by calculating its place with sine and cosine, then erasing the old spot.
- Power: the TP4056 charges the battery from a USB cable, and a switch turns the badge on and off.
Circuit diagram
Pin table
| ESP32-C3 pin | Round display / part |
|---|---|
| 3V3 | VCC |
| GND | GND |
| GPIO4 | SCL (clock) |
| GPIO6 | SDA (data) |
| GPIO3 | DC |
| GPIO7 | CS |
| GPIO2 | RST |
| GPIO1 | Page button, other leg to GND |
| 5V pin | TP4056 OUT+ through the slide switch |
| GND | TP4056 OUT− |
Step-by-step instructions
Test the display on a breadboard
With no battery and the USB cable only, wire the round display and the button to the ESP32-C3 as in the pin table. Install the esp32 by Espressif board package. In Library Manager install Adafruit GC9A01A and Adafruit GFX Library.
Upload the code
Choose Tools > Board > ESP32C3 Dev Module and turn USB CDC On Boot to Enabled. Paste the code below and click Upload. The first page should appear with a pink dot running round the edge. Press the button to flip pages.
Make it yours
Use the card designer above to try your name, class, school and hobby. Copy the code lines it creates into the top of the sketch, replacing the sample ones. Upload again.
Add battery power
With an adult, wire the LiPo, TP4056 and switch as in the diagram, with the switch off. Connect the switch output to the ESP32-C3 5V pin last. Switch the battery off before you plug in USB to upload new code.
Build the card case
Cut a round window in thick card or foam board and fit the display behind it. Tape the board and battery on the back, keeping the TP4056 USB port reachable for charging. Add a hole for the lanyard, a button on the side, and cover the back with tape.
Arduino code
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_GC9A01A.h>
#define TFT_CS 7
#define TFT_DC 3
#define TFT_RST 2
#define BTN_PIN 1
// ---- Edit these to make the card yours (keep them short!) ----
const char* NAME = "ARYA";
const char* CLASS_ = "Class 6A";
const char* SCHOOL = "Sunrise School";
const char* HOBBY = "ROBOTS";
const char* ID_NO = "MM-001";
// ---------------------------------------------------------------
// Colours (RGB565)
#define BG 0x08E6 // dark navy
#define WHITE 0xFFFF
#define YELLOW 0xFE47
#define PINK 0xFB51
#define BLUE 0x2BFC
#define MINT 0x2DD1
Adafruit_GC9A01A tft(TFT_CS, TFT_DC, TFT_RST); // uses the default SPI pins
const int NUM_PAGES = 4;
int page = 0;
unsigned long lastChange = 0, lastDot = 0;
int dotX = -100, dotY = -100;
float angle = 0;
bool lastBtn = HIGH;
// Draw text centred, shrinking it until it fits the width
void centerText(const char* s, int y, int maxSize, uint16_t color, int maxW = 170) {
int size = maxSize;
while (size > 1 && (int)strlen(s) * 6 * size > maxW) size--;
int w = strlen(s) * 6 * size;
tft.setTextSize(size);
tft.setTextColor(color);
tft.setCursor(120 - w / 2, y);
tft.print(s);
}
void drawPage(int p) {
tft.fillScreen(BG);
for (int r = 116; r <= 119; r++) tft.drawCircle(120, 120, r, BLUE); // ring
dotX = -100; // forget old dot
if (p == 0) {
centerText("HELLO!", 45, 3, YELLOW);
centerText("my name is", 85, 2, WHITE);
centerText(NAME, 115, 5, PINK);
centerText("ROBOT MAKER", 175, 2, MINT);
} else if (p == 1) {
centerText("I STUDY AT", 50, 2, WHITE);
centerText(SCHOOL, 90, 3, YELLOW);
centerText(CLASS_, 140, 3, PINK);
} else if (p == 2) {
centerText("I LOVE", 55, 3, WHITE);
centerText(HOBBY, 100, 4, YELLOW);
for (int i = 0; i < 3; i++) tft.fillCircle(90 + i * 30, 175, 9, i == 1 ? PINK : MINT);
} else {
centerText("ID CARD", 50, 3, WHITE);
centerText(ID_NO, 95, 4, YELLOW);
centerText("MakeMindz Club", 150, 2, MINT);
centerText("Made by me!", 180, 2, PINK);
}
}
void setup() {
pinMode(BTN_PIN, INPUT_PULLUP);
tft.begin(40000000); // 40 MHz SPI
tft.setRotation(0);
drawPage(0);
lastChange = millis();
}
void loop() {
unsigned long now = millis();
// Button: next page
bool btn = digitalRead(BTN_PIN);
if (lastBtn == HIGH && btn == LOW) {
page = (page + 1) % NUM_PAGES;
drawPage(page);
lastChange = now;
delay(50); // debounce
}
lastBtn = btn;
// Auto-flip every 8 seconds
if (now - lastChange > 8000) {
page = (page + 1) % NUM_PAGES;
drawPage(page);
lastChange = now;
}
// Animated dot orbiting inside the ring
if (now - lastDot > 30) {
lastDot = now;
if (dotX >= 0) tft.fillCircle(dotX, dotY, 5, BG); // erase old dot
angle += 0.12;
dotX = 120 + (int)(106 * cos(angle));
dotY = 120 + (int)(106 * sin(angle));
tft.fillCircle(dotX, dotY, 4, PINK);
}
}
Tips and troubleshooting
The screen stays black
Check VCC, GND and all five signal wires (SCL, SDA, DC, CS, RST). Make sure you chose the ESP32C3 board, and try pressing the board’s reset button.
The colours look wrong
Some round displays swap red and blue. Try swapping the colour values in the code, or search for your display’s “colour order” setting.
The picture is rotated or the text is cut off
Change tft.setRotation(0) to 1, 2 or 3. Shorten long words, because the corners of a round screen are cut off.
Nothing happens when I press the button
Check that one leg of the button goes to GPIO1 and the other to GND. The code turns on the built-in pull-up resistor, so no resistor is needed.
It restarts on battery power
Check the battery is charged, that the switch contacts are solid, and that the battery wires are firmly connected. Add a 100 µF capacitor across the 5V pin and GND.
My display has a different chip
The code above is only for the GC9A01. For another chip you need a different library and different setup lines.
What did we learn?
- SPI is a fast way for a microcontroller to send pictures to a screen.
- Colours in code are stored as numbers, called RGB565.
- Sine and cosine help us move things in circles.
- Privacy means choosing carefully what to share about yourself.
Try these challenges
- Add a fifth page with a fun fact or a joke.
- Draw a robot face or logo with
fillCircleandfillRect. - Add a battery level page using the ESP32-C3’s analog input and two resistors.
- Use Wi-Fi so your phone can change the name without uploading code.
Questions kids ask
Can I use a different ESP32 board?
Yes, but the pin numbers will be different. Change the #define lines and connect the SPI wires to your board’s SPI pins.
How long does the battery last?
A 400 mAh battery usually lasts a few hours with the screen on. Turning the switch off when you are not wearing it helps a lot.
Can this open doors or replace my school ID?
No. It is a fun name badge and does not work as a real ID or key. It is also a good reason to learn about how real smart cards stay secure.
Comments
Post a Comment