Poll
Question: which better to work with ?
API mode ? - 8 (88.9%)
AT mode ? - 1 (11.1%)
Total Voters: 9

Pages: [1] 2   Go Down
Author Topic: PC Coordinator + XBee Arduino + API mode  (Read 7886 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello every body smiley

I need your help about this !
I have a 3 XBee modules and I want to connect the coordinator to PC and the 2 routers to Arduino so I have tried many codes to get communication and nothing worked even I tried to connect coordinator to arduino and tried to communicate with router on arduino and nothing worked...

I have configured the XBee modules with the latest firmware and DH=0, DL=ffff, AP=2 for coordinator and DH=0, DL=0, AP=2 for routers

the code that I had tried is from the following thread
http://arduino.cc/forum/index.php/topic,90128.0.html

The transmitter code :
Code:
Quote
#include <XBee.h>

uint8_t text[] = {'H', 'e', 'l', 'l', 'o'};

XBee xbee = XBee();
XBeeAddress64 remoteAddress = XBeeAddress64(0x0013a200, 0x407a3903);
ZBTxRequest zbTx = ZBTxRequest(remoteAddress, text, sizeof(text));

void setup () {
  delay(1000);
  xbee.begin(9600);
}

void loop () {
  xbee.send(zbTx);
  delay(3000);
}
The receiver code :
Code:
Quote
#include <XBee.h>

XBee xbee = XBee();
ZBRxResponse zbRx = ZBRxResponse();

void setup () {
  delay(1000);
  xbee.begin(9600);
  Serial.println("starting up yo!");
}

void loop () {

  // 1. This will read any data that is available:
  xbee.readPacket();

  // 2. Now, to check if a packet was received:
  if (xbee.getResponse().isAvailable()) {
    if (xbee.getResponse().getApiId() == ZB_RX_RESPONSE) {
      xbee.getResponse().getZBRxResponse(zbRx);
    
     for (int i = 0; i < zbRx.getDataLength(); i++) {
         Serial.print("payload [");
         Serial.print(i, DEC);
         Serial.print("] is ");
         Serial.print(zbRx.getData(i));
     }
    }
  }
}


I need to make a simple communication in API mode but nothing work and tested code could help me I will appreciated  and I appreciate any help smiley
Regards  smiley

« Last Edit: May 06, 2012, 07:18:15 pm by Fouad » Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello Fouad,

Have you downloaded the Xbee library to your Arduino software?

Did you changed the address of the remote device in the transmitter code?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset



first of all mismas_nc many many thanks for your reply smiley
yes I have done this correctly, I've tried to send the API frame using X-CTU just XBee to XBee on the explorers and they work good
but I want to use arduino with XBee, the problem is the code dosn't work

Regards
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4089
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Do your explorers have RSSI LEDs? Are they lighting up when the transmission is sent?
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello Mr. Jack Christense
many thanks for your replay I do really appreciated
the explorer is connected to arduino and it has RSSI LED but it is not lighting up

Regards
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4089
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Then the transmission is not getting through. Look at the "Series2_Tx" example that comes with the XBee library. Implement some similar code to read the ZBTxStatusResponse.  Use getDeliveryStatus(), assign it to a variable, and print it out.  Status codes are as below.

I might slow down the transmissions to maybe every 8 or 10 seconds until I got it working.  Also just FYI, setting DH and DL in API mode has no effect, the address is in the ZBTxRequest packet.

Code:
00110 #define     SUCCESS 0x0
00111 #define CCA_FAILURE 0x2
00112 #define INVALID_DESTINATION_ENDPOINT_SUCCESS 0x15
00113 #define     NETWORK_ACK_FAILURE 0x21
00114 #define NOT_JOINED_TO_NETWORK 0x22
00115 #define     SELF_ADDRESSED 0x23
00116 #define ADDRESS_NOT_FOUND 0x24
00117 #define ROUTE_NOT_FOUND 0x25
00118 #define PAYLOAD_TOO_LARGE 0x74
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

before I try your suggestion I'd like to mention that I erased #include <NewSoftSerial.h> from the original code from the example
is it ok ?

because I tried so many times to add NewSoftSerial library and the arduino didn't accept it and send me error message about it, so I decided to remove it

 
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have inserted this to the end of the "void loop"

void loop(){
.
.
.
   int x=txStatus.getDeliveryStatus();
           if (x) {
        Serial.println(x,HEX);
      }
}

and it gave me: 53
but I didn't fine the related problem !!
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4089
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Regarding NewSoftSerial, the XBee library uses hardware serial and the XBee must be hooked to the hardware serial pins. Is that how you have it connected?  (That said, there should be no problem using NewSoftSerial for other devices.)

You have the XBee product manual? There is no status code of 0x53, see page 110. So something is fishy, I'd double check my code.
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I connected the TX, RX, POWER, GND between Arduino and XBee
I work with the code with out the "NewSoftSerial" library and I'd like to know if it is ok ?

I have checked the status and I didn't find any related one to mine

so what I'm asking if there is a simple code and may be tested that any body could post it to me, I will be greatfull
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4089
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You must have some sort of installation issue, including the NewSoftSerial library should cause no problem. But the XBee library does not use it, like I said.

Probably the Series2_Rx and Series2_Tx examples are about as simple as it gets. Haven't played with them myself, but I might try that if I were you.

Here is a blog post of mine that may also be useful.
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks for you support I'll try my best and get back with good results

Regards
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried the code in the xbee library
the TX and RX code for seirs 2 and nothing worked the cooedinator keep sending but the router does not respond
any help please ?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I Have tried this thing
I have one  XBee in API as coordinator, and one router XBee in API

I connected the arduino to the router and installed the following code on arduino
Quote
#include <XBee.h>

uint8_t text[] = {'H', 'e', 'l', 'l', 'o'};

XBee xbee = XBee();
XBeeAddress64 remoteAddress = XBeeAddress64(0x0013a200, 0x407a3903);
ZBTxRequest zbTx = ZBTxRequest(remoteAddress, text, sizeof(text));

void setup () {
  delay(1000);
  xbee.begin(9600);
}

void loop () {
  xbee.send(zbTx);
  delay(3000);
}

the serial output of the arduino is:

7E 00 0F 10 01 00 7D 33 A2 00 40 7D 5E 70 39 FF FE

Which is has no response on coordinator !!

So I tried the following, I tried to communicate using direct I/O on the two XBees and I has a API frame communication from the router to the coordinator which is :

7E 00 12 29 00 13 A2 00 40 7C 48 1E 4C 46 01 01 00 01 00 00 01 00

and communicate well smiley
I Think the problem is in the code on arduino it should be edited to send a frame such as the second one to establish communication

I’m I right ??
I think the following command should modified

Quote
ZBTxRequest zbTx = ZBTxRequest(remoteAddress, text, sizeof(text));
If yes, How to make that ??

P.S: the XBees configuration as follow
Receiver : COORDINATOR API, Version 21A7 , DH=0, DL=FFFF
Transmetter : ROUTER API, Version 23A7 , DH=0 , DL=0
AND THE SAME PAN ID
regards
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 66
Rock&Roll;
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Fouad,

I have a similar issue.

I have debugged the sended frame from arduino and direct I/O, and they aren't the same.
I think the problem isn't in 'ZBTxRequest' function, instead it is in the XBee library 'send' function, where the frame is created.

I'm investigating this!

Regards.
Logged

Pages: [1] 2   Go Up
Jump to: