Pages: 1 [2]   Go Down
Author Topic: Xbee Api connection  (Read 5352 times)
0 Members and 1 Guest are viewing this topic.
Wellington, New Zealand
Offline Offline
Sr. Member
****
Karma: 1
Posts: 404
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

One problem might be the Serial.print()s which send output directly to the XBee attached to the hardware serial port, potentially messing up the api message that is also sent via the serial port.
Logged


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

Hi,

thanks!!

But I have been doing some tests and I think the reason is another one.

I set the xbee shields in USB mode, and open two x-ctu, with the 'digi API fram maker' web app, I created also the send frame as the receive one, and send it by x-ctu terminal. And how surprise!! It works!!

So, I realised that the problem is in the library or the examples, because I only tried to use them.
Logged

Wellington, New Zealand
Offline Offline
Sr. Member
****
Karma: 1
Posts: 404
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So you've tried them in USB mode, which eliminates the interference from the Serial.print() calls, and the connection works and you can send packets.

But you think that this is proof that it is not the Serial.print() calls that are causing the problem?

I don't follow your logic.  What do you think is the problem?
Logged


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

Ok, I'll try to explain my logic, sure I'm wrong but if Serial.print is the problem I don't understand why it is happening.

I think that if I'm using xbee modules in api 2 mode, and also I'm working with xbee library, so Serial.print doesn't must interfere with xbee.send or xbee.readPacket instructions. They must work in a different way in this case.

And one more doubt I have is when I launch 'xbee.send' from one module, the other doesn't receive anything even when it sends to MAC address.

It is a strange behaviour and I' m forgetting something but I haven't caught the point.

Regards.


PD: Now I'm trying to receive the packet without any 'Serial.print' instructions on the sender side and only one in the receiver side to show data however there's no response, so it never shows anything. Instructions like 'readPacket', 'xbee.getResponse().isAvailable()', or this one 'xbee.getResponse().getApiId() == ZB_RX_RESPONSE' never works fine, and I think there would be the problem.
« Last Edit: March 23, 2012, 04:07:11 am by Yolco » Logged

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

One more thing... I work with xbee shield so, when I upload my code to arduino, I have to switch the jumpers from xbee shield to xbee position. Is this right??

Or is there another configuration to improve the communication?? (I tried different ones but even though it didn't work).
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 104
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I haven't tried but I think when you upload code, you should set jumpers to usb position.
Logged

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

To upload the code I switched jumpers to USB position, but for a right behaviour they must be at xbee position. Unless someone could tell me another thing...
Logged

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

The problem is in 'send side'.

- I tried making the frames by myself and send them by x-ctu software, and it works fine!!
- Moreover, I send the handmade frame by x-ctu (from router) and I receive it (to coordinator). [I have problems showing the entire data, but this is my fault].
- In the other way, sending data with API and receiving it without it, it doesn't work.

I can't find what is the code problem. I think it might be because of the S2B chips , which are different from the S2 ones.
Logged

Wellington, New Zealand
Offline Offline
Sr. Member
****
Karma: 1
Posts: 404
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Try removing the Serial.print() and Serial.println() calls from your sketch and see it that makes any difference.
Logged


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

I tried it but there's no difference. It didn't work.

I'm thinking it could be a problem with 'send' instruction and the 'escape' character when it creates the frame.

I'm taking a look of the code.
Logged

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

Hi,

thanks!!

The Xbees are setted by X-CTU to AP2.

I was checking the library and in the XBee.cpp, at 'sendByte' function I substituted the 'write' instructions for 'Serial.print(xxx, HEX)', where xxx are 'ESCAPE', 'b^20' or 'b'. And it shows the frame to send, but this frame is wrong (I know that when a byte is '00', it only shows one '0').

I couldn't tell you if it because of the 'Serial.print' instruction this wrong behaviour, but how I told you before if I send the frame manually, the mesage is delivered to the receiver (in my case the coordinator).

Regards
Logged

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

Hi,

I've been doing more attempts today. I modified the 'send' function when it adds '2' to the frame length because the didn't be equal as the length of my frame. But it doesn't matters it didn't work yet.

So, I was looking for another thing, and I did the next things:
- I was sending data in AT mode and the coordinator received it in api mode (AP2).
- Instead an arduino mega2560 I used an arduino UNO, but the behaviour was the same as in the mega ones.
- I tried to send the data in the API mode (AP2), and received it by coordinator in AT mode, but coordinator didn't get anything.
- And, finally, I checked if it could be because of the serial. How I did this? Ok, I switched the jumpers to USB mode, and tried again to send data by terminal (x-ctu). It worked! Coordinator get the message. But when I switched back the jumpers to XBEE mode, the router didn't send anything once more.

I'm using the examples in the xbee library for API modes, and for AT modes I only printed the next message: Serial.print("HELLO");

So, it wouldn't be because of the serial. But I don't know what more to try. Also I updated the ZB modules firmwate, but they don't work yet.

Regards
Logged

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

Hello

I have a problem almost identical to yours and I'm looking for a tested code just for simple communication no more no less
I will tell you if I got results

Regards
Logged

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

"Xbee Library"

In 'sendByte' function, when the it calculates the checksum it has to be:
"checksum = 0xff - (checksum & 0xff);"

But communication still fails!
Logged

Pages: 1 [2]   Go Up
Jump to: