HUM: RDM6300

HUM: RDM6300-Uncategorized

You are a beginner with Dasduino. Or electronics? A specific module caught your eye, but you do not know how to use it? Do not worry, HUM is here for you! How to Use Module (HUM) is a blog tutorials series by soldered where you will find all you need in order to begin working with your favorite module. Tutorials include: technical characteristics, work principle, instructions on how to connect the module with Dasduino and the basic code. Everything else is left to your imagination.

INTRODUCTION

If you have the need to ensure unauthorized access to a room or building, the need to control when someone enters or leaves the building, or anything similar, this tutorial is intended for you. It is about the RDM6300 rfid reader that is used to read cards or tags that contain a special code on it, and each code on the card or tag is different. How the reader works and how the communication between the reader and the card looks like is described below, and in the end, there is a code that allows access control.

Module characteristics:
• Frequency: 125kHz
• Reading distance: 2-5 cm
• Communication: serial
• Voltage: 5V
• Dimensions: 3.8 x 1.8 x 1.2cm

HOW DOES IT WORK?

The RDM6300 module comes with a small external antenna (loop). Even though it all sounds complicated, when we have a closer look at its basic parts and work principle, it becomes much simpler and understandable, so let us begin with the working principle of this device.
As we have already mentioned, the module comes with an external antenna which is an important part of this module and without it, the module can not work. On the module, there is a chip that controls the antenna and through the antenna, it receives data and sends that same data via serial communication to Dasduino. The cards we use to approach the antenna are also powered by the RFID reader, since these cards are passive and do not contain a battery or any other source of power supply within. The cards consist of a small chip that has a code unique to each card stored in it. Also, inside the card, there is an antenna (loop) similar to the RFID reader antenna that powers the chip within the card and through which the data is also sent to the RFID reader antenna.

Therefore, the principle is simple when the card is placed near the RFID reader antenna. The card receives its power supply via its antenna because of the electromagnetic waves and the card chip “awakens” and starts sending the code, and finally, the rfid reader receives that code and sends it to Dasduino. When we move the card away, it is left without power and no code is sent. For this reason, sometimes it happens that if we hold the card close to the RFID reader’s antenna, the reader scans the card multiple times.

 

HOW TO CONNECT IT?

The module is connected to Dasduino via serial communication (UART), and for that same reason, we need to use the SoftwareSerial library, which allows us to create serial communication on other pins because we need the pins 0 and 1 for the Serial monitor and communication with the computer.
We will connect the module to the power supply (5V and GND), and the pins Tx and Rx will be connected to the D2 and D3 Dasduino pins, but everything is also visible in the given scheme.

ARDUINO CODE

To work with this module, we use the library that comes installed with Arduino IDE and therefore, we do not need to install it. The library creates serial communication on the pins that we choose, and we have chosen D2 for the Tx pin in this code, and for the Rx pin, we have chosen the D3 Dasduino pin.
The first example of the code displays a unique code that is stored in the card when the card is closer to the reader (reader antenna), on the Serial monitor. We must know this code if we want to have controlled access to a room as described in the second example.

#include <SoftwareSerial.h&gt//including the library that serves to establish serial communication on other pins
SoftwareSerial RFID(2, 3); //(RX,TX) Our SoftwareSerial library constructor  
                 // using which, we set the serial communication to pins 2 and 3
void setup() {
  Serial.begin(9600);//Serial communication initialization (speed 9600 baud)
  RFID.begin(9600);//Software serial communication initialization (speed 9600 baud)
}
void loop() {
  // checking if there is data from the rfid reader and if there is, then we read them
if(RFID.available()>0){
  //using the while loop, we allow data readings as long as there is data from the rfid reader
 while(RFID.available()>0){
  int i=RFID.read(); //the read bit i saved to variable and 
  Serial.print(i,DEC); //we display the variable on the Serial monitor in the form of a decimal number
  Serial.print(",");// adding the space between each number
}
  Serial.println();//when we read the data for one card, we continue to a new row and wait for new data from the rfid reader
}
}

The second example is a controlled access to a room that uses the RFID technology. If we want to add a new card that would have access to the room, in the code we need to insert the unique card code that can be read with the first example of the program. When we insert the code, to the verification, we only need to add the ability to, while comparing the allowed cards, check the new card in the function and that is it. Here, we can have as many cards as we want, we just have to make changes in the program in these two places, as it is described.

#include <SoftwareSerial.h&gt//including the library that serves to establish serial communication on other pins
SoftwareSerial RFID(2, 3); //(RX,TX) Our SoftwareSerial library constructor 
                 // using which, we set the serial communication to pins 2 and 3
//variable to which we save the code from the read card in order to be able to compare it to our saved cards
int novakartica[14]={0,0,0,0,0,0,0,0,0,0,0,0,0,0};
//variables to which we save the codes of the cards to which we want to allow access (change the code for your own cards)
int kartica1[14]={2,48,55,48,48,51,70,53,48,50,51,52,66,3};
int kartica2[14]={2,48,55,48,48,51,70,53,48,49,67,55,52,3};
// if we add another card, we must enter its code here
int ok=-1;//variable to which we save if the access is denied or allowed
int dozvoljeno=12;// the pin to which a green diode is connected, and which is activated when access is allowed
int odbijeno=13;// the pin to which a red diode is connected, and which is activated when access is denied
void setup(){
  Serial.begin(9600);//Serial communication initialization (speed 9600 baud)
  RFID.begin(9600);//Software serial communication initialization (speed 9600 baud)
  //setting the pins to which the led diodes are connected as output pins
  pinMode(allowed,OUTPUT);
  pinMode(denied,OUTPUT);
  }
 //the function in which we compare two codes off the cards that we turn to the function check (provjeri)
 //(checking the card that is read and another saved card)
 //if the code is the same, the function returns true, and if not, it returns false, and so we know if the card is read
 //one of those to whom access is allowed
 boolean usporedi(int a[14],int b[14]){
  int br=0;
  boolean vrati=false;
  //in the for loop we compare each number of both cards and if they are the same, we increase the counter number
    for(int i=0;i0){
    for(int i=0;i0){
    Serial.println("access allowed");
    digitalWrite(allowed,HIGH);
    delay(1000);
    digitalWrite(allowed,LOW);
    ok=-1;
  }
  //if ok is equal to zero, then access is denied and we turn on, and after one second, turn off the red led diode
  else if(ok==0){
    Serial.println("Access denied");
    digitalWrite(denied,HIGH);
    delay(1000);
    digitalWrite(denied,LOW);
    ok=-1;
    }
  }
void loop(){
  // in the loop, we constantly call the function ocitaj (read) which then calls the rest of the necessary functions 
  ocitaj(); 
  }