Hello every one. I have a similar project and i found it wise to place my question here.
My project is a door entry system using the rfid 522 module and arduino nano. The project is already complete and the problem i am facing is that the program seems to freeze after some times the relay energized with load (door loock). some times working continious, other times only 1 entry. It seems like random.
I make some research and i add this circuit for the relay:
by using this circuit works a litle better but the problem continious.
This happens only if i have load to the relay (the door lock). with out load works just fine.
the door lock works with 8v to 24v. i ve tried with several voltage from minimum to maximum but nothing change.
the code is the following:
- All the resources for this project: https://randomnerdtutorials.com/
- Modified by Rui Santos
- Created by FILIPEFLOP
*/
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 4
#define RST_PIN 5
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
const int buzzerPin = 6;
void setup()
{
pinMode(buzzerPin, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
digitalWrite(2, LOW); // turn the LOCK on (HIGH is the voltage level)
Serial.begin(9600); // Initiate a serial communication
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522
Serial.println("Approximate your card to the reader...");
Serial.println();
tone(buzzerPin, 100, 100);
delay(1000);
tone(buzzerPin, 50, 100);
}
void Function1()
{
delay(500);
digitalWrite(2, HIGH); // turn the LOCK on (HIGH is the voltage level)
delay(1000);
digitalWrite(2, LOW); // turn the LOCK on (HIGH is the voltage level)
delay(500);
}
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("Message : ");
content.toUpperCase();
if ((content.substring(1) == "xx xx xx xx") || (content.substring(1) == "xx xx xx xx")|| (content.substring(1) == "xx xx xx xx")) //change here the UID of the card/cards that you want to give access
{
tone(buzzerPin, 100, 100);
delay(500);
{
Function1();
}
}
else {
tone(buzzerPin, 1000, 15000); /* 1 minute delay for safety if not
the correct card
delay(60000);
}
}
any suggestion?
thank you very much