How to send array via Xbee

Hey,

is it possible to send a array from a arduino uno with sparkfun Xbee shield and rfid reader to a sparkfun explorer witch is plugged into my usb port on my MacBook?

I want to read a Serialnumber from a RFID Card with my RFID Reader on my Arduino Uno and send it with my XBee shield over the air to the Xbee explorer on my MacBook to check the Serialnumber on my Server in a Database and send a ACK or Deny back to the Arduino witch will open or look a door.

Thanks and reguards

Berlin86

is it possible to send a array from a arduino uno with sparkfun Xbee shield

Yes, it is. The key is to forget about the XBees, shields, and explorer devices, and just pretend that there are wires instead.

Use the Serial.print(), Serial.write(), and/or Serial.println() functions just like there was a wire in place.

Ah cool thanks for the quick answer!

I have XBee Version S1, I heard that they are only unidirectional, but I need bidirectional for the anser of the server, do I have to buy version S2 ?

Thanks

If, by S1, you mean Series 1, they are bi-directional.

All right great, but how do I send from my MacBook a replay over the Arduino explorer back to my Arduino Uno?

Thanks

All right great, but how do I send from my MacBook a replay over the Arduino explorer back to my Arduino Uno?

What application on the MacBook is receiving the serial data that the Arduino sends? Whatever application that is is using some class to read from the serial port. That class almost certainly has a method to write to the serial port, too. Use the method, Luke!.

I was able to send data from my Arduino Uno over Xbee to the explorer Xbee but the data looks different compared to a wired connection with USB, do you know why?

/*
RFID SOFT UART READ AND SEND VIA XBEE
created by Sascha Franke
25.02.2011 Berlin

*/

// include the SoftwareSerial library so you can use its functions:
#include <SoftwareSerial.h>

#define rxPin 3
#define txPin 6
//#define ledPin 12

// set up a new serial port
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);
//byte pinState = 0;
int i = 0; 
byte rfid[] = {0,0,0,0,0};

void setup()  {
  // define pin modes for tx, rx, led pins:      
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
 // pinMode(ledPin, OUTPUT); 
 
  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  Serial.begin(9600);
  digitalWrite(txPin, HIGH);
}

void loop() 

{
  
  // listen for new serial coming in:
   rfid[i] = mySerial.read();
   
  i++;
  if (i==5)
  {
    for(int ii=0;ii<5;++ii)
      {
        Serial.println(rfid[ii], DEC);
      //mySerial.println(rfid[ii], DEC);
      }
    
    while (Serial.available())
      {
        Serial.flush();
      }
      
    i=0;
    
  }
}

I am reading at the moment with Aduino and ZTerm the Data, but in the end the data goes into a SQL Library witch checks the data and respons back Y or N for the doorlook.

Hope it works

Thanks for helping me out

I was able to send data from my Arduino Uno over Xbee to the explorer Xbee but the data looks different compared to a wired connection with USB, do you know why?

How is the data different?

SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);

SoftwareSerial is obsolete. You should be using NewSoftSerial instead.

   rfid[i] = mySerial.read();
   
  i++;

Now this is a really bad idea. SoftwareSerial::read() will, like all serial read functions, return -1 if there is nothing to read. You are not checking for valid data before storing it in the array.

    while (Serial.available())
      {
        Serial.flush();
      }

If the other end of the connection sends a response, just route it to the bit bucket. Makes it hard to be enthusiastic about posting replies to your threads...