XBEE + UNO not working correctly

Hey guys,

I want to use 2 XBee modules to send signals from my pc to robot to change various parameters.
I have an arduino uno conencted to Xbee via this shield http://www.active-robots.com/arduino-mega-2560.html
The other Xbee is conencted to my pc via a usb explorer dongle (http://www.active-robots.com/xbee-explorer-dongle.html)

Since this is the first time I’m using XBee I used some code available online for some initial testing, and data was sent from the arduino and seen properly in X-CTU

The next step was for me to send data from the pc (via XCTU terminal) to the arduino, and use these commands to change an LED
I’ve written some basic code for doing this adapted from different codes available online, but when I test it it doesn’t seem to work properly. The code is attached at the end of the post.

I see “2 way XBee comms started” in XCTU and when I enter letters, the tx pin on the usb dongle lights up but nothing happens on the arduino side.

Any ideas on what is going wrong, or how I can get this properly set up
Much appreciated

Arduino Code

String command;
int led=13;
char n;

void setup() 
{
  Serial.begin(57600);
  Serial.println("2 way XBee comms started");
}  

void loop() {      
  if(Serial.available())
  {
    n=Serial.read();
    if (n != 10)
    {
      command += n;
    }
    else
    {
      Serial.println("Command recieved: ");
      Serial.println(command);
  
      if (command=="on")
      {
         digitalWrite(led, HIGH);
      }
      if(command=="off")
        {
          digitalWrite(led, LOW);
        }
        if(command=="slow");
        {
          for (int i=0; i<=5; i++)\
          {
            digitalWrite(led, HIGH);
            delay(500);
            digitalWrite(led, LOW);
            delay(500);
          }
        }
        if(command=="fast");
        {
          for (int i=0; i<=5; i++)\
          {
            digitalWrite(led, HIGH);
            delay(250);
            digitalWrite(led, LOW);
            delay(250);
           }
        }
      command = "";
    }
  }
}

I have an arduino uno conencted to Xbee via this shield http://www.active-robots.com/arduino-mega-2560.html

Do you know where to find a schematic for this shield? Honestly, there are so many gotchas when it comes to getting these darn things to work properly with UNO boards, that it's not even funny, it's just a big PITN. Some of these boards can blow up your XBee modules if not configured properly.

I've looked for the schematics myself, but not had much luck. The board is made by Sparkfun, but retired and there are no schematic available.

The closest I've found is this, but the switched on this board seem different. http://www.dfrobot.com/wiki/index.php/Xbee_Shield_For_Arduino_%28no_Xbee%29_%28SKU:DFR0015%29 http://www.dfrobot.com/wiki/images/0/02/XBeeShield_SCH.png

Also I was under the impression that series 2 xbee modules are easy to get up and running?

Now that you mention S2 modules, they are more difficult to setup than S1. Read the datasheet.

Those shields look similar, but the DFRobot has a switch and the other does not. Also, the schematic for the DFRobot shield shows jumpers that must be set properly. Eg, XBee Dout goes straight to a jumper that says RXD, TXD. If you jumper the 3.3V Dout to an Arduino 5V TXD pin, you can blow the XBee module. This is what I mean by a gotcha.

Personally, I wouldn't use what you have without first tracing out the complete schematic, and am certain I'm not connecting it to blow the module. There have been about 3 or 4 other people here recently with the same problem. These shields ALL have a very poor design, AFAIAC.

Sorry, I also meant that Series 1 were easier to set up as they don't need to be configured as a coordinator, or an end device as is the case for S2.

I'm too sure how well I would fare tracing the shield as I haven't before, and tips on how I would go about it. Also would you say this board is better to use? http://proto-pic.co.uk/xbee-explorer-regulated-new/

Also, I have used it already (assuming it was working ok) and the Xbee doesn't appear to be dead, I just had issues with receiving, but I will hold of until I check the traces

Thanks for your replies so far

Yeah, that's a MUCH better part, in that it has both 3.3V regulator and 5V-to-3.3V level shifters. It's not a shield, so you have to jumper the Din, Dout pins to the Arduino header pins.

Having the S1 Xbees is a real plus, because 2 of those will communicate directly at 9600 bps without any need for configuring [assuming you haven't changed the configuration already].

Now, you have the s.w. problem. I've not found SoftSerial to work worth poo myself, so I always use the XBees with the UNO h.w. UART, which means you cannot use a USB connection to the PC and the XBee simultaneously. What you can do is setup the UNO as a remote link, and connect your Explorer dongle to the PC as the host link.

So you might try this for now, and see if you can at least get the comms going, then go from there.

  1. Plug your each of your Xbees into the Explorer dongle and connect to the PC. Run a Terminal Emulator program like Hyperterminal on the PC - [not the Arduino IDE Serial Monitor]. Set to 9600, 8N1. Then if you type +++, you should see OK come back. Do this first to verify both XBees.

  2. connect the ProtoPic XBee adaptor to the UNO as follows:

  3. gnd to gnd.

  4. UNO 5V header pin to adaptor 5V pin to power the adaptor.

  5. do NOT connect UNO 3.3V pin.

  6. UNO RX to adaptor Dout.

  7. UNO TX to adaptor Din.

  8. run the following sketch on the UNO, and you should see characters entered on the PC keyboard echoed back:

int ch;

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

void loop() 
{      
  if( Serial.available() )  {
    ch = Serial.read();
    Serial.write(ch);
  }
}
  1. note - you will have to first connect the UNO to the PC, upload the sketch, then disconnect the USB cable, and connect the ProtoPic adaptor per item 2.

Having only 1 h.w. UART on the UNO is a PITN. If you can get this all to work, then later on, you can try other arrangements. One step at a time.

Thanks for all your help dan,

I was waiting for the board and it just arrived yesterday. I wired it up and ran the script you sent me and lo and behold! 2 way communication started working properly :)

After re-writing the program in my first post, I was able to use the Xbees to carry out the actions I needed to in my first post. It now reads in the command from the pc and executes the correct command on the arduino

Thanks