SM130 RFID with Arduino MEGA

Radio-frequency identification (RFID) is the wireless non-contact use of radio-frequency electromagnetic fields to transfer data, for the purposes of automatically identifying and tracking tags attached to objects. The tags contain electronically stored information. Some tags are powered by and read at short ranges (a few meters) via magnetic fields (electromagnetic induction). Others use a local power source such as a battery, or else have no battery but collect energy from the interrogating EM field, and then act as a passive transponder to emit microwaves or UHF radio waves (i.e., electromagnetic radiation at high frequencies). Battery powered tags may operate at hundreds of meters. Unlike a bar code, the tag does not necessarily need to be within line of sight of the reader, and may be embedded in the tracked object.

RFID tags are used in many industries. An RFID tag attached to an automobile during production can be used to track its progress through the assembly line. Pharmaceuticals can be tracked through warehouses.

Since RFID tags can be attached to clothing, possessions, or even implanted within people, the possibility of reading personally-linked information without consent has raised privacy concerns.” – from wikipedia (http://en.wikipedia.org/wiki/Radio-frequency_identification)

We will use now the SM130 module with Arduino MEGA to start experimenting with RFID world…

sm130_whole_sys

The SM130 is a compact module that includes all necessary components for 13.56 MHz RFID Mifare® Reader/Programmer except only the PCB antenna, is a low cost module solution for Mifare® applications and supports Mifare® Classic 1K (1KByte), Mifare® Classic 4K (4KByte) and Mifare® Ultralight (512 bit). The module itself performs all demodulation, decoding, encryption and decryption operations. It has 2 general purpose inputs and 2 general purpose outputs to expand I/O count of the system.

This module can be controlled via

It is mainly composed by

Unfortunately the antenna that allows communication with cards isn’t built-in so must me connected externally, it’s a simple step since the antenna has a pinout compatible to the SM130. There is an image that show how to do the few connections between SM130 and antenna (click to enlarge)

sm130_conn_part

  • RED wires are +5Vdc
  • BLACK wires are ground
  • GREEN wires are for UART communication

According to SM130 pinout just connect UART RX and UART TX to Serial3 on Arduino MEGA board.

sm130_module

I’ve written a library for Arduino to interface the SM130 module that works over UART bus and it can be download here: sm130_code.

This library take advantage from multiple UART modules on the Arduino MEGA board to allow the communication with the module while debugging over terminal in Arduino IDE, but with few modifications can be used also in conjunction with SoftwareSerial and then with every Arduino Board. In the library file above there is also an self-explaining example.

8 thoughts on “SM130 RFID with Arduino MEGA

  1. Hello, I am Javi, from Spain.

    I read in you blog the article: SM130 RFID with Arduino MEGA, it is wonderful.

    I try the code, but i have error on line:

    rfid.begin(&Serial3);

    serialShell.ino: In function ‘void setup()’:
    serialShell:12: error: ‘Serial3’ was not declared in this scope

    I use a arduino UNO with SM130 RFID, it ‘s posible make it in Arduino UNO using UART protocol ?

    Thanks.

    • Thank you for interest! Surely is possible, but in the Arduino UNO board only one hardware UART is available and this is the one used by debug interface. You can connect through this port or use a software serial port (the latter changing something in the code). If you don’t need to debug via serial, simply connect the rfid to the UNO board via Serial1 instead of Serial3 and use pin 1 and 2.

  2. Hello,

    Thanks a lot for this post. Have you ever tried to use multiple antennas ?
    If you have an idea (because I don’t) how would you do that ?

    Nicolas

    • Since I’m using a serial interface, I’m pretty sure that with a MEGA board (that has 3 serial interfaces) you can handle up to 3 different modules. Maybe few modifications are needed, but firtly try it because I’ve only one module. Let me know 🙂

  3. hello,
    I use the same material, except that my rfid reader is a 13.56MHz RFID Shield
    using the program, the program shows me an error;
      “sketch_mar18b: 22: error: ‘mySerial’ was Not Declared in this scope”

    # include

    NewSoftSerial mySerial (6, 7), (this is an error)

    • The code is intended to use with sm130 based module. However mySerial is an hardware serial port, not a SoftwareSerial

  4. Thanks A LOT for this code!
    I have a question. I can read tags, but i cant write. Can this have something to do with the firmware of the module? You even commented in SM130.h //! Get the module firmware
    int firmware();

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.