i was purchase RFID Module from http://www.stronglink.cn/english/sl015m1.htm
but them has only AVR Example code I don't understand it about AVR programing
am tried to create arduino code but not work any body please help me convert avr code to arduino
or arduino code to read Tag id for this Module
:) :) :)
this is arduino code ( not work )
#include <NewSoftSerial.h>
/*
This program tests communication with the Seeeduino 13.56 RFID Reader by sending a request for the unit's serial number and getting a response.
We need 4 pins connected from the RFID to the Arduino : These all come from connector J2
RFID -> ARDUINO
TX -> TX (pin 4)
RX -> RX (pin 3)
+5V -> +5V
GND -> GND
NOTES :
1.Debug info and received data will be sent through the Arduino to your serial monitor. You should have it open to see anything!
You should see something like this :
The RFID test program has started
Header = AA
Station ID = 00
Data Length = 1
Command = 83
Checksum = 82
Footer = BB
Listening for response...
I received: AA
I received: 0
I received: A
I received: 0
I received: 0
I received: FF
I received: FF
I received: FF
I received: FF
I received: FF
I received: FF
I received: FF
I received: FF
I received: A
I received: BB
NOTES (Continued)
2.The reset pin on the RFID should be tied to GND, either on the RFID or the Arduino
3.Please note that this test program outputs debug data with no trailing zero : so for example '00' becomes '0' and '0A' becomes 'A'
4.If you're not seeing any response from the RFID unit, chances are that you have your RX and TX pins round the wrong way.
5.This code uses the 'NewSoftSerial' library to set up another serial port on pins 3+4 of your Arduino. You must download the library and 'include' it in your code (using Sketch:Import Library from the Menu bar). Library can be found at : arduiniana.org/libraries/newsoftserial/
6.The code used to send the data section of the packet has not been properly tested.
/
/
RFID -> ARDUINO
TX -> TX (pin 4)
RX -> RX (pin 3)
+5V -> +5V
GND -> GND */
#define rxPin 3
#define txPin 4
int KeyPin = 2;
NewSoftSerial rfid(txPin,rxPin);
byte DATA[255] = {};
void send_command(int CMD, byte DATA[])
{
int i; //an index for the data send loop
int checksum;
int DATALENGTH;
byte STX=0xBA;
/byte CMD=0x31;/
byte STATIONID = 0x02;
Serial.print("Header = ");
Serial.print(STX,HEX); //STX command begin code
Serial.println();
rfid.print(STX,HEX);
Serial.print("Station ID = ");
Serial.print("02"); //RFID reader address use zero for all readers to respond)
Serial.println();
rfid.print(STATIONID,HEX);
DATALENGTH = sizeof(DATA)/2;
Serial.print("Data Length = ");
Serial.print(DATALENGTH,HEX); //send the length of the data section
Serial.println();
rfid.print(DATALENGTH,HEX);
Serial.print("Command = ");
/* Serial.print(CMD,HEX); //send the command word
Serial.println();
rfid.print(CMD,BYTE);*/
Serial.print(CMD,HEX); //send the command word
Serial.println();
rfid.print(CMD,HEX);
checksum = (STATIONID ^ DATALENGTH ^ CMD);
i=0;
while (DATA*)*
- {*
- Serial.print("Data Word ");*
- Serial.print(i);*
- Serial.print(" = ");*
_ Serial.print(DATA*,HEX); //send each byte of the data*_
* Serial.println();*
_ rfid.print(DATA*,HEX);
checksum = checksum ^ DATA;
i++;*_
* }*
* Serial.print("Checksum = ");*
* Serial.print(checksum,HEX); //*
* Serial.println();*
* rfid.print(checksum,HEX);*
* Serial.print("Footer = ");*
* Serial.print(0xBD,HEX); //ETX command end code*
* Serial.println();*
* rfid.print(0xBD,HEX);*
* Serial.println();*
}
void read_response()
{
* byte incomingByte;*
* Serial.println("Listening for response...");*
* rfid.println(incomingByte, BYTE);*
while (rfid.available() > 0)
* {*
* // read the incoming byte:*
* incomingByte = rfid.read();*
* // say what you got:*
* Serial.print("I received: ");*
* Serial.println(incomingByte, HEX);*
* }*
}
void setup()
{
* //start serial port at 9600 bps: This is for the debug info we send to your PC/Mac*
* Serial.begin(9600);*
* //start a NewSoftSerial serial port at 9600bps : This is to talk to the RFID.*
* rfid.begin(9600);*
* Serial.println("The RFID test program has started");*
}
void loop()
{
* send_command(0x31, DATA); //This command is requests the serial number of the RFID unit*
* read_response(); //This just displays the raw data recieved*
* while(1) {} //loop forever*
}
Datasheet_RFID_I-Code.pdf (159 KB)
AVR-SL015M3.c (8.44 KB)