With this code, i am successfully able to write the RFID tag to the SD card:
//#include <XBee.h>
#include <SD.h>
#include <SPI.h>
//XBee xbee;
File dataFile;
char RFID_tag[17];
void setup() {
//initiate xbee and wait
//xbee.begin(9600);
//delay(6000);
// RFID tag reader
Serial1.begin(9600);
delay(400);
RFID_tag[0] = ' ';
pinMode(10, OUTPUT);
// see if the card is present and can be initialized:
if (!SD.begin(4)) {
// don't do anything more:
return;
}
}
void loop() {
// get RFID tag string
Serial1.readBytesUntil('\r',RFID_tag,17);
// if there is a string write to SD and send
if (RFID_tag[0] != ' '){
// form packet to transmit (DL - destination address (HEX), payload, size of payload)
//Tx16Request tx16 = Tx16Request(0x0100, (uint8_t*)RFID_tag, sizeof(RFID_tag));
// transmit packet
//xbee.send(tx16);
//delay(300);
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
dataFile = SD.open("data.txt", FILE_WRITE);
delay(500);
// if the file is available, write to it:
if (dataFile) {
dataFile.println(RFID_tag);
dataFile.print('\n');
delay(300);
dataFile.close();
delay(300);
}
for (int i = 0; i < sizeof(RFID_tag); i++){
RFID_tag[i] = ' ';
}
}
}//loop() end
Note, the xbee is not connected and all the xbee stuff is commented out. So my thought is to next incorporate the xbee stuff back in with the xbee disconnected. Writing to SD was fine, also I did that I have no issues transmitting the correct array from xbee to xbee. When the xbee is connected, the write to SD card ability is lost.