首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >RFID与Arduino的接口

RFID与Arduino的接口
EN

Stack Overflow用户
提问于 2018-09-07 22:10:54
回答 1查看 126关注 0票数 0

我想把RC522和Arduino UNO board连接起来。我使用了下面的表格来连接RC522芯片。

代码语言:javascript
复制
SDA      10
SCK      13
MOSI     11
MISO     12
IRQ      UNUSED
GND      GND
RST      9
3.3V     3.3V
代码语言:javascript
复制
#include "SPI.h" // SPI library
#include "MFRC522.h" // RFID library (https://github.com/miguelbalboa/rfid)
const int pinRST = 9;
const int pinSDA = 10;
MFRC522 mfrc522(pinSDA, pinRST); // Set up mfrc522 on the Arduino
void setup() {
  SPI.begin(); // open SPI connection
  mfrc522.PCD_Init(); // Initialize Proximity Coupling Device (PCD)
  Serial.begin(230400); // open serial connection
}
void loop() {
  if (mfrc522.PICC_IsNewCardPresent()) { // (true, if RFID tag/card is present ) PICC = Proximity Integrated Circuit Card
    if(mfrc522.PICC_ReadCardSerial()) { // true, if RFID tag/card was read
      Serial.print("RFID TAG ID:");
      for (byte i = 0; i < mfrc522.uid.size; ++i) { // read id (in parts)
        Serial.print(mfrc522.uid.uidByte[i], HEX); // print id as hex values
        Serial.print(" "); // add space between hex blocks to increase readability
      }
      Serial.println(); // Print out of id is complete.
    }
  }
}

带RFID卡时,串行显示器显示空白。

EN

回答 1

Stack Overflow用户

发布于 2021-06-30 00:57:03

您使用的布线方法与我们在使用Arduino和MFRC522的射频识别教程中使用的布线方法相同:

​根据您提供的信息,很难判断您可能遇到了什么问题。然而,这里有一些建议:

  • 您的串行监视器是否设置为波特率 230400 以匹配您的代码?
  • 您是否尝试过在 mfrc522.PCD_Init() 之后添加延迟? 5ms左右的延迟就足够了
  • 你用的是什么 Arduino 板?在 serial.begin() 之后可能还需要延迟

我们写了一个教程,扩展了一些基础知识,这可能会帮助你解决你的问题:

An Introduction to RFID with Arduino

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52224300

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档