Feature: Remote Management
Complexity: 🟡 Medium Hardware Required: ✅ None (ESP32-C3 has built-in WiFi/Bluetooth) User Value: ⭐⭐⭐ Essential
Overview
Leverage the ESP32-C3 SuperMini’s built-in WiFi (802.11 b/g/n) and Bluetooth 5.0 (BLE) capabilities to enable remote configuration, monitoring, and control of the RFID system. No additional hardware needed!
Benefits
- Configure cards remotely via web interface
- Real-time access monitoring from anywhere
- Remote door unlock capability
- System diagnostics and alerts
- Over-the-air (OTA) firmware updates
- Mobile app control via BLE
- Home automation integration
Built-in Connectivity Features
WiFi Capabilities
- 802.11 b/g/n (2.4 GHz)
- Access Point and Station modes
- WPA/WPA2/WPA3 security
- Up to 150 Mbps data rate
- IPv4 and IPv6 support
Bluetooth Capabilities
- Bluetooth 5.0 (LE)
- Extended advertising
- 2 Mbps PHY for faster data
- Long range mode
- Multiple connections
Implementation Checklist
Phase 1: WiFi Setup
- Create
WiFiManager
class:class WiFiManager { private: String ssid; String password; WebServer server; bool apMode; public: void begin(); void startAP(const char* apSSID); void connectToWiFi(const char* ssid, const char* pass); bool isConnected(); void handleClient(); String getIPAddress(); };
- Implement connection modes:
- AP mode for initial setup
- Station mode for normal operation
- Auto-fallback to AP on connection failure
- mDNS for easy discovery (rfid.local)
Phase 2: Web Interface
- Built-in web server:
void setupWebServer() { server.on("/", HTTP_GET, handleRoot); server.on("/api/status", HTTP_GET, handleStatus); server.on("/api/cards", HTTP_GET, handleListCards); server.on("/api/cards", HTTP_POST, handleAddCard); server.on("/api/cards", HTTP_DELETE, handleRemoveCard); server.on("/api/unlock", HTTP_POST, handleUnlock); server.on("/api/logs", HTTP_GET, handleLogs); server.on("/update", HTTP_POST, handleOTA); server.begin(); }
- RESTful API endpoints:
GET /api/status
- System statusGET /api/cards
- List authorized cardsPOST /api/cards
- Add new cardDELETE /api/cards/{uid}
- Remove cardPOST /api/unlock
- Remote unlockGET /api/logs
- Access historyGET /api/config
- Get configurationPUT /api/config
- Update configuration
Phase 3: BLE Implementation
- Create
BLEManager
class:class BLEManager { private: BLEServer* pServer; BLECharacteristic* pStatusChar; BLECharacteristic* pCommandChar; BLECharacteristic* pConfigChar; public: void begin(const char* deviceName); void advertise(); void updateStatus(String status); bool isConnected(); void handleCommand(String cmd); };
- BLE Services:
- RFID Service UUID
- Status characteristic (notify)
- Command characteristic (write)
- Config characteristic (read/write)
- Security with pairing
Phase 4: Security Implementation
- WiFi Security:
- WPA2/WPA3 encryption
- HTTPS with self-signed cert
- Session tokens
- Rate limiting
- BLE Security:
- Pairing with PIN
- Encrypted characteristics
- Connection whitelist
- General Security:
- Authentication required
- Command validation
- Audit logging
Phase 5: Web Dashboard
- Modern responsive UI:
<!DOCTYPE html> <html> <head> <title>RFID Access Control</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> /* Embedded CSS for single-file deployment */ body { font-family: Arial; margin: 20px; } .card { background: #f0f0f0; padding: 20px; margin: 10px 0; } button { background: #4CAF50; color: white; padding: 10px 20px; } </style> </head> <body> <h1>RFID Access Control</h1> <div id="status" class="card"> <h2>System Status</h2> <p>WiFi: <span id="wifi-status">Connected</span></p> <p>Last Access: <span id="last-access">None</span></p> </div> <div class="card"> <h2>Quick Actions</h2> <button onclick="unlockDoor()">Unlock Door</button> <button onclick="viewLogs()">View Logs</button> </div> <script> // Embedded JavaScript async function unlockDoor() { const response = await fetch('/api/unlock', {method: 'POST'}); alert(response.ok ? 'Door Unlocked!' : 'Failed'); } </script> </body> </html>
Phase 6: Mobile App Features
- BLE Scanner:
- Auto-discover RFID system
- Connect with pairing
- Remember paired devices
- Remote Functions:
- Unlock door
- Add/remove cards
- View access logs
- Configure settings
- Notifications:
- Access alerts
- Low battery warnings
- System errors
Phase 7: OTA Updates
- Web-based OTA:
void handleOTA() { HTTPUpload& upload = server.upload(); if (upload.status == UPLOAD_FILE_START) { Update.begin(); } else if (upload.status == UPLOAD_FILE_WRITE) { Update.write(upload.buf, upload.currentSize); } else if (upload.status == UPLOAD_FILE_END) { Update.end(true); ESP.restart(); } }
- Safety features:
- Rollback on failure
- Version checking
- Signature verification
Phase 8: MQTT Integration
- MQTT client setup:
void setupMQTT() { mqttClient.setServer(MQTT_SERVER, MQTT_PORT); mqttClient.setCallback(mqttCallback); // Topics String baseTopic = "rfid/" + deviceId + "/"; mqttClient.subscribe((baseTopic + "command").c_str()); mqttClient.publish((baseTopic + "status").c_str(), "online"); }
- Home Assistant discovery
- Status publishing
- Command subscription
Testing Checklist
- WiFi connection reliability
- AP mode fallback
- Web interface responsiveness
- API endpoint testing
- BLE connection stability
- OTA update process
- Security testing
- Power consumption impact
- Range testing
Example Usage
WiFi Configuration Portal
// On first boot or reset
if (!WiFi.isConnected()) {
WiFi.mode(WIFI_AP);
WiFi.softAP("RFID-Setup");
// Start config portal on 192.168.4.1
}
BLE Mobile App Commands
// Command format: CMD:PARAMS
// Examples:
// "UNLOCK:5" - Unlock for 5 seconds
// "ADD:04A3B2C1" - Add card UID
// "STATUS:" - Get system status
MQTT Topics
rfid/device123/status - System status
rfid/device123/access - Access events
rfid/device123/command - Control commands
rfid/device123/config - Configuration
Power Considerations
- WiFi active: ~100mA additional
- WiFi power save mode: ~20mA
- BLE advertising: ~10mA
- Deep sleep with wake on BLE: ~1mA
Security Best Practices
- Change default passwords
- Use strong WiFi encryption
- Enable HTTPS for web interface
- Implement rate limiting
- Regular security updates
- Audit log all remote access
- Fail-safe local operation
Future Enhancements
- WebSocket for real-time updates
- Progressive Web App (PWA)
- Voice assistant integration
- Video doorbell integration
- Multi-site management
- Cloud backup/sync
- Machine learning for anomaly detection