Pages: [1]   Go Down
Author Topic: Tested Code for XBee Arduino communication in API mode  (Read 1203 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

I searched the web about a thread, topic or any thing that provide a tested code for a simple communication in api mode for XBee and Arduino and I found codes didn't work with me, I tried too many codes and I don't know why they don't work, I took all consideration for my far knowledge

so I hope this thread comes out with some results

Regards
 smiley
« Last Edit: May 08, 2012, 01:30:14 pm by Fouad » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46240
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You need to post some code, explain what you think it does, and what it actually does. Then, we have some hope of helping you. Otherwise, there is no hope.
Logged

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

PaulS thanks for your reply

the XBee used is XBee 2mW Chip Antenna - Series 2 (ZB)
the XBee configuration as follow:

API mode Coordinator and Router, AP=2, DH=0, DL=0, BD at 9600 for the two.
Then I connect the Coordinator directly to the PC with the usb shield and connect the Router to the Arduino and uploaded the Router code.

Router Code
Code:
#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);
}

Then I opened the XCTU to see what I'm receiving on the Coordinator's side, and nothing was received
Logged

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

I Have tried this thing next to the previous reply

I connected the arduino to the router and installed the Router code form the previous reply 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:

Code:
7E 00 0F 10 01 00 7D 33 A2 00 40 7D 5E 70 39 FF FE
Which is has no response on coordinator !! (I think the xbee library generate the wrong frame format for my XBee)

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 :

Code:
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

I Think the problem is in the code or the library 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 as is the previous reply.
regards
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46240
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you tried running the XBees in AT mode? Do you KNOW that they talk to each other?

Why are you using mesh network models to do point to point communication?
Logged

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

Aha

the AT command works good but it has a problem which is it keep sending data and then stop sending and then sending the data was send all at once, so it send at the begining and then freez for some seconds and then sends at once

I have 3-XBee module and I want to make a mesh network.

I used a tool called "RCOM-MeshBee" you can google it to test the connection in api and it works fine and the output api fram was like this


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

Pages: [1]   Go Up
Jump to: