سلام
کد زیر رو روی برد Esp8266 آپلود می کنم که ازش برای خواندن تگ های RFID با ماژول RC522 استفاده میکنم اما بعد از چند ساعت دیگه چیزی نمی خونه و باید برد ریست بشه.
کسی می دونه مشکل از کجاست؟
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN D4
#define RST_PIN D3
#define LED_B D2 //define green LED pin
#define LED_R D0 //define red LED
#define RELAY1 D1 //relay pin
#define RELAY2 D8 //buzzer pin
#define ACCESS_DELAY 700
#define DENIED_DELAY 1000
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
void setup()
{
Serial.begin(115200); // Initiate a serial communication
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522
pinMode(LED_B, OUTPUT);
pinMode(LED_R, OUTPUT);
pinMode(RELAY1, OUTPUT);
pinMode(RELAY2, OUTPUT);
digitalWrite(RELAY1, HIGH);
digitalWrite(RELAY2, HIGH);
Serial.println("Put your card to the reader...");
Serial.println();
}
void loop()
{
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
//Show UID on serial monitor
Serial.print("UID tag :");
String content = "";
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
content.concat(String(mfrc522.uid.uidByte[i], HEX));
}
Serial.println();
Serial.print("User : ");
content.toUpperCase();
if (content.substring(1) == "9C 96 59 A9" || content.substring(1) == "EC 74 51 9C" || content.substring(1) == "01 02 03 04" || content.substring(1) == "04 43 F4 35") //change here the UID of the card/cards that you want to give access
{
Serial.println("Authorized access");
Serial.println();
delay(500);
digitalWrite(RELAY1, LOW);
digitalWrite(RELAY2, LOW);
digitalWrite(LED_B, HIGH);
delay(ACCESS_DELAY);
digitalWrite(RELAY1, HIGH);
digitalWrite(RELAY2, HIGH);
delay(500);
digitalWrite(LED_B, LOW);
delay(50);
digitalWrite(LED_R, HIGH);
delay(100);
digitalWrite(LED_R, LOW);
digitalWrite(LED_B, HIGH);
delay(100);
digitalWrite(LED_B, LOW);
digitalWrite(LED_R, HIGH);
delay(100);
digitalWrite(LED_R, LOW);
digitalWrite(LED_B, HIGH);
delay(100);
digitalWrite(LED_B, LOW);
digitalWrite(LED_R, HIGH);
delay(800);
digitalWrite(LED_R, LOW);
}
else {
Serial.println(" Access denied");
digitalWrite(LED_R, HIGH);
delay(DENIED_DELAY);
digitalWrite(LED_R, LOW);
}
}