Need help interfacing this xbee shield question

Hi I brought this http://proto-pic.co.uk/products/XBS005-%252d-Shield-for-the-Arduino-%26-Amicus-development-boards.html Xbee shield as a substitute to the digi mainstream one, the only problem is its new to the market (so no example complete sketches and I'm a noob) :-X.

Basically the xbee modules are configured to talk to each other, I used two xbee explorers for this. So I don't need any config code. The board came with minimal documentation. Only really says " Turning on the Xbee requires digital pin 8 to be taken HIGH, you need to do this in your code, something like this will suffice (other systems should be equally simple ):

pinMode(8,OUTPUT);
digitalWrite(8, High0;

Their example script isn't complete and I'm stuck. Heres their code http://www.openkontrol.org/wiki/tiki-index.php?page=Arduino+Code. I'll paste it below.

// Arduino example code
void setup() // always called at the start to setup I/Os etc
{
Serial.begin(9600); // start the serial port at 9600 baud
}

void loop() // repeatedly called
{
static boolean waitingForStart = true; // true if waiting for start of message
static long time; // used to store time of first character - for timeout

if (waitingForStart) // we are waiting for the first character of a message
{
if (Serial.available()) // got some characters
{
waitingForStart=false; // in message, enable timeout
time=millis(); // set up timeout
}
}
else // timing out
{
if (Serial.available()==12) // have we got the message?
{
processCommand(); // yes - process the message
waitingForStart = true; // and wait for the next one
}
else if (millis()-time > 100) // 100 millisecs should be enough to receive the message
{
Serial.flush(); // timed out - flush any characters received
waitingForStart = true; // wait for the next message
}
}
}
void processCommand() // message received - process it
{
char message[12]; // buffer to store message in
for (int i=0; i<12; i++) message[i] = Serial.read(); // read the message into the buffer
if (strncmp(message,"aC01",4) == 0) // check first four characters of message
{ // it is for us
if (message[4] == 'E') // test 5th char
{
Serial.print("aR01EHERE---");// send 12 byte reply
}
}
}
uint8_t charToHex(char c)
{
if (c < 'A') return (c-'0');
return (c-'A'+10);
}
int char2hex(char* msg) // char * means a pointer to a char 
{
return(charToHex(msg[0])*16+ charToHex(msg[1]));
}

Can anyone help me complete this sketch?. I'm perplexed wishing I had brought a digi shield! :frowning:

I really don't think it's a shield issue. I think it's a mis-understanding of what the sketches should be doing.

You need to be running two different sketches - one on the sender and one on the receiver. Of course, if you are aiming for bi-directional communication, the roles will reverse at times. But, you still need two different sketches.

What kind of XBees do you have? You mention having them talk when they are both on XBee explorers. That's good. You should be able to move on of the XBees to the shield/Arduino, and write cod for it to read serial input, and echo it back out.

void loop()
{
   while(Serial.available() > 0)
   {
      Serial.write(Serial.read());
   }
}

Try this on one of the Arduinos, with the other on the XBee explorer. Naturally, you'll need a setup function, in which you set pin 8 as output and HIGH.

Let us know whether this works. If it does, we can help you with the real code for this Arduino and the code for the other Arduino. If not, we can try other things.

Hello thanks for the replh, I'm using digi Xbee series 2.5, One setup as a router the other setup as a co-ordinator/end end device. I downloaded the Xbee library from google code and got them talking gobble, so not that helpful. I've basically had one running hacked scripts on the arduino, the other attached to XCTU. I have had the baud rate setup on 9600 on both.

In essence i'm trying to write a write the simplest tx/rx script that works then take it from there. I only really need an echo script which says the signal strength then I can write the final distance algorithm. So close but so far!

I chose Xbees because they were advertised as being well supported, they are simple using desktops but arduino i'm finding difficult.

Thanks the echo script worked. Now I can go onto develop my application. People like you make arduino rock!