rc522 rfid spi在ttgo tdisplay上

发布于 2025-02-07 22:24:14 字数 2126 浏览 4 评论 0原文

这将是该ESP32板TTGO TDISPLAY的特定特定特定的。我可以使RC522与其他ESP32合作。

要在此板上引用SPI引脚: https://github.com /xinyuan-lilygo/ttgo-t-t-display/eskoes/32

现在,RC522正在识别并成功返回固件编号,但不会读取卡片。我已经验证了它在其他设备上有效的工作。

MISO - 27
MOSI - 26
CLK - 25
CS - 33
RST - 17

我将最高点设置为高,就像其他ESP32设备上一样高且起作用。

我不知道我是否错过了一步(可能会在板载显示屏上禁用SPI),还是该板上的SPI有所不同。我对这两个设备检查SS,OLED是1,RC522也是...但是,在其他ESP32上,RC522仍然是1个,

不确定这在TTGO上是否有所不同,因为有两个SPI的速度,OLED和RC522。我相信他们都在使用不同的SPI总线,HSPI和VSPI。 OLED引脚无法访问,因此我正在使用另一组。

下面的代码

#include <SPI.h>
#include <MFRC522.h>
#include <TFT_eSPI.h> // Hardware-specific library

#define RST_PIN 17 // Configurable, see typical pin layout above
#define SS_PIN 33 // Configurable, see typical pin layout above

MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance

TFT_eSPI tft = TFT_eSPI(); // Invoke custom library

void setup() {
Serial.begin(9600); // Initialize serial communications with the PC
while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)

pinMode(RST_PIN, OUTPUT);
digitalWrite(RST_PIN, HIGH);
Serial.println("HELLO");
Serial.println(digitalRead(RST_PIN));
tft.init();

tft.fillScreen(TFT_WHITE);

SPI.begin(25,27,26);            // Init SPI bus CLK, MISO, MOSI
mfrc522.PCD_Init();     // Init MFRC522
delay(4);               // Optional delay. Some board do need more time after init to be ready, see Readme
mfrc522.PCD_DumpVersionToSerial();  // Show details of PCD - MFRC522 Card Reader details
Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks..."));
}

void loop() {
// Reset the loop if no new card present on the sensor/reader. This saves the entire process when idle.
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}

// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
    return;
}

// Dump debug info about the card; PICC_HaltA() is automatically called
mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
}

This is going to be pretty specific to this one ESP32 board, TTGO TDISPLAY. I am able to get the RC522 working with other ESP32's.

For reference of SPI pins on this board: https://github.com/Xinyuan-LilyGO/TTGO-T-Display/issues/32

Right now, the RC522 is being recognized and returns the firmware number successfully, but it will not read cards. I have verified it works on other devices.

MISO - 27
MOSI - 26
CLK - 25
CS - 33
RST - 17

I am setting RST to HIGH, as on other ESP32 devices it reads HIGH and works.

I do not know if I'm missing a step (something maybe to disable SPI on the onboard display) or if there's something different about SPI on this board.I'm checking SS for both devices, the OLED is 1 as is the RC522... However, the RC522 is still 1 on the other ESP32 that works...

Not sure if this is different on the TTGO because there are two SPI's going, OLED and RC522. I believe they are both using different SPI busses, HSPI and VSPI. The OLED pinouts are not accessible, so I'm using the other set.

Code below

#include <SPI.h>
#include <MFRC522.h>
#include <TFT_eSPI.h> // Hardware-specific library

#define RST_PIN 17 // Configurable, see typical pin layout above
#define SS_PIN 33 // Configurable, see typical pin layout above

MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance

TFT_eSPI tft = TFT_eSPI(); // Invoke custom library

void setup() {
Serial.begin(9600); // Initialize serial communications with the PC
while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)

pinMode(RST_PIN, OUTPUT);
digitalWrite(RST_PIN, HIGH);
Serial.println("HELLO");
Serial.println(digitalRead(RST_PIN));
tft.init();

tft.fillScreen(TFT_WHITE);

SPI.begin(25,27,26);            // Init SPI bus CLK, MISO, MOSI
mfrc522.PCD_Init();     // Init MFRC522
delay(4);               // Optional delay. Some board do need more time after init to be ready, see Readme
mfrc522.PCD_DumpVersionToSerial();  // Show details of PCD - MFRC522 Card Reader details
Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks..."));
}

void loop() {
// Reset the loop if no new card present on the sensor/reader. This saves the entire process when idle.
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}

// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
    return;
}

// Dump debug info about the card; PICC_HaltA() is automatically called
mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清引 2025-02-14 22:24:14

漠视。原来我的地面很糟糕。一旦我改为另一个地面,它就可以了。

上面的代码应该适用于试图在TTGO TDISPLAY上使用RC522的任何人。只需检查您的连接即可。

Disregard. Turns out I had a bad ground pin. Once I changed to a different ground, it worked fine.

Code above should work for anyone trying to get RC522 working on TTGO TDISPLAY. Just check your connections.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文