Wireless Arduino programming Series 2 XBees

XBee projects like the adapter, xBee tutorials, tweetawatt/wattcher, etc. from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
sgicka
 
Posts: 3
Joined: Mon Jun 17, 2013 1:10 pm

Wireless Arduino programming Series 2 XBees

Post by sgicka »

Hello,

I have recently ordered two XBee adapter kits and Series 2 XBees in hopes of wirelessly programming an arduino as instructed in the following tutorial: http://www.ladyada.net/make/xbee/arduino.html
I have followed the instructions, and set up both the transmitter and receiver (including reset circuit) as mentioned. Instead of blinking green LEDs, I have solid green and no red lighting. I understand this could be a difference between series of XBees. When I connect both XBees to X-CTU via FTDI cable and the adapter, they can communicate with the modem properly. However when I implement the adapter kit to the circuit with the arduino, I can not connect to the receiving Xbee through the Arduino usb cable as I would think I should be able to. I get the error from the screen shot I have attached.
error.PNG
error.PNG (125.56 KiB) Viewed 1165 times
I have not been able to run a range test, and the instructions for testing/debugging/or even what type of arduino sketch I should be running are not specified. Could anyone verify that this is the correct procedure to this point and maybe elaborate on how I can debug from this point?

**I am aware of the baud rate. From the tutorial, it specifies that if the Arduino is newer, to run 57600. This is consistent with both XBees.

Thank you

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Wireless Arduino programming Series 2 XBees

Post by adafruit_support_rick »

You might want to post this over on the Digi forums as well.

sgicka
 
Posts: 3
Joined: Mon Jun 17, 2013 1:10 pm

Re: Wireless Arduino programming Series 2 XBees

Post by sgicka »

Update:
Through X-CTU I have both connected. I have flashing green LED's and Red during communication. Through X-CTU I have been running range tests but at this point I am at about a 50/50 good/bad packet rate. I am not sure if this could be an Arduino (bootloaded Duemillanove) bottleneck or a different concern. I've noticed that the green led on the Arduino side (router XBee) is flashing more often than the computer (coordinator XBee). The code I have on the Arduino is the Series2IO Sample example code:

Code: Select all

#include <SoftwareSerial.h>

/**
 * Copyright (c) 2009 Andrew Rapp. All rights reserved.
 *
 * This file is part of XBee-Arduino.
 *
 * XBee-Arduino is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * You should have received a copy of the GNU General Public License
 * along with XBee-Arduino.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <XBee.h>


/*
This example is for Series 2 (ZigBee) XBee Radios only
Receives I/O samples from a remote radio.
The remote radio must have IR > 0 and at least one digital or analog input enabled.
The XBee coordinator should be connected to the Arduino.
 
This example uses the NewSoftSerial library to view the XBee communication.  I am using a 
Modern Device USB BUB board (http://moderndevice.com/connect) and viewing the output
with the Arduino Serial Monitor.    
You can obtain the NewSoftSerial library here http://arduiniana.org/libraries/NewSoftSerial/
*/

// Define NewSoftSerial TX/RX pins
// Connect Arduino pin 9 to TX of usb-serial device
uint8_t ssRX = 9;
// Connect Arduino pin 10 to RX of usb-serial device
uint8_t ssTX = 10;
// Remember to connect all devices to a common Ground: XBee, Arduino and USB-Serial device
SoftwareSerial nss(ssRX, ssTX);

XBee xbee = XBee();

ZBRxIoSampleResponse ioSample = ZBRxIoSampleResponse();

XBeeAddress64 test = XBeeAddress64();

void setup() { 
  xbee.begin(9600);
  // start soft serial
  nss.begin(9600);
}

void loop() {
  //attempt to read a packet    
  xbee.readPacket();

  if (xbee.getResponse().isAvailable()) {
    // got something

    if (xbee.getResponse().getApiId() == ZB_IO_SAMPLE_RESPONSE) {
      xbee.getResponse().getZBRxIoSampleResponse(ioSample);

      nss.print("Received I/O Sample from: ");
      
      nss.print(ioSample.getRemoteAddress64().getMsb(), HEX);  
      nss.print(ioSample.getRemoteAddress64().getLsb(), HEX);  
      nss.println("");
      
      if (ioSample.containsAnalog()) {
        nss.println("Sample contains analog data");
      }

      if (ioSample.containsDigital()) {
        nss.println("Sample contains digtal data");
      }      

      // read analog inputs
      for (int i = 0; i <= 4; i++) {
        if (ioSample.isAnalogEnabled(i)) {
          nss.print("Analog (AI");
          nss.print(i, DEC);
          nss.print(") is ");
          nss.println(ioSample.getAnalog(i), DEC);
        }
      }

      // check digital inputs
      for (int i = 0; i <= 12; i++) {
        if (ioSample.isDigitalEnabled(i)) {
          nss.print("Digital (DI");
          nss.print(i, DEC);
          nss.print(") is ");
          nss.println(ioSample.isDigitalOn(i), DEC);
        }
      }
      
      // method for printing the entire frame data
      //for (int i = 0; i < xbee.getResponse().getFrameDataLength(); i++) {
      //  nss.print("byte [");
      //  nss.print(i, DEC);
      //  nss.print("] is ");
      //  nss.println(xbee.getResponse().getFrameData()[i], HEX);
      //}
    } 
    else {
      nss.print("Expected I/O Sample, but got ");
      nss.print(xbee.getResponse().getApiId(), HEX);
    }    
  } else if (xbee.getResponse().isError()) {
    nss.print("Error reading packet.  Error code: ");  
    nss.println(xbee.getResponse().getErrorCode());
  }
}

I thought that if I was doing a range test sending a 32 bits of data, it would appear on the Arduino serial monitor with this code since the tx/rx pins are connected to pins 10/9 on the arduino.
Any thoughts on the update so far and how to optimize throughput?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Wireless Arduino programming Series 2 XBees

Post by adafruit_support_rick »

sgicka wrote:I thought that if I was doing a range test sending a 32 bits of data, it would appear on the Arduino serial monitor with this code since the tx/rx pins are connected to pins 10/9 on the arduino.
What have you got connected to pins 9 and 10 on the Arduino? The original programmer had some sort of external USB-Serial device.
Are you saying that you've jumpered Arduino pins 0,1 to arduino pins 9,10?

How is the XBee connected to the Arduino?

sgicka
 
Posts: 3
Joined: Mon Jun 17, 2013 1:10 pm

Re: Wireless Arduino programming Series 2 XBees

Post by sgicka »

I was going from xbee tx/rx to arduino 9/10. I also did the xbee tx/rx to arduino tx/rx all with poor results.

The arduino is connected to the router xbee as explained in the tutorial on assembling the adapter:
Adapter kit with mounted XBee with the reset signal circuit of a capacitor, npn transistor and resistor to the arduino reset. 5v powering the adapter from the arduino, centralized ground, and tx/rx from the xbee going to rx/tx of the arduino.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Wireless Arduino programming Series 2 XBees

Post by adafruit_support_rick »

sgicka wrote:I was going from xbee tx/rx to arduino 9/10.
The sketch you posted uses that to echo the XBee data to a serial monitor. You won't get anywhere connecting the xbee to that.
sgicka wrote: I also did the xbee tx/rx to arduino tx/rx all with poor results.
Where did you find this XBee library? I'm not familiar with that. I don't see you telling it what pins to use to connect to the XBee. What pins are you supposed to use?

Are you certain you've configured the XBee according to whatever mode this XBee library is expecting

Locked
Please be positive and constructive with your questions and comments.

Return to “XBee products (discontinued)”