Vanganesha / xbee-arduino

xbee-arduino -- library for xbee
GNU General Public License v2.0
0 stars 0 forks source link

Rx works fine, Tx does not. Same result even using the unmodified examples. #27

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. open the Series2_Tx example
2. run it
3. Error message: No timely response

What is the expected output? What do you see instead?
I expect the packet to be sent. Instead, nothing gets sent, and the program 
outputs "No timely response"

What version of the product are you using? On what operating system?
xbee-arduino 0.3 from the zip file; OS Windows 7, Arduino IDE 1.0
Arduino duemilanove with atmega328
XBee Series2 from Digi (digi.com) FCC-ID OUR-XBEE2, IC: 4214A-XBEE2
baud rate 9600, 8N1

Please provide any additional information below.
I tried the same xbees in two ways:
1) java api, ftdi cable from computer to xbee, with xbee adapter kit 1.0 from 
adafruit
2) arduino api, with the standard xbee shield

The java api works fine, the arduino one not. I traced the code to make sure 
that identical bytes were being sent. Here are the results:
----------------
Tracing code from xbee-api and xbee-arduino
in both cases the same request gets sent: 

0x7e,0x00,0x0f,0x10,0x01,0x00,0x7d,0x33,0xa2,0x00,0x40,0x33,0x54,0x73,0xff,0xfe,
0x00,0x00,0x61,0xa1

destination xbee is 13a200 40335473

Results:
==============

send from java (xbee-api ZNetSenderExample ) to xbee over ftdi cable: works, 
packet gets sent and arrives at destination
send from arduino (xbee-arduino Series2_Tx example) to xbee over xbee shield: 
does not work,    error "No timely response"

send the raw bytes of the above resuest (via many serial.write-s for each byte) 
from a simple arduino program to xbee over the xbee shield does not work

I made a "proxy" program inside the arduino that connects software serial port 
to serial port, i.e. makes a "pipe"

void setup() {
  Serial.begin(9600);
  nss.begin(9600);
  nss.println("starting up...");
  delay(10000); //give xbee time
}

void loop() {  
  while (nss.available()) {
    c=nss.read();
    Serial.write(c);
 //   nss.print("Wrote ");nss.println(c, HEX);
  }

  while (Serial.available()) {
    nss.write(Serial.read());
    //Serial.write(Serial.read());
  }

  while (!(nss.available() || Serial.available())) {
    delay(10);
  }

}

working in AT mode, this pipe works fine. Now I try sending the raw bytes over 
the pipe in API mode

Raw bytes from the request above:
7e000f1001007d33a20040335473fffe000061a1

Sending the raw bytes from computer terminal program (coolterm) over this pipe 
to the xbee: does not work
sending the raw bytes from computer terminal program (coolterm) over ftdi cable 
to the same xbee: works fine, packet gets delivered

If I use the Series2_Tx example, but with a broadcast address, packet gets 
delivered. 

I double checked the address and it is the same in java and arduino. Baud rate 
is also the same.

Any idea what the reason might be or how to fix it? 
Thanks in advance,
Erion.

Original issue reported on code.google.com by eelmasllari on 21 Mar 2012 at 6:01

GoogleCodeExporter commented 9 years ago
Hi,

I have a similar problem with this library. It can never send any data. 
Although I'm using the new zigbee modules, S2B.

What is the expected output? What do you see instead?
I'm using the Series2_Tx example too. I'm only trying to send a payload like 
{1,2,3,4} to a specific address, and also a broadcast one, but it doesn't 
matter, the message never arrives.

What version of the product are you using? On what operating system?
xbee-arduino 0.3 from the zip file; OS Ubuntu 11.10, Arduino IDE 023
Arduino Mega2560 with Xbee Shield
XBee Pro Series2B from Digi (digi.com) FCC-ID MCO-PROS2B, IC: 1646A-PROS2B
baud rate 57600, 8N1

