A real-time RFID-based wallet system featuring an ESP8266 reader, a Node.js backend, SQLite database integration, and a live web dashboard with separate Admin (Top-Up) and Cashier (Payment) interfaces.
🔗 Live Dashboard: http://157.173.101.159:8021/
This project implements a complete RFID Wallet Transaction System that enables:
- Card Top-Up (Credit)
- Product Payment (Debit)
- Real-time balance updates
- Safe wallet updates (atomic transactions)
- Strict MQTT topic isolation
Users scan RFID cards using an ESP8266 terminal. The backend processes transactions securely and updates the web dashboard instantly via WebSocket.
The system consists of three main components:
- Scans RFID cards using an MFRC522 reader
- Publishes card UID and balance via MQTT
- Subscribes to:
- Top-Up commands
- Payment commands
- Updates local balance
- Publishes updated balance confirmation
Important:
- Does NOT use HTTP
- Does NOT use WebSocket
- Express.js REST API
- MQTT client (Publish–Subscribe communication)
- Socket.io for real-time updates
- SQLite database for transaction integrity
POST /topupPOST /pay
- Business logic processing
- Balance validation
- Safe wallet update (atomic database transaction)
- MQTT message translation
- Real-time WebSocket updates to dashboard
Responsive web interface built with Vanilla JS.
- Auto-detected Card UID
- Previous balance display
- Top-up amount input
- “TOP UP” button
- Success/Fail response
- Real-time updated balance
- Auto-detected Card UID
- Previous balance display
- Product dropdown selection
- Quantity input
- Auto-calculated total cost
- “PAY” button
- Approved/Declined result with reason
- Real-time updated balance
Backend/– Node.js server, API routes, MQTT logic, database integrationFrontend/– Web dashboard interfaceESP8266/– Arduino source code (RFDI.ino)database/– SQLite database file
cd Backend
npm install
npm startServer runs on:
http://localhost:3000
Open ESP8266/RFDI.ino in Arduino IDE and update:
#define WIFI_SSID "Your_SSID"
#define WIFI_PASS "Your_Password"Flash the code to your ESP8266 board.
| MFRC522 Pin | ESP8266 Pin | Notes |
|---|---|---|
| VCC | 3.3V | Do NOT use 5V |
| GND | GND | Ground reference |
| RST | GPIO0 (D3) | Reset pin |
| NSS/CS | GPIO2 (D4) | SPI Select |
| MOSI | GPIO13 (D7) | SPI MOSI |
| MISO | GPIO12 (D6) | SPI MISO |
| SCK | GPIO14 (D5) | SPI Clock |
Base topic:
rfid/y2c_team0125/
rfid/y2c_team0125/card/statusrfid/y2c_team0125/card/topuprfid/y2c_team0125/card/payrfid/y2c_team0125/card/balance
No wildcard subscriptions.
No generic topics.
Strict team isolation enforced.
The system uses SQLite to ensure safe and atomic wallet operations.
- Cards
- Wallet
- Products
- Transactions (Ledger)
Each transaction stores:
- Transaction type (TOPUP / PAYMENT)
- Previous balance
- New balance
- Timestamp
All wallet operations follow:
- BEGIN TRANSACTION
- Validate balance (for payments)
- Update wallet balance
- Insert transaction record
- COMMIT
If any step fails:
ROLLBACK
This guarantees:
- No partial updates
- No double spending
- No inconsistent balances
- Full transaction integrity
ESP → MQTT → Backend → WebSocket → Dashboard
Dashboard → HTTP → Backend → MQTT → ESP
ESP → MQTT → Backend → WebSocket → Dashboard
Dashboard → HTTP → Backend
Backend validates balance → Safe DB update → MQTT command to ESP
ESP confirms → WebSocket update to dashboard
- Backend deployed on VPS
- Public dashboard accessible online
- Repository is public and structured
Licensed under the ISC License.