Recently I’ve been working on a RFID identification solution for a new project at University of Aveiro.
Our first approach will be through Arduino and the Son Micro SM130 RFID module. At first, the Arduino seemed quite simple and effective for the final goal, but soon the problems came up.
We will have to communicate basically with two different modules:
- The RFID reader (ships with UART communication, but can be upgraded to an I2C firmware version)
- The Door module (responsible to communicate with a database and opening the door – UART only communication)
The first problem we came across is that Arduino only has one Hardware UART available, which is also connected to the USB interface (used to upload programs to the board). If we need to upload a new program to the ATMega, we have to physically disconnect the SM130 from the UART pins. Not only this is a non-elegant solution but also, if we need to print something to the Serial console, the same will be sent to the RFID module. For the Door communication we would use the SoftwareSerial library, as a second UART.
SoftwareSerial supports multiple software UARTs but only one of them can be “listening” at a time, which means we lose everything that is sent to us while we are not listening.
Our solution will be to upgrade the SM130 to the I2C version, leaving the HW UART free for debugging purposes and the Door module handling for the SoftwareSerial. This scheme improves the overall performance of our final prototype, because incoming messages will always be placed in the corresponding buffer, ready to be read as soon as we can.
In this post I will also provide you some useful information that I found throughout the preliminary search. All links were working at 17/march/2012, but if you find a broken link, feel free to contact me. Also, the information I provide is merely to instructional purposes, use it at your own risk.
The I2C Firmware
The I2C firmware version is not freely available in SonMicro’s website, but if you are interested in the official release of the I2C firmware, you should send an e-mail to email@example.com to request it.
The upgrade is easy and is done using the Firmware Upgrade tool available at SM130′s Support Webpage.
I found some links supposedly with the i2c firmware (use at your own risk, I recommend that you request it from SonMicro):
- I2C firmware: http://www.joostaanen.com/RFID/SM130/Firmware/i2c_28_b1.rme
- UART firmware: http://www.joostaanen.com/RFID/SM130/Firmware/um13d1.rme
- UART firmware that supports anti-collision (for multiple tag reading): http://www.joostaanen.com/RFID/SM130/Firmware/um13g.rme
Connect the SM130 module to USB through a FTDI cable or an Arduino without the ATMega in the socket. You only need to connect 5 pins on SM130: +5V/Vcc (pins 1 and 28), GND (14), RX (11) and TX (12). If you are using a chipless Arduino, see this link for more information.
Run the Firmware Upgrade tool, select the right COM port and the right firmware file you want to upload and then click “Auto Upgrade” button.
It is usual that the I2C slave address is not correctly set (it tends to be 0×30 after the FW upgrade). To check/change it, you must use the SMRFID Mifare Tool from SonMicro (available at the module’s support page). Unzip and execute the tool.
- Set the baud rate in the left top corner to 19200
- Make sure you have the right COM port selected
- Click “hardware commands” in the menu
- Click ‘read I2C adress’
If this returns 42 (or 0×42) it has the default address. To change it to 0×42 you click “Set I2C adress” in “hardware commands” menu and input 42 (input is done in HEX).
Testing the module
To test the module you can read the I2C Appplication Note from SonMicro and write your own program. However, to save time, there is already a library that you can use to print the card TAG in the serial monitor, called RFIDuino, available here. Install the library and use the “seek” example. Hopefully you will see your TAG on the screen.