Example 43: RFID Card (MFRC522)
Example 43: RFID Card (MFRC522)
Experiment Overview
MFRC522 is a commonly used RFID reader that supports reading Mifare series IC cards (13.56MHz). It communicates via SPI interface, enabling access control, attendance tracking, item tagging, and similar applications. FastBee includes built-in RFID driver in Standard / Full firmware.
Note: This feature requires
FASTBEE_ENABLE_RFID=1; disabled by default in Lite firmware.
Hardware Wiring
| Board Label | GPIO Pin | Connected Device |
|---|---|---|
| SDA(SS) | GPIO5 | MFRC522 SDA (Chip Select) |
| SCK | GPIO18 | MFRC522 SCK |
| MOSI | GPIO23 | MFRC522 MOSI |
| MISO | GPIO19 | MFRC522 MISO |
| RST | GPIO27 | MFRC522 RST (Reset) |
MFRC522 requires 3.3V power supply; do NOT connect to 5V!
JSON Configuration Example
{
"peripherals": [
{
"id": "rfid_01",
"name": "RFID Reader",
"type": 38,
"enabled": false,
"pins": [5, 18, 23, 19, 27],
"params": {
"category": "rfid"
}
}
]
}Peripheral Execution Linkage
Scenario 1: Card Swipe Unlock (Event Trigger)
Feature: When RFID card is detected, open relay for 3 seconds then close
Web UI Configuration Steps
Step 1: Ensure Relay Peripheral is Configured
- Peripheral ID:
relay_01 - Type: GPIO Output
Step 2: Create Rule
- Click Peripheral Config in the left menu → Switch to Peripheral Execution tab
- Click New Rule button
- Fill in basic configuration:
- Rule Name:
RFID Unlock - Report Data: ✅ Enabled
- Enable: ✅ Enabled
- Rule Name:
Step 3: Configure Trigger (Event Trigger)
Click Add Trigger button
Fill in trigger configuration:
Field Value Description Trigger Type Select Event Trigger RFID card swipe event Event Type 120RFID card detected Event Source Select rfid_01RFID reader
Step 4: Configure Actions (3 actions required)
Action 1: Open Relay
- Click Add Action button
- Fill in:
- Action Type: Select HIGH
- Target Peripheral: Select
relay_01
Action 2: Delay 3 Seconds
- Click Add Action button again
- Fill in:
- Action Type: Select Delay
- Delay Time:
3000(3000ms = 3 seconds)
Action 3: Close Relay
Click Add Action button a third time
Fill in:
- Action Type: Select LOW
- Target Peripheral: Select
relay_01
Click Save button
Scenario 2: Card Removal Event (Event Trigger)
Feature: Turn off LED when RFID card is removed
Configuration Steps:
- Create rule, name:
RFID Card Removed - Trigger configuration:
- Trigger Type: Select Event Trigger
- Event Type:
121(RFID card removed) - Event Source: Select
rfid_01
- Action configuration:
- Action Type: Select HIGH (LED off)
- Target Peripheral: Select
led_d1
- Click Save
RFID Specifications
| Feature | Description |
|---|---|
| Operating Frequency | 13.56MHz |
| Supported Cards | Mifare series IC cards |
| Read Distance | 3-5cm |
| UID Format | 4-byte hexadecimal (e.g., A1B2C3D4) |
| Polling Rate | Internal 200ms polling |
Notes
- Firmware Version: Use Standard / Full firmware, or enable
FASTBEE_ENABLE_RFIDin custom build - Power Supply: MFRC522 must use 3.3V; 5V will damage the chip
- Read Distance: Typical card reading distance is 3-5cm
- UID Format: Card UID is 4-byte hexadecimal, e.g.,
A1B2C3D4 - SPI Pins: Pin order is SS, SCK, MOSI, MISO, RST
- Polling Rate: Driver internally polls for cards every 200ms
