Yun SoftwareSerial not reading complete XBee Frame

Greetings,

I have a pair of XBees that talk to each other just fine. I am able to see Analog data that my Xbee router sends to my XBee Coordinator. The analog input is a temp sensor and I can see that change in the Frame info in XCTU.

My problem is that when I read the data passed thru the SoftwareSerial lines(Pins 10, 11 on Yun) the frame length is read as 02(H) instead of 12(H) and I end up with a 6 Byte Frame and no data.

The Frame comes into the Coordinator just fine but somehow the Frame is not Sent out properly. I have read the XBee documentation but it is all related to hardware UArt type of comms. I have tried many different parameter changes on the XBee and matched these changes in my software serial port.

Any suggestions are appreciated.

Thanks,

Regards,

Mike M

Any suggestions are appreciated.

Without seeing the actual code, it's hard to suggest what the problem might be.

It's hard to imagine that only one byte of the frame is received incorrectly, and its hard to imagine that it is consistently the same byte, unless something is stepping on the byte in a consistent (and incorrect, obviously) way.

PaulS,

Thank you for our reply.

Here is the code I am using for the Router with one Analog input.

#include <SoftwareSerial.h>
#include <Bridge.h>

SoftwareSerial mySerial(10, 11);

void setup() {
  Bridge.begin();
  Console.begin();
  mySerial.begin(9600);
}

void loop() {
  if (mySerial.available() >=22){
    if (mySerial.read() == 0x7E){
      Console.print("7E, ");
      for(int i=1;i<19;i++){
        byte discardByte = mySerial.read();
      Console.print(discardByte,HEX);
      Console.print(", ");
    }
    int analogMSB = mySerial.read();
    Console.print("MSB, ");
    int analogLSB = mySerial.read();
    Console.print("LSB, ");
    int chkSum = mySerial.read();
    Console.print("ChkSum");
    Console.println();
    }
  }
}

The coordinator( when connected to XCTU) has the proper Frame type 92 coming in with correct data.

This is what the Console displays:

Unable to connect: retrying (1)... connected!
7E, 0, 2, 8A, D, 68, 7E, 0, 2, 8A, D, 68, 7E, 0, 2, 8A, D, 68, 7E, MSB, LSB, ChkSum
7E, 0, 2, 8A, D, 68, 7E, 0, 2, 8A, D, 68, 7E, 0, 2, 8A, D, 68, 7E, MSB, LSB, ChkSum
7E, 0, 2, 8A, D, 68, 7E, 0, 2, 8A, D, 68, 7E, 0, 2, 8A, D, 68, 7E, MSB, LSB, ChkSum
7E, 0, 2, 8A, D, 68, 7E, 0, 2, 8A, D, 68, 7E, 0, 2, 8A, D, 68, 7E, MSB, LSB, ChkSum
7E, 0, 2, 8A, D, 68, 7E, 0, 2, 8A, D, 68, 7E, 0, 2, 8A, D, 68, 7E, MSB, LSB, ChkSum
7E, 0, 2, 8A, D, 68, 7E, 0, 2, 8A, D, 68, 7E, 0, 2, 8A, D, 68, 7E, MSB, LSB, ChkSum

It appears that the repeating 6 byte sequence is a "Modem Status" frame.The other thing that I don't understand is the data displayed on the Console is refreshing about every 8 seconds but I set the sample rate of the Router to 5 seconds.

I am new to XBee and admit I do not have a complete understaning of the device but I have tried to sort this problem for several days and I am still baffled.

Thanks.

Regards,

Mike M

SoftwareSerial mySerial(10, 11);

So, you have a mySerial connected to these pins. What the heck is a mySerial? A meaningful name would make a lot more sense. If there is an XBee connected to these pins, why not use Fred and the name? Or, even XBee?

  if (mySerial.available() >=22){
    if (mySerial.read() == 0x7E){
      Console.print("7E, ");
      for(int i=1;i<19;i++){
        byte discardByte = mySerial.read();

If there are 22 or more bytes, the assumption is that some specific frame type is coming. You don't check that the correct frame type arrives.

If there are 22 or more bytes, and the first of those 22 is 0x7E, you read and print 19 bytes. If the first of the 22 is not 0x7E, you assume that the next 3 bytes are MSB, LSB, and the checksum. Personally, I do not think that that is a valid assumption.

What is the sending XBee connected to? Why is it apparently not sending a type 92 frame when the coordinator is connected to the Yun instead?

PaulS,

So my serial port naming should be meaningful to you. I did not request help with programming style. This code will never see any eyes but my own and if it does I will name the connection "Pauls Special GD Serial".

I can see from this code that the proper frame IS NOT being sent and if I knew why I would not be taking your time.

Thank you.

Regards,

Mike M.

For Those following this post,

I have just started using theArduino Yun. I have an attached XBee sensor network that is sending data to the Yun through the SoftwareSerial connection.

My XBee network was working just fine but I ran into a problem getting proper data to the Arduino. I asked for help on this forum and continued to seek the solution.

I finally realized that the info I was being sent by the XBee was a Modem Status frame. This frame was constantly repeated. I went back to the XBee docs and discovered that the message I was being sent was "0x0D = Voltage supply limit exceeded (PRO S2B only)".

I had my Yun supplying +5 volts to a Sparkfun Explorer Regulated which held my Coordinator. I switched over the supply to the +3.3 volts and frame type 92 data frames were seen at the Yun.

Attached find the the Modem Status frame specs.

Regards,

Mike M.

I switched over the supply to the +3.3 volts and frame type 92 data frames were seen at the Yun.

Nice work figuring that out.