Storing data of ZigBee API frame to local Sd-card on Arduino

Hello all…

I am exploring ZigBee communication in API mode with arduino. I have some issues which I can’t understand so far, so I hope here I will get some help from the forum.

I am using two ZigBee S2C radios, both configured with API-1 mode. So far I am able to send a share a simple message between these two nodes.

Code of the transmitter node is,

#include <XBee.h>
#include <SoftwareSerial.h>
  SoftwareSerial softwareSerial (Rx, Tx);
  XBee xbee = XBee();


void setup() {
  Serial.begin(9600);
  softwareSerial.begin(9600);
  xbee.setSerial(softwareSerial);
}

void loop() {
  uint8_t data[] = {'H','I'};
  XBeeAddress64 addr64 = XBeeAddress64();
  addr64.setMsb(0x00000000); //XXXXX -> Msb address of router/end node
  addr64.setLsb(0x0000ffff); //XXXXX -> Lsb address of router/end node 
  ZBTxRequest zbTx = ZBTxRequest(addr64, data, sizeof(data));
  xbee.send(zbTx);
  delay(1000);
}

Now as this data as “HI” is correctly transmitting, now I want to store it locally to an SD-card connected to arduino. But I don’t know how can I get that data from that array and store it simply on SD-card.

e.g

myFile = SD.open("test.txt", FILE_WRITE);
       if (myFile) {
        myFile.print(????);       // Here I want to print that data using <SPI.h> and <SD.h>

Further details can be shared if needed, Please help regrding this.