I have been working on combining the Skyetek M1 Mini RFiD module and an Arduino Mini Pro.
To begin with, I have had the components on breadboard and been using an Arduino Diecimila while developing the code. After some trial and error I had a working set up Grin
I then decided it was time to upload the code to the Arduino Mini Pro and check it all worked. Problem is, it doesnt!! The program initialises and returns a Serial.print command showing that it has started. However it does not appear to be talking to the M1 mini, and it defintaly isnt printing the RFiD data to the serial port.
The code I have written is as follows:
// File......RFiD Read - Code for IE5 to talk to Software interface
// Version 1.0
// Author Ian Culverhouse
// Date 13th July 2009
// Purpose - To implement the SkyeTek M1 RFiD Module with the Arduino to read 13.56mhz RFiD IC
// Revision History -
// Imports --------------------------------------------------------------
#include <SoftwareSerial.h> // Initialise Software Serial
// I/O Definitions ------------------------------------------------------
#define txPin 5 // Software serial tx pin
#define rxPin 4 // Software serial rx pin
#define ledPin 13 // LED pin
#define successRead 9 // Indicate successfull read.
// Initialise the Software serial port ----------------------------------
SoftwareSerial mySerial(rxPin, txPin);
#define d_size 64 // create some space for receiving data from tag reader
byte readerData[ d_size]; // Sets up Array for the tag ID to be held in
// Setup the Pins & Ports -----------------------------------------------
void setup() {
// define pin modes for tx, rx, led pins:
pinMode(rxPin, INPUT); // pin mode for the software serial rx pin
pinMode(txPin, OUTPUT); // pin mode for software serial tx pin
pinMode(ledPin, OUTPUT); // pin mode for the ledpin
pinMode(successRead, OUTPUT); // pin mode for successfull read
mySerial.begin(9600); // set the data rate for the serial ports
Serial.begin(9600); // sets data rate for the hardware serial port
Serial.println("Initialised Serial"); //prints the word begin to the hardware serial port as a trace that the system is working
digitalWrite(ledPin, HIGH); // Sets the ledpin to high, indicating the system is active
}
// Program code ----------------------------------------------------------
void loop(){
// first step is to query the reader for a tag. Send a 001400 command to it. If no tag is found then it will lopp back
// and try again. When a tag is found the code will store the entire response from the reader.
int in_count; // defines variable in_count
mySerial.print( 0x0d, BYTE); //send CR
mySerial.print("001400"); // Send read command to M1 mini
mySerial.print( 0x0d, BYTE); //send CR
delay(50);
byte ch = mySerial.read(); // get first byte of answer from reader
// if it was not a LF (0x0a), send read command again if it was,
// store all bytes until ending LF was received
if (ch == 0x0a) // if first byte received is a line feed enter if statement
{
ch = mySerial.read(); // read the first byte into the variable ch
in_count = 0; // set in_count to 0 - used as a counter for the array
while( (ch != 0x0a) && ( in_count < d_size))// while the byte being received is not a line feed and the eeprom is not full enter while loop
{
readerData[in_count] = ch; // the array dta is filled with the value of ch
in_count++; // in_count is increased by 1
ch = mySerial.read(); // the next character from the serial port is read in and ch is assigned the value
}
}
if (readerData[0] != '9') { // check to see if first byte of data is a 9. If it is then
// error code 94 has been sent from reader, indicating that there is no
// in range of reader, go back and try again.
for ( int i = 0; i < in_count; i++) Serial.print( readerData*, BYTE);*
-
digitalWrite(successRead, HIGH); // Sets the successread LED to high*
-
delay(25);*
-
Serial.println();*
-
digitalWrite(successRead, LOW); // Sets the successread LED to high *
}
}
Can anyone offer any suggestions or advice? Have you experienced similar problems when working between arduino hardware?