May 1st, 2019 by cedcraftscodes
In this tutorial, we will learn how to connect Arduino with FRID and GSM Module. This is a cool project that can be used in different scenarios (e.g. School ID system with SMS notification which notifies parents if their child arrived at school; Doorlock system with SMS notification) and many more.
MFRC522 RFID Module
SIM800L GSM Module
Arduino
Jumper Wires
MFRC522 RFID Module
Pin | Wiring to Arduino Uno |
SDA | Digital 10 |
SCK | Digital 13 |
MOSI | Digital 11 |
MISO | Digital 12 |
IRQ | unconnected |
GND | GND |
RST | Digital 9 |
3.3V | 3.3V |
Sim800L GSL Module
Pin | Wiring to Arduino Uno |
RX | Digital 2 |
TX | Digital 3 |
GND | GND |
VCC | 5V |
If you have trouble connecting your GSM module, I have a separate tutorial on how to connect your GSM module and send SMS.
After you have connected your Arduino and downloaded the MFRC522 Library Go to “Sketch -> Include Library -> Add .ZIP Library” and browse your downloaded ZIP file.
Upload the following Codes to your Arduino
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | #include <SPI.h> #include <MFRC522.h> #include <SoftwareSerial.h> SoftwareSerial mySerial(3, 2); constexpr uint8_t RST_PIN = 9; constexpr uint8_t SS_PIN = 10; MFRC522 mfrc522(SS_PIN, RST_PIN); void setup() { mySerial.begin(9600); SPI.begin(); } void loop() { if ( ! mfrc522.PICC_IsNewCardPresent()) { return; } if ( ! mfrc522.PICC_ReadCardSerial()) { return; } long code=0; for (byte i = 0; i < mfrc522.uid.size; i++) { code=((code+mfrc522.uid.uidByte[i])*10); } if(code != 0) { String message = "Card Scanned: " + String(code); sendSms(message); } delay (2000); } void sendSms(String message) { delay(1000); mySerial.println("AT"); delay(500); mySerial.println("AT+CMGF=1"); delay(500); mySerial.println("AT+CMGS=\"+ZZXXXXXXXXXX\"\r"); delay(500); mySerial.print(message); delay(500); mySerial.write(26); } |
Replace the ZZ with your country code, followed by your phone number. For example, in the Philippines, ZZ would be 63, followed by the next 10 digits.
That’s it! Hope it helps 🙂 Please share this tutorial by clicking the social media buttons below.
Ali ATEÅž
December 8, 2019 at 4:41 am#include
#include
#include
SoftwareSerial mySerial(3, 2);
constexpr uint8_t RST_PIN = 9;
constexpr uint8_t SS_PIN = 10;
MFRC522 mfrc522(SS_PIN, RST_PIN);
void setup() {
mySerial.begin(9600);
SPI.begin();
}
void loop() {
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;
}
long code=0;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
code=((code+mfrc522.uid.uidByte[i])*10);
}
if(code != 0) {
String message = "Card Scanned: " + String(code);
sendSms(message);
}
delay (2000);
}
void sendSms(String message) {
delay(1000);
mySerial.println("AT");
delay(500);
mySerial.println("AT+CMGF=1");
delay(500);
mySerial.println("AT+CMGS=\"+ZZXXXXXXXXXX\"\r");
delay(500);
mySerial.print(message);
delay(500);
mySerial.write(26);
}
Codes don't work like this