Problem on receiving xbee data on arduino

Hello! I'm from Brazil and this is my first post, so apologize for the bad English and also if I did something wrong.

My goal is very simple (so I think): I want to establish a xbee network with three devices.

DEVICE A: IBoard EX (http://imall.iteadstudio.com/iboard-ex.html)
Uses a xbee configured as coordinator in AT mode.
DL and DH are set to broadcast (FFFF).

DEVICE B: Arduino Uno with Open Jumper's sensor expansion shield (http://x.openjumper.com/en/sensors-shield/)
Uses a xbee configured as router in AT mode.
DL and DH are set to coordinator (0).

DEVICE C: Arduino Nano with other xbee and sd card shield (http://imall.iteadstudio.com/im120417016.html).
Uses a xbee configured as router in AT mode.
DL and DH are set to coordinator (0).

The initial idea was to make DEVICE A as a webserver, to host a web service to check and control sensors and relays at DEVICES B and C. I have no problem with the ethernet, webserver and webservice stuff, but I was not able to get the xbees working correctly.

So, I decided to simplify a little my environment for debugging proposes.

I'm just using DEVICE A and a xbee explorer connected to my PC.

I uploaded this sketch to DEVICE A:

#include <SoftwareSerial.h>
SoftwareSerial softSerial0(0,1);///RX/TX

void setup()
{
  softSerial0.begin(9600);
  pinMode(0,INPUT);
  pinMode(1,OUTPUT);
}

void loop()
{
  softSerial0.print('H');
  delay(1000);
  softSerial0.print('L');
  delay(1000);
}

And opened X-CTU at terminal screen on my PC.

Everything works as expected. I receive all H and L at X-CTU.

But, if I type something at X-CTU, that thing does not appears at DEVICE A serial console.
That is ok, because I did not program that.

So, I uploded this sketch to Arduino:

#include <SoftwareSerial.h>
SoftwareSerial softSerial0(0,1);///RX/TX

const int ledPin = 13; // the pin that the LED is attached to
int incomingByte;      // a variable to read incoming serial data into

void setup() {
  Serial.begin(9600);
  softSerial0.begin(9600);

  pinMode(ledPin, OUTPUT);
  pinMode(0,INPUT);
  pinMode(1,OUTPUT);

}

void loop() {
  if (softSerial0.available() > 0) {
    incomingByte = softSerial0.read();
    Serial.println(incomingByte);
    // if it's a capital H (ASCII 72), turn on the LED:
    if (incomingByte == 'H') {
      digitalWrite(ledPin, HIGH);
    } 
    // if it's an L (ASCII 76) turn off the LED:
    if (incomingByte == 'L') {
      digitalWrite(ledPin, LOW);
    }
  }
    Serial.println(incomingByte);
    delay(250);
}

It does not matter what I type at X-CTU. DEVICE A serial console only keeps showing "0".

I tried to switch my xbees, but the result was the same.

Can anyone provide some help?

SoftwareSerial softSerial0(0,1);///RX/TX

It does not make sense to have a SoftwareSerial on the HardwareSerial pins. As your board is a Leonardo-Clone, you can use just Serial1 and omit the SoftwareSerial completely.

pylon, if I could I would kiss you!!! :*

Thanks very much!

If you allow me, I'll have two more questions:

a) Where could I have obtained that info? So i can study more and don't make stupid questions on the future... :blush:

b) If I run that code on DEVICE B, it does not work. Do you know why?

Thanks again!

a) Where could I have obtained that info? So i can study more and don't make stupid questions on the future...

http://arduino.cc/en/Guide/ArduinoLeonardoMicro

b) If I run that code on DEVICE B, it does not work. Do you know why?

That's an Arduino UNO, which has no USB connectivity in the main processor but uses a ATmega16U2 coprocessor for the USB interface. The two processors are communicating over the hardware serial interface (which is available on pin 0/1). You can still use the hardware serial interface but not concurrently with the USB debugging serial connection.

Pylon, thanks for the reference.

I was finally able to solve my problem with the Uno and chinise shield: the xbee was upside down. :sweat_smile:

Again, thanks so much for your help!