艺术
美容与健康
工艺
文化与历史
娱乐
环境
食品与饮料
逆向工程
科学
体育
技术
可穿戴设备
RFID Access Reader
Ed

创建者

Ed

14. 八月 2026FI
0
0
0
0
0

RFID Access Reader

A door reader that unlocks only for cards on a list you control. Built at 13.56 MHz on the SM130 Mifare module carried by its evaluation shield, with a relay board to switch the strike. The module is configured into Auto Mode, where it reports a card's unique identifier over serial as plain ASCII the moment the card enters the field — so the Arduino only has to read a line of text and compare it, with no binary protocol to implement. Be clear about what this gives you: a MIFARE Classic 1K identifier can be read by anyone standing near the card, and cloned. This is an access convenience, like a key that can be copied at any hardware shop — not a security barrier.
中级
3 hours

说明

1

Assemble the relay board

The Beefcake board ships as a kit and has to be soldered before anything else.

  1. Fit the relay, the screw terminals and the passives.
  2. Check the coil side and the contact side are on the correct halves of the board before applying power.
The contact side switches your door strike and may carry mains-adjacent voltage. If it does, treat the whole contact side as live and do not work on it powered.

此步骤所需材料:

SparkFun Beefcake Relay Control KitSparkFun Beefcake Relay Control Kit1 套件

所需工具:

Ryobi ONE+ RSI18-0 Cordless Soldering IronRyobi ONE+ RSI18-0 Cordless Soldering Iron
2

Mount the reader module and wire it — pin by pin

Fit the SM130 and its antenna to the 13.56 MHz evaluation shield, then wire the shield to the Arduino.

  1. SM130 TX → Arduino D2 (Arduino receives)
  2. SM130 RX → Arduino D3 (Arduino transmits)
  3. SM130 VCC5V, GNDGND
  4. Relay board control input → Arduino D7, its GND to Arduino GND

The SM130's UART is 5 V and 5 V tolerant, so it connects straight to an Uno with no level converter. That is specific to this module — the 3.3 V SM5210 parts do need one.

Never wire the module's UART pins to an RS232 port directly. RS232 swings around ±12 V and will destroy it; a USB-UART adapter is required.

此步骤所需材料:

RFID Module - SM130 Mifare (13.56 MHz)RFID Module - SM130 Mifare (13.56 MHz)1
RFID Evaluation Shield - 13.56MHzRFID Evaluation Shield - 13.56MHz1
Arduino Uno R3 SMDArduino Uno R3 SMD1
Jumper Wires Premium M/M 20 AWG - 15.5 cm (Pack of 10)Jumper Wires Premium M/M 20 AWG - 15.5 cm (Pack of 10)1
3

Configure the module for Auto Mode with ASCII output

Out of the box the module is in Standard Mode, where it waits for binary commands. Put it into Auto Mode with ASCII output instead, using SonMicro's Mifare Panel tool over a USB-UART adapter.

  1. Set Operation Mode to Auto Mode (Automatic Card Reading).
  2. Under Auto Read Mode set Serial Output Type to ASCII, and tick CR and LF.
  3. Leave Baudrate at its factory 19200.

That combination is the stock template 02/AUTO-B-P-ASCII-CRLF, so it can also be ordered pre-configured, or applied from a supplied .xml upgrade file with no configuration step at all.

Auto Mode is what makes this project simple. The module reports each card as a line of plain text the moment it enters the field, so the Arduino never has to build a framed binary packet or verify a checksum.

此步骤所需材料:

USB-B CableUSB-B Cable1
4

Read a card and write its identifier down

Power the Arduino over USB, open the serial monitor at 9600, and upload the sketch from the next step with the allow-list still empty.

  1. Present a tag. A line of hex digits appears.
  2. Write that identifier down exactly as printed.
  3. Repeat for every card that should be allowed.
Read the identifiers off the actual cards rather than assuming a format. Length varies by card family — a MIFARE Classic 1K reports 4 bytes, other ISO14443A cards report 7.

