Go Down

Topic: XBee not sending right away (Read 440 times) previous topic - next topic

Hey guys. :-)

Recently I've been trying to create some kind of simple RC using XBee's.
But I've hit a brick wall.

The problem is, that my sender (controller) sends strings of data, simply using Serial.println("");, which is fine.
But it seems that the data is not send right away. E.x i send 10x "F1" (Forward, speed=1), it doesn't receive 10x "F1", it receives something like: "F\n 1\n F1\n F1\n F1..." and so on.

I could post some code, but it's really just reading from a joystick, and then sending the strings "F1", "B1" and so on.

Anyone got an idea of why this is happening?
Thanks in advance.

PaulS

Which XBees? How are they configured? It likely isn't a code issue, but one never knows without seeing the code (on both ends).

The XBee's are of the chip-kind, I really don't know what kind they are, besides that..
Although, I think the code is actually what's messing with me.
I changed a few things in the receiver code, and that seemed to have changed a few things.

Do you have an example of a really simple receiver code? My current one is:

Code: [Select]
String str = "";
 
  if(Serial.available() > 1)
  {
    while(Serial.available())
    {
      char c = Serial.read();
      str.concat(c);
    }
  }

  if(str != "" && str != "\n")
  {
    Serial.print("New: ");
    Serial.println(str);
  }


But that still seems to kind of buggy, my output right now from the console is:
Code: [Select]
New: F1
New:


But it gets even buggier if I send more data..

PaulS

Quote
But that still seems to kind of buggy, my output right now from the console is:

You are printing a String on each pass through loop(), whether you have received data, or not.

You are sending that data through the XBee back to the sender. Why?

You'll need to know more about the XBees than that they have a chip antenna if you expect the configure them correctly.

How are the XBees connected to the Arduinos?

I believe this is the one: http://www.let-elektronik.dk/xbee-1mw-chip-antenne.html
The Serial.println is just for debugging purposes. It sends data back, but the 'sender' doesn't read this, so it doesn't matter. It just for me to follow in the console, when testing. And the string isn't getting printed, unless it actually contains something.

PaulS

Quote
And the string isn't getting printed, unless it actually contains something.

Like a line feed?

The proper ratio of answers to questions is 1+ to 1. You are quite a bit under that ratio right now.

Go Up