Thank you for your help thus far. I have changed my code to no longer read the RFID tag into a string; however, i still cannot 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);
Serial.begin(9600);
delay(400);
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 (sizeof(RFID_tag) > 0){
// 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);
// if the file is available, write to it:
if (dataFile) {
dataFile.println(RFID_tag);
dataFile.close();
}
// 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);
}
}//loop() end