此步骤所需材料:

RFID Tag - Adhesive Mifare 1K (13.56 MHz)RFID Tag - Adhesive Mifare 1K (13.56 MHz)2
5

Upload the access sketch

Put the identifiers you recorded into the ALLOWED array, then upload. SoftwareSerial ships with the IDE — nothing else is needed.

rfid_access_reader.inoarduino
// RFID Access Reader -- 13.56 MHz SM130 in Auto Mode, ASCII output + CR/LF
//
// The module is configured (template 02/AUTO-B-P-ASCII-CRLF) to print each
// card's UID as plain ASCII the moment the card enters the field. So this
// sketch just reads a line of text and compares it -- no binary framing,
// no checksums, nothing to get subtly wrong.
//
// Wiring:  SM130 TX -> D2   SM130 RX -> D3   relay control -> D7
// SM130 UART is 5V tolerant, so no level converter is needed on an Uno.

#include <SoftwareSerial.h>

const int  RFID_RX_PIN = 2;      // Arduino receives  <- SM130 TX
const int  RFID_TX_PIN = 3;      // Arduino transmits -> SM130 RX
const long RFID_BAUD   = 19200;  // stdMifare factory default

const int  RELAY_PIN   = 7;
const unsigned long UNLOCK_MS = 3000;   // how long the strike stays released

SoftwareSerial rfid(RFID_RX_PIN, RFID_TX_PIN);

// Identifiers that may open the door. Read these off your own cards in
// step 4 -- these two are placeholders and will not match anything.
const char *ALLOWED[] = {
  "A1B2C3D4",
  "11223344"
};
const uint8_t ALLOWED_COUNT = sizeof(ALLOWED) / sizeof(ALLOWED[0]);

char    uid[24];
uint8_t idx = 0;

bool isAllowed(const char *candidate) {
  for (uint8_t i = 0; i < ALLOWED_COUNT; i++) {
    if (strcasecmp(candidate, ALLOWED[i]) == 0) return true;
  }
  return false;
}

void unlock() {
  digitalWrite(RELAY_PIN, HIGH);
  delay(UNLOCK_MS);
  digitalWrite(RELAY_PIN, LOW);
}

void handleUid(const char *u) {
  Serial.print(F("card: "));
  Serial.print(u);

  if (isAllowed(u)) {
    Serial.println(F("  -> GRANTED"));
    unlock();
  } else {
    Serial.println(F("  -> denied"));
  }
}

void setup() {
  Serial.begin(9600);      // local monitor over USB
  rfid.begin(RFID_BAUD);   // the reader module

  pinMode(RELAY_PIN, OUTPUT);
  digitalWrite(RELAY_PIN, LOW);   // fail secure: door locked on power-up

  Serial.println(F("reader ready -- present a card"));
}

void loop() {
  while (rfid.available()) {
    char c = rfid.read();

    if (c == '\r' || c == '\n') {      // end of one reported card
      if (idx > 0) {
        uid[idx] = '\0';
        handleUid(uid);
        idx = 0;
      }
    } else if (idx < sizeof(uid) - 1) {
      uid[idx++] = c;
    } else {
      idx = 0;   // overlong line: discard rather than overrun the buffer
    }
  }
}
6

Test the reject path before the accept path

Present an unlisted card first, and confirm the relay stays shut and the monitor prints denied.

  1. Only then present a listed card and confirm it opens.
  2. Wire the strike through the relay's normally-open contact, so a power cut leaves the door secure rather than released.
A reader that opens for everything looks perfect if you only ever test a valid card — the comparison being inverted is invisible from the happy path. Test the failure first, always.

CC0 公共领域

此蓝图以 CC0 协议发布。你可以自由复制、修改、分发和使用此作品,无需征得许可。

通过购买蓝图中的产品支持创客,他们将获得 创客佣金 (由供应商设定),或创建此蓝图的新版本并将其作为连接包含在你自己的蓝图中以分享收入。

讨论

(0)

登录 加入讨论

加载评论中...