Interface MiFare Reader/Writer with Arduino

Introduction

MiFare is a contactless smart card system which is being trademark by NXP Semiconductors. With MiFare reader/writer, useful information can be either read from or written into MiFare cards which will then be used in applications like electronic wallet, access control, corporate ID cards, transportation and so on. In conjuction with that, Cytron Technologies is carrying the MiFare ISO14443A Classic 1K or 4K card reader/writer CR038A which is communicable using computer or microcontroller. In this tutorial, users will learn on how to interface MiFare reader/writer with Arduino using Cytron product, BBFUINO board which is Arduino compatible.

Hardware Required:

Electronics Components:

  • MiFare Reader/Writer CR038 (RFID-ICRW-CR038) – 1
  • MiFare Card (RFID-TAG-MYF-CA) – 1
  • Breadboard Friendly (Arduino Compatible) (BBFUINO) – 1
  • USB to UART Converter (UC00A) – 1
  • USB MiniB Cable (2.0) (WR-USB-M) – 1
  • Breadboard GL-12 (C&D) (BD-BB-0617) – 1
  • LCD (8×2) (DS-LCD-082A) – 1
  • Straight Pin Header (Male) 2×40 Ways (CN-PH-M240S) – 1
  • Straight Female Header 2×10 Ways (CN-PH-F210S) – 1
  • 6x6x1 Push Button 4Pin (SW-PBM-4N-060601) – 2
  • Multilayer Capacitor 0.1uF (CP-MC-0.1UF) – 1
  • Male to Male Jumper Wire (WR-JW-MM65) – 1 pack

            

   RFID-ICRW-CR038        RFID-TAG-MYF-CA                BBFUINO

        

          UC00A                          WR-USB-M                   BD-BB-0617

        

          DS-LCD-082A            CN-PH-M240S                CN-PH-F210S

        

SW-PBM-4N-060601          CP-MC-0.1UF                   WR-JW-MM65

Tools and Equipment:

  • Cutter
  • Screw Driver
  • Soldering Iron
  • Solder Lead
  • Solder Paste (optional)

Software Required:

Related Materials:

*Users are encouraged to read through the related user manuals for better understanding on how the products stated above work in place.

Procedure:

  1. Referring to “Hardware Installation” section in the user manual of BBFUINO, install the 2×8 LCD onto the BBFUINO board.


    Figure 1: 2×8 LCD on BBFUINO board

  2. Plug the BBFUINO board into breadboard as shown in Figure 2 below.


    Figure 2 BBFUINO on breadboard

  3. Next, solder the 1×7 header pin (male) which is provided to the flex cable breakout board of the MiFare reader/writer CR038 (RFID-ICRW-CR038) as shown in Figure 3 below.


    Figure 3: Solder header pins to flex cable breakout board of MiFare reader/writer

  4. Plug the soldered flex cable breakout board of MiFare reader/writer into breadboard as shown in Figure 4 below.

    *Flex cable breakout board extend out the connections of MiFare reader/writer CR038.


    Figure 4: Flex cable breakout board on breadboard

  5. Based on the schematic shown in Figure 5 below, construct the interfacing circuit of MiFare reader/writer with BBFUINO on breadboard using male-to-male jumpers.


    Figure 5: Schematic of the interfacing circuit of MiFare reader/writer with

    BBFUINO

    *Two buttons are added to provide inputs to BBFUINO board for program execution and mode selecting in Arduino program for interfacing MiFare reader/writer.

    *0.1uF capacitor is connected across each button to reduce bouncing effect of the button.

    *TX pin of MiFare reader/writer is connected to RXD of BBFUINO while RX pin of MiFare reader/writer is connected to TXD of BBFUINO.

  6. The completed interfacing circuit is similar to appearance as shown in Figure 6 below.


Figure 6: The completed interfacing circuit of MiFare reader/writer with BBFUINO

7.The interfacing circuit is considered done here. Now, it’s time to program BBFUINO for interfacing with the MiFare reader/writer CR038.

8.Firstly, download the driver of UART to USB Converter (UC00A) and install it according to the installation guides.

9.After the USB driver is successfully installed, with the UC00A still connected to the computer through USB miniB cable, the COM port assigned to UC00A can be checked through the Device Manager under the Ports (COM & LPT) category. In this case, the COM port is COM 6.

Figure 7: COM port assigned for UC00A

10.Next, download the MiFare_Arduino_Interfacing zipfile which contains the Arduino source code for MiFare reader/writer CR038 interfacing.

11.Unzip the file downloaded into a folder. In the resulted folder, there is a file called MiFare_Arduino_Interfacing.ino.

12.Open the MiFare_Arduino_Interfacing.ino file in Arduino IDE. By referring to the “Getting Started” section in the user manual of BBFUINO, upload the program into the BBFUINO board through Arduino IDE using UC00A programmer.

*Please detach the connections formed by male-to-male jumpers between TXD & RXD of BBFUINO and TX & RX of MiFare reader/writer CR038 at the time before uploading program into BBFUINO board. Attach the jumpers back when the uploading process of program is finished.

*This step is to prevent unnecessary write operation to MiFare reader/writer during the program uploading process since the TXD and RXD of BBFUINO board is shared with both MiFare reader/writer and UC00A.

*The completed interfacing circuit can be either powered up by the UC00A or connect BBFUINO board with a 12V AC to DC adapter through the DC jack socket on it, but not both at the same time.

13.There is total of 6 modes integrated in the Arduino program of interfacing MiFare reader/writer CR038 with BBFUINO, which are:

  • Mode 0: Blinking of the MiFare reader/writer onboard LED
  • Mode 1: Getting device number of the MiFare reader/writer
  • Mode 2: Getting NUID of a MiFare card
  • Mode 3: Read data stored in Block 0 (in Sector 0) in memory of a MiFare card
  • Mode 4: Write data into Block 4 (in Sector 1) in memory of a MiFare cards
  • Mode 5: Read data stored in Block 4 (in Sector 1) in memory of a MiFare card

    *MiFare card is need to be put close to or simply on the top of the MiFare reader/writer CR038, before executing the Mode 2, 3, 4 and 5.

    *Regarding the interfacing circuit, Button 1 is used to select which mode is going to be executed while Button 2 is used to execute the mode selected.

    *The BBFUINO board need to be reset each time the user select different modes for execution.

    *Please refer to comments in Arduino program of interfacing MiFare reader/writer CR038 with BBFUINO for more information.

14.The video below demonstrates the interfacing of MiFare reader/writer CR038 with the BBFUINO board. Please enjoy it.


The tutorial is ends here. Have fun with this Arduino project. See you next time!

Attachments:


, , , ,

Related Post

Getting Started with Mifare RC522 RFID Kit (RFID-RC522)

Getting Started with Colour Sensor Module (SN-COLOUR-MOD)

Getting Started with Tilt Sensor (SN-TILT)

Getting Started with Vibration Sensor Module (Normally Off) (SN-VIBRATE-MOD)

2 thoughts on “Interface MiFare Reader/Writer with Arduino

  1. any example on PIC? i download sample code for CR038 using SK40C got problem on read block 0 and write block 4.

Leave a Reply

Your email address will not be published. Required fields are marked *