Blog - Sketching with Hardware

RFID

Published on: | Author: Lisa Andres | Categories: 2018b, Tutorials

For our project „Feline Cuisine“ we had the idea to create a cat feeding machine which gives personalized food to each cat. To realize that, we used RFID tags, which can be attached to a cats collar.

 

What is RFID?

RFID (“radio-frequency identification”) is a technology to identify and track RFID tags. The tags contain an identification code which can read by an RFID reader using radio waves. The tags can be attached to objects or be implanted under the skin and need to touch the reader or be nearby it, so the RFID reader can identify the RFID tag. The RFID tag is a transponder which can transfer data and gets charged with power with the RFID reader. Tags that contain an own battery can reach a higher distance to be tracked.

RFID technology is common used in the industry to locate, scan and identify products but it is used as well to track animals and identify them.

The tags can be read but some can also be written, do add specific data to each RFID tag. The tags contain an integrated circuit that stores and processes information and that modulates and demodulates radio-frequency signals. Aswell they contain means of collecting power from the reader signal and an antenna for receiving and transmitting the signal.

Depending on the frequency of the tags, the signal can reach different range and speed. For example a typical RFID tag for animals uses 120–150 kHz and can reach up to 10 cm. Smart cards used in electronic ticketing or contactless payment use 13.56 MHz and can reach upto 1 meter distance for the signal.

 

RFID and Arduino


To use RFID technology with Arduino, you need different RFID tags and an RFID reader for Arduino.

The RFID reader has to be attached to the Arduino like on the picture shown. Do not already connect it to the computer.

 

 

First we attached the RFID reader to the Arduino MEGA, hoping to work as fine as with Arduino UNO, but it turned out that it was not and the tags were not read. So we switched the Arduino MEGA with the Arduino Leonardo, which worked.

At the beginning we made use of the LED shown in the picture above, because it was helpful to control on the light, if the tags were read or not. You can also remove the LED, because it is not necessary for the functionality.

 

Once the reader is connected with the Arduino, the next step is to download the needed library in Arduino IDE.

Unfortunately the device came with an instruction how to set it up, but no library or test file, which were needed in the instruction. Fortunately we could find it on the website of the manufacturer.

(https://www.velleman.eu/support/downloads/?code=VMA405)

To add the library to Arduino IDE, you have to go in Arduino IDE to

Sketch > Include library > Add .zip Library

and select the library file where you previously stored it.

(If the Arduino® IDE gives you a message that the RFID already exists, try to delete the RFID folder in your Arduino/libraries folder and load it again.)

The library is included to your sketch with

#include <RFID.h>

 

Load the test file, with which it is possible to read the tags and find out its serial number.

Now the Arduino can be plugged into the computer and be tested with the test sketch (vma405__mfrc522__test.ino).

Start the serial monitor in Arduino IDE (Ctrl + Shift + M) and hold one of the RFID tags in front of the reader. On the serial monitor will appear the message “Not Allowed” and the code of the tag. You will have to add the code of every RFID tag to the program.

 

It is added in the test file to

int cards[][5] = {{int,int,int,int,int}};

After adding the RFID code, the tag will be recognized.

To program events depending on the recognized RFID tag, every tag has to be identified with its code separately in the program.

 

Advice

For our project we wanted to hide the Arduino in a box but the RFID reader was placed outside the box. Therefore we used a 1 meter cable to connect the Arduino and the reader. As soon as we used the long cable, the RFID tags were read slower and even sometimes wrong, that the message “Not Allowed” showed up, which means an unknown RFID tag was recognized.

A long cable can cause the reader to deliver the information slower. To speed this up, we tried to wrap aluminium foil around the cable. This could help for a better connection between the RFID reader and the Arduino.

Unfortunately this did not solve our problem, but made it even worse. After wrapping the foil around it, there was no reaction of the reader at all.

After finding out that the problem was one cable that broke and a second time 2 cable that touched each other, the reader worked fine with the 1 meter cable.

Conclusion:

  • Make sure your wires are well connected
  • Longer cables can make the reading process slower
  • To wrap aluminium foil around the cable can optimize the connection but does not have to

 

Technical data

The picture below shows the connected pins from Arduino to the RFID reader.

 

The reader has to be attached to 3.3V pin, 5V would cause damage on the device.

 

 

To see the RFID technology used in our project “Feline Cuisine” click here.

 

Or see the RFID technology in action

linked categories 2018b, Tutorials

|

Write a comment

Comment

[…] If you want to know more about RFID technology and how to use it with an Arduino read Lisa’s Blogpost. […]