Video Demonstration & Walkthrough
Watch the live workshop demonstration showcasing sub-second NFC check-in/check-out speed, audio/TFT feedback, offline Wi-Fi disconnection recovery via FIFO queue, and automatic Google Sheets logging.
Advertisement
System Architecture
Unlike bloated attendance systems that require paid SaaS subscriptions or a dedicated local database server, this terminal communicates directly over HTTPS with a serverless Google Apps Script endpoint connected to your Google Sheets workbook:
ESP32 + PN532 + ST7789
Reads ISO14443A UIDs in hardware, applies 4s debounce, displays status on TFT, and persists offline scans to LittleFS FIFO.
Google Apps Script
Validates shared device secret, acquires LockService mutex, locks timestamps to GMT-7, and toggles IN/OUT state.
Google Sheets
Appends immutable attendance rows via appendRow() and runs nightly triggers to flag forgotten overnight shifts.
Real-Time Performance & Resilience Specs
- 0.3s Response Time: Immediate visual feedback on the ST7789 IPS display plus piezo buzzer tone as soon as the PN532 reads a badge, followed by a fast TLS handshake to Google Apps Script.
- 4s NFC Debounce Protection: Holding a tag against the reader for too long or double-tapping within
4000msis ignored cleanly by the firmware, preventing accidental double clock-in/clock-out punches. - 3s HTTP Timeout: Every network POST is guarded by
http.setTimeout(3000). If office Wi-Fi drops or Google latency spikes, the terminal never freezes the reception queue. - Offline FIFO Buffer: Failed uploads are serialized in strict First-In-First-Out order into
/fifo_queue.jsonlinside ESP32 flash (LittleFS) and automatically flushed in chronological order once Wi-Fi reconnects.
Automated Nightly Feature: Forgotten Shift Auto-Closing & Red UI Flags
If an employee clocks in during the day and forgets to tap out before going home, a scheduled Google Apps Script time-driven trigger (autoCloseForgottenShifts()) scans open CLOCK IN states overnight, inserts an AUTO-OUT record at 23:59:00 GMT-7, and highlights the entire row in red (#FEE2E2 / #991B1B) under the Admin Flag column (FORGOTTEN_SHIFT_REVIEW) so payroll admins spot anomalies immediately.
Downloads & File Repository
All project source files, cloud backend scripts, 3D enclosure meshes, and wiring schematics are free to download and customize for your workshop or business.
Advertisement
Google Apps Script (Code.gs)
GMT-7 permanent time script with appendRow logging, LockService concurrency safety, and overnight shift auto-closing.
ESP32 Firmware (.ino / .bin)
Arduino/ESP32 source code featuring 4s NFC debounce protection, 3s HTTP timeout guard, ST7789 UI, and LittleFS FIFO offline buffer.
3D Printable Case (.STL / .STEP)
Precision enclosure tuned for the Creality Ender 3 S1 Pro with recessed pockets for ST7789 TFT + PN532 NFC reader.
Connection Schema (.png / .pdf)
Complete pin-to-pin wiring diagram for ESP32 DevKit v1, ST7789 SPI TFT display, PN532 I2C NFC module, and Piezo Buzzer.
Connection Schema (ESP32 + ST7789 + PN532 + Buzzer)
Before powering the circuit via USB-C, confirm that the tiny DIP switches on your PN532 NFC module are set to I2C Mode (SEL0 = ON / 1, SEL1 = OFF / 0). All peripherals share the 3.3V logic rail.
Hardware Bill of Materials (BOM)
Every component in this build is available off-the-shelf and tested in our workshop catalog:
| Component | Interface / Voltage | Qty | Role in Terminal | Catalog Link |
|---|---|---|---|---|
| ESP32 DevKit v1 | Wi-Fi 2.4GHz, 3.3V Logic, USB Power | 1 | Main MCU, HTTPS TLS client, LittleFS offline FIFO storage | View in Catalog |
| PN532 NFC Module | I2C (GPIO 21 SDA / GPIO 22 SCL), 3.3V | 1 | 13.56MHz RFID/NFC ISO14443A card & keyfob reader | Sensors & RF |
| ST7789 TFT Display | VSPI (SCK 18, MOSI 23, CS 15, DC 2, RST 4) | 1 | High-contrast color IPS screen for IN/OUT & sync status | Displays |
| Passive / Active Buzzer | GPIO 27 + GND (3.3V trigger) | 1 | Distinct beep patterns (1x Live OK, 2x Offline FIFO, 3x Error) | Modules |
3D Printable Case Preview (Creality Ender 3 S1 Pro)
Sliced profile recommendations for Ender 3 S1 Pro: PETG or PLA+, 0.20mm layer height, 20% Gyroid infill, 0.4mm nozzle, no supports required when printed face-down. Inspect the base enclosure envelope below:
Google Apps Script Preview (Code.gs)
const TIMEZONE = "GMT-7";
const LOG_SHEET_NAME = "AttendanceLogs";
function doPost(e) {
const lock = LockService.getScriptLock();
try {
lock.waitLock(10000);
const payload = JSON.parse(e.postData.contents || "{}");
const uid = String(payload.uid || "").trim().toUpperCase();
const ss = SpreadsheetApp.getActiveSpreadsheet();
const logSheet = ensureLogSheet(ss);
const nextAction = resolveNextAction(logSheet, uid);
const formattedDate = Utilities.formatDate(new Date(), TIMEZONE, "yyyy-MM-dd");
const formattedTime = Utilities.formatDate(new Date(), TIMEZONE, "HH:mm:ss");
logSheet.appendRow([
formattedDate,
formattedTime,
uid,
lookupEmployee(ss, uid),
nextAction,
payload.deviceId || "TERMINAL-01",
payload.offlineBuffered ? "OFFLINE_FIFO" : "REALTIME"
]);
return ContentService.createTextOutput(JSON.stringify({ ok: true, action: nextAction }))
.setMimeType(ContentService.MimeType.JSON);
} finally {
lock.releaseLock();
}
}
ESP32 Firmware Snippet (esp32_nfc_attendance.ino)
const unsigned long NFC_DEBOUNCE_MS = 4000; // 4s duplicate-tap guard
const uint16_t HTTP_TIMEOUT_MS = 3000; // 3s non-blocking timeout
if (uidStr == lastUid && (millis() - lastScanMs) < NFC_DEBOUNCE_MS) {
return; // Ignore accidental double-tap
}
lastUid = uidStr;
lastScanMs = millis();
if (sendToGoogleSheets(uidStr, false, action, name)) {
beep(1, 80);
flushFifoQueue(); // Drain any offline scans in strict FIFO order
} else {
enqueueOfflineFifo(uidStr, millis() / 1000UL);
beep(2, 60);
}