So I am trying to use both the MCFCR522 and the sim900 to develop a project so the when I use a NFC tag I will receive an SMS saying that I have been clocked in. But when I upload the command to the arduino there are no errors and no output also. I tried it in the void setup statement but I cannot read the NFC tags since it runs the program only once.
So my questions are do both the modules work together ? they work well separately so is this some kind of compatibility issue ? or Am I missing something entirely ?
The code that I am using is :
void setup()
{
//Begin serial communication between board and the IDE
Serial.begin(9600);
SPI.begin();
//Start coms with the mfrc522 module
mfrc522.PCD_Init();
//Begin serial communication with Arduino and SIM900
mySerial.begin(9600);
Serial.println("Initializing...");
delay(1000);
mySerial.println("AT"); //Handshaking with SIM900
updateSerial();
Serial.println("Approximate 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("Message : ");
content.toUpperCase();
if (content.substring(1) == "A3 03 A7 1D")
{
Serial.println("Authorized access");
mySerial.println("AT+CMGF=1"); // Configuring TEXT mode
updateSerial();
mySerial.println("AT+CMGS=\"xxxxxxxxxx\"");//change Z xxxxxxxxxxx with phone number to sms
updateSerial();
mySerial.print(" Clocked in ");
updateSerial();
mySerial.write(26);
Serial.println();
delay(3000);
}
else if(content.substring(1) == "A3 48 E3 1B") {
Serial.println("Authorized access");
mySerial.println("AT+CMGF=1"); // Configuring TEXT mode
updateSerial();
mySerial.println("AT+CMGS=\"xxxxxxxxxx\"");//change Z xxxxxxxxxxx with phone number to sms
updateSerial();
mySerial.print(" Clocked in ");
updateSerial();
mySerial.write(26);
Serial.println();
delay(3000);
}
else{
Serial.println("Please Try again");
}
}
//Serial to check if there is any incoming signal to the arduino from GSM module
void updateSerial()
{
delay(500);
while (Serial.available())
{
mySerial.write(Serial.read());//Forward what Serial received to Software Serial Port
}
while(mySerial.available())
{
Serial.write(mySerial.read());//Forward what Software Serial received to Serial Port
}
}