XBEE

I have 2 arduinos(uno and mega) each of them fitted with an xbee shield. I got both them to send me back OK when i send +++ to them, sometimes I need to seed two or three times before i get an answer, any ideas why?

Well what i want to do is to take the value read on analog0 from one of the arduino send it to the other one, the other arduino also reads analog input at A0 and then send both values + timestamp to my laptop over usb. Sth like this Time, A0Local,A0Remote

The problem is that I have problem finding any good tutorials to do this.

I have these XBees: http://www.sparkfun.com/products/9097

this shield on the arduino uno 5V: http://www.seeedstudio.com/depot/xbee%C3%82%C2%AE-shield-p-419.html?cPath=132_134

this shield on the mega 5V: http://shieldlist.org/dfrobot/mega-expansion-1-1

any tip were to find information on how to do this would be appreciated.

Kim

I have 2 arduinos(uno and mega) each of them fitted with an xbee shield.

That's the correct number.

I got both them to send me back OK when i send +++ to them, sometimes I need to seed two or three times before i get an answer, any ideas why?

Where are you sending +++ from? Why? The XBees should only receive +++ from X-CTU prior to reading the configuration or storing a new configuration.

Are you sending +++ to an XBee from the other XBee? If so, how far apart are the XBees? Are they being powered solely by the shield?

There are known issues with powering Pro models from some shields. They are 3.3V devices, and the 3.3V regulators are not always up to powering Pro models. The extra range that the Pro models provide means that they need more current. Some shields are simply not up to it.

I just used this code to test that the shields were working, and I sent +++ from the terminal from arduino and got OK back most of the times, sometimes after sending it 2-3 times… So i should make an external power supply for them?

//Serial Relay - Arduino will patch a
//serial link between the computer and the Bee Shield
//at 9600 bps 8-N-1
//Computer is connected to Hardware UART
//Bee Shield is connected to the Software UART

#include <SoftwareSerial.h>
#define RxD 2
#define TxD 3

SoftwareSerial mySerial(RxD,TxD);

void setup()
{
    pinMode(RxD, INPUT);
    pinMode(TxD, OUTPUT);
    mySerial.begin(9600);               // the Bee baud rate  
    Serial.begin(9600);                 // the terminal baud rate  
}

void loop()
{
    if(Serial.available())
    {
       mySerial.print((unsigned char)Serial.read());
     } 
    else  if(mySerial.available())
    {
       Serial.print((unsigned char)mySerial.read());
     }  

}
SoftwareSerial mySerial(RxD,TxD);

Do you really have a mySerial connected to those two pins? I didn't think so.

It is not only possible to use meaningful instance names, it is highly recommended.

    if(Serial.available())

Serial.available() returns a number, not a boolean (true or false). Don't use it like it returns a boolean.

    else  if(mySerial.available())

So, if there was data on the hardware serial port, ignore any data on the software serial port.

I'm thinking that this is not a good idea.

What code are you running on the Mega? You are not doing SoftwareSerial there too, are you?