HUM: RDM6300

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>//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.