Project regarding EZ-link Card Reader

Hi all, i'm not really good with programming, i'm trying to make a project where i have a card reader and a atmega2560, whenever i tap my EZ-link card on the reader, it will pop something out in the serial monitor. However i'm not sure where did i went wrong.

This is the code i got it from online (Github)

Whenever i tapped my ez-link card onto the reader, nothing shows up on my serial monitor, is the EZ-link not compatible? or am i doing something wrong?

I've also connected the atmega 2560 to the RDM 8800 :

TX to TX
RX to RX
5V to 5V
GND to GND

if possible i'd love some help from a fellow Singaporean!

/******************** RDM8800 *************************
This vesion source code of RDM8800 firmware reads Singapore's EZLink cards.
They use 13.56MHZ RFID Tag type ISO 14443 Type B[1] / CEPAS protocol.

From the original source code written by Stan Lee(Lizq@iteadstudio.com).

When a card is detected it returns as a comma seperated list of text fields.
They are the card number, balance, number of days since 1995-01-01 to expire
and number of days since 1995-01-01 created.

So for example:

Presenting a card will return:

1000130019390060,8.38,9107,6915

Which can be broken up into the following comma seperated fields:

Number: 1000130019390060
Balance: 8.38
Expire days: 9107
Created days: 6915

By Bill - bill@anantya.com 19/Jun/2014
************************************************************/

#include <PN532Lib.h>
#include <SPI.h>

uint8_t cardDataIn[128];

uint8_t cardDataOut[] = {
0x01, // target number (always 1)
0x90, // command class
0x32, // INS - read purse
0x03, // purse #3
0x00, // param 1
0x00, // param 2
0x00, // LC
0x00 // ??
};

const int LED = 3;

#define PN532_CS 10

PN532Lib nfc(PN532_CS);

void setup(void) {
// setup serial at 9600 baud
Serial.begin(9600);

// startup the nfc card reader
nfc.begin();
nfc.SAMConfig();

pinMode(LED,OUTPUT);
digitalWrite(LED,LOW);
}

void loop(void) {

// look for EzLink cards
uint32_t id = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443B, PN532_CARDTYPEB);

// if random tag id number then we have a card
if (id != 0) {
// now request the card data
if ( nfc.dataExchange(cardDataOut, sizeof(cardDataOut), cardDataIn, sizeof(cardDataIn)) ) {
// if card data found set the LED to on
digitalWrite(LED,HIGH);

// send out the card number
uint8_t i;
for ( i = 0; i < 8; i ++ ) {
Serial.print((cardDataIn[8 + i] >> 4) & 0x0F, HEX);
Serial.print(cardDataIn[8 + i] & 0x0F, HEX);
}

// send out the balance
double balance = (cardDataIn[2] << 16 ) | (cardDataIn[3] << 8 ) | (cardDataIn[4] );
Serial.print(",");
Serial.print(balance / 100);

// send out the expired day count from 1995
uint32_t expireDays = (cardDataIn[24] << 8 ) | (cardDataIn[25]);
Serial.print(",");
Serial.print(expireDays);

// send out the created days
uint32_t createDays = (cardDataIn[26] << 8 ) | (cardDataIn[27]);
Serial.print(",");
Serial.print(createDays);

// send the end or record cr/lf
Serial.println("");

// wait a bit for the LED
delay(20);

// off LED
digitalWrite(LED,LOW);
}
}
// loop delay before the next read attempt
delay(100);
}

Usually, you connect the Arduino's RX to the device's TX, and the Arduino's TX to the device's RX.

And when you post code, you're supposed to place it between [code]code tags[/code].
It makes us all much happier. :slight_smile:
(Perhaps you could edit and fix that?)

Furthermore, just glancing at the code, it appears to use SPI for communications with the card reader, and serial for printing to the serial monitor.

Do you have the card reader attached to the same serial port that the IDE/serial monitor uses?
Anyway, if your card reader has a serial interface, that code won't work with it, unless I'm mistaken.
(Or if it also has an SPI interface, you need to use that instead of the serial interface.)
Do you have a link to your exact card reader and/or it's datasheet.

ftp://imall.iteadstudio.com/Modules/IM131218001/DS_IM131218001.pdf

there you go for the datasheet for the RDM8800 NFC module. Sorry i'll try and change my code!

opp289:
ftp://imall.iteadstudio.com/Modules/IM131218001/DS_IM131218001.pdf
there you go for the datasheet for the RDM8800 NFC module. Sorry i'll try and change my code!

So I see that it does only have a serial (UART) interface, and no I2C. The library and code that you're using isn't suitable.

You need to find a compatible library that uses a serial interface instead of I2C. Then if you also want to print to the serial monitor, you'll need to connect the card reader to another serial port, (Serial1, Serial2 or Serial3), TX to RX, RX to TX, and leave the main hardware serial port, (Serial), for communication with the serial monitor.

I see you still didn't edit your opening post and place the code between code tags. If you can't be bothered doing that, don't expect people to put much effort into helping you.

this reply is very late, but i'm thinking that for nfc hooking up to a pc, it is probably easier to make do with a usb to uart serial dongle (e.g. Adafruit CP2104 Friend - USB to Serial Converter : ID 3309 : $5.95 : Adafruit Industries, Unique & fun DIY electronics and kits) and a pn532 module (e.g. the mentioned module RDM8800)

in that sense an an arduino is probably not necessary, libnfc on the pc would directly interface pn532 over usb-serial if i'm right about it and most of the interaction with the pn532 nfc reader can then be done from the pc

http://nfc-tools.org/index.php?title=Main_Page

another way to do that would be to program arduino to do usb-serial interfacing