Please provide any additional information below.
The receive example works fine, because I have been investigating and messages 
are shown when they arrived. To do this, I used the x-ctu app, and I send the 
data by terminal making my own frame, and this frame is received by the api in 
a right way.

The frame I made was: "7E 00 10 10 01 00 7D 33 A2 00 40 86 15 D9 00 00 00 00 12 
34 3F" (It might be the same frame as send example must send).

I'll continue making some probes to try understand where the error is, but if 
you could help us it would be great.

Thanks in advance.

Regards!!

Original comment by Alvjo...@gmail.com on 23 Apr 2012 at 8:31

GoogleCodeExporter commented 9 years ago
Hi!

In my case the problem was that the XBees need to be initialized to AP=2. the 
xbee-api (Java) does it automatically, but not the arduino library. It is 
indeed mentioned in the documentation, yet IMHO not with big enough letters ;) 
So, before doing anything else, just after xbee.begin, you need to send an 
ATCommandRequest with AP=2 (careful, the AP will be a char array {'A','P'}, but 
the 2 in the value is a byte/int, not a char '2'). This worked for me. 

Ciao & good luck,
Erion.

Original comment by er...@erion.info on 23 Apr 2012 at 2:19

GoogleCodeExporter commented 9 years ago
Hi, 

thanks!! 

The Xbees are setted by X-CTU to AP2, so in my case it isn't necessary, 
although I will try it.

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,
Jorge

Original comment by Alvjo...@gmail.com on 23 Apr 2012 at 6:37

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
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,
Jorge

Original comment by Alvjo...@gmail.com on 24 Apr 2012 at 4:56

GoogleCodeExporter commented 9 years ago
I am running out of suggestions, but if I were in this position, I'd go back to 
the beginning and trace my steps in the the following order:

-reset everything to AT mode, 9600 bps
-check that things are working in AT mode, no api library needed for this
-switch the node (NOT the coordinator!) to API, check that xbee-api library in 
Java works. How you connect from Java to the XBEE depends on what cables and 
electronic skills you have. Worst case, remove the controller chip from  one of 
the arduinos; this will turn the arduino into a basic FTDI cable (google to 
find more details)
-switch the coordinator to API, AP=2, check that everything is working -- again 
only xbee-api library in Java, from the same author as xbee-arduino
-in the library, go to "private void doStartupChecks()" in XBee.java and 
comment out the part that reads and sets the AP=2 mode. Run and check that 
everything still works. 
-if everything is fine up to here, you may start using the xbee-arduino 
library. double-check to make sure the serial ports in the code and in the 
XBees are set to 9600 bps. use a hardware serial port, not a software serial 
one.
hopefully it should work at this point. if it doesn't, you might need an 
oscillator to see what is being sent to the xbees and compare it with what 
should be sent. I used this one when I had problems: http://www.saleae.com/logic

Good luck!
Erion.

Original comment by er...@erion.info on 25 Apr 2012 at 10:10

GoogleCodeExporter commented 9 years ago
Hi,

it doesn't work.
I can't find a solution, so if somebody could try it and post his/her solution 
it would be great!

Thanks!

Regards,
Jorge

Original comment by Alvjo...@gmail.com on 4 May 2012 at 1:18

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

But communication still fails!

Original comment by Alvjo...@gmail.com on 11 May 2012 at 11:25

GoogleCodeExporter commented 9 years ago
Could not reproduce

Original comment by andrew.rapp@gmail.com on 2 Feb 2014 at 6:58

GoogleCodeExporter commented 9 years ago
try to give xbee 3.3 from different source, but common the ground of both 
sources.
It will work perfectly..
I faced this issue many times and the solution worked for me.

If powering from same source a little googling could tell you to ad some 
capacitor or resistor on VCC DOUT of xbee ...
search for it.

Original comment by mohammed...@gmail.com on 1 Apr 2015 at 9:16