xbee code sending help

so i will post some code that i am using and my problem is that i just configured my xbees and they can talk to eachother in terminal in XCTU but i cut the power and put my ATMEGA chip back in then unhook my xbee’s then upload the code to my arduinos. i then plug the xbees back in and turn the power on. nothing happens. this is a simple code but im not sure what the problem is. i really need help so anything will help.

Thanks

Send:

//client
//setup
void setup()
{
  //init serial communication
  Serial.begin(9600);
}

//main
void loop()
{
  //send H
  Serial.print('H');

  //delay
  delay(1000);

  //send L
  Serial.print('L');

  //delay
  delay(1000);
}

Receive:

//server

//led pin
const int led_pin = 13;

//incoming data stream
int stream;

//setup
void setup()
{
  //init serial communication
  Serial.begin(9600);

  //init led pin as output
  pinMode(led_pin, OUTPUT);
}

//main
void loop()
{
  //check incoming data
  if(Serial.available() > 0)
  {
    //read data
    stream = Serial.read();

    //check data
    boolean value = (stream == 'H' ? HIGH : LOW);

    //set led pin value
    digitalWrite(led_pin, value);
  }
}

FWIW, I am trying to do this in three steps to debug issues:

  1. laptop-xbee to xbee-laptop (here you know that xbee is working)
  2. laptop-arduino-xbeeshield-xbee to xbee-laptop (one time each for sender and receiver; here atleast one side is working)
  3. laptop-arduino-xbeeshield-xbee to xbee-xbeeshield-arduino-laptop (here both sides are working)

Hi,

I recently had a similar problem with my XBee modules (series 2) which would connect to each other but they didn't seem to be sending/receiving data.

Thankfully, the simple answer was to switch the jumpers on my XBee shields from USB to XBEE once i'd uploaded the sketches. This seemed to solve the problem of the two XBees sending and receiving but I never got round to examining the data via Serial Monitor.

Perhaps you need to switch your jumpers around (if you're using an XBee shield?

alright well im not sure how to do my wireing any different because i have his shield: http://www.ladyada.net/make/xbee/index.html

i have 3.3v and ground connected and tx to tx and rx to rx

As is typical with any communication problem, there are a lot of variables :-)

Serial communication - Ensure that your Xbee is powered (Look for lights) - Use a USB->FTDI cable to communicate to your Xbee through any terminal program. You can put it in command mode and make sure its happy. It will respond. - Power both Xbees, and use the USB->FTDI to issue the command to find other Xbee radios. It will respond with their IDs and signal strengths. This proves all of your Xbee HW radios are working. 2- Ensure that you have the Tx and Rx wired correctly between Arduino and Xbee. This is not always as straightforward as it seems. I would recommend using software serial to communicate to the Xbee so you can use your Serial Monitor to communicate to the arduino. Copy whatever is received from Software Serial (which is talking to Xbee) to Serial Monitor (which will come over the USB hooked to your arduino) 3- Ensure your PAN (personal area network) IDs are ok. If they are different, then the XBEES are on different networks. If using defaults, you should be okl

Good luck dude. Just lock down one variable, test it, and move to the next. Ground up.

There's an XBee shield that doesn't need jumpers changing it does it for you. http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=320600445777&ssPageName=STRK:MESELX:IT

Miles

alright ill try some of those and i had them talking to eachother so they work right but i am powering them b usb right now just to test if they are working with the code is that alright to power like that? or do i do DC?

I think the naked Xbees take 3.3v. I use the Xbee adapters from adafruit http://www.adafruit.com/index.php?main_page=product_info&cPath=29&products_id=126 so I can feed it 5v or whatever. There is a 3.3v output on the Arduino, but I am not sure it will produce enough oomph! for a couple XBees when they are transmitting. They probably will, but not sure.

So when I unplug my USB cord and put the 9v on it didn't send anymore I havnt got it to revive either but r u saying if I use 5v it should work?