How to configure Xbee S1 point to point (asking)

Hi!

I am trying to configure xbee to talk to other one. But I am not able to do it. I have 2 xbee S1 (pro and normal) and 1 arduino fio and 1 arduino duemilanove.

Code in sender:

int incomingByte = 0;   // for incoming serial data

void setup() {
  Serial.begin(9600);  // opens serial port, sets data rate to 9600 bps
  pinMode(13, OUTPUT);

  // blink twice at startup
  digitalWrite(13, LOW);
  delay(1000);

  digitalWrite(13, HIGH); // first blink
  delay(50);
  digitalWrite(13, LOW);
  delay(200);
  digitalWrite(13, HIGH); // second blink
  delay(50);
  digitalWrite(13, LOW);
}

void loop() {
  delay(5000);
    Serial.write('1');
digitalWrite(13, HIGH); // second blink
  delay(50);
  digitalWrite(13, LOW);
}

Code in second arduino:

int incomingByte = 0;   // for incoming serial data

void setup() {
  Serial.begin(9600);  // opens serial port, sets data rate to 9600 bps
  pinMode(13, OUTPUT);

  // blink twice at startup
  digitalWrite(13, LOW);
  delay(1000);

  digitalWrite(13, HIGH); // first blink
  delay(50);
  digitalWrite(13, LOW);
  delay(200);
  digitalWrite(13, HIGH); // second blink
  delay(50);
  digitalWrite(13, LOW);
}

void loop() {
  // send data only when you receive data:
  if (Serial.available() > 0) {
    // read the incoming byte:
    incomingByte = Serial.read();

    if(incomingByte == '0'){
      digitalWrite(13, HIGH);
      delay(1000);
      digitalWrite(13, LOW);
    }else if(incomingByte == '1'){
      digitalWrite(13, HIGH);
      delay(5000);
      digitalWrite(13, LOW);
    }    
  }
}

I tried in default mode with this code. Not working. After I tried to change configuration of xbee, same pan id (like before) same DH and seting up the DL with the SL of other one. Other options kept as default.

I don't know what more I have to do. I have looked for any tutorial but all are for series 2 or 2.5 and I can't choose coordinator or router/end device.

Any idea, tutorial where I can find any solution or something I can read?

If the two XBees can’t talk to each other, the code is not really relevant, is it?

I tried in default mode with this code.

That crap from digi about XBees being able to talk to each other out of the box is an outright lie.

After I tried to change configuration of xbee, same pan id (like before) same DH and seting up the DL with the SL of other one. Other options kept as default.

SL should not have been altered.

The PAN ID’s need to be the same. DL on one XBee needs to match MY on the other one. Neither DL or MY should be 0.

I put the code because I don't know if the problem comes from xbee or the program.

I didn't change SL, I put SL's value on the other xbee's DL.

Pan IDs are the same.

So, I have to set DL = OTHER MY in both devices?

I can't try it until tomorrow but I will try and after I post it telling what happens.

Thanks!

I didn't change SL, I put SL's value on the other xbee's DL.

Good. This means you won't need to change it back.

Pan IDs are the same.

Good.

So, I have to set DL = OTHER MY in both devices?

Yes. If one XBee has DL = 45 and MY = 27, the other one must have DL = 27 and MY = 45.

What values you choose for MY and DL do not matter as long as the same two values are used on each XBee (in opposite places, of course) and neither value is 0.

I see.

Other question related is that what happend if I want to use instead a point to point connection, a connection where every point is connected to the same xbee. Something like: Point a, point b, point c, these 3 connected to point d.

A, b and c, must have DL = MY point d. But what is about point d? Is it possible with series 1?

If one XBee needs to listen to other XBees, it's MY address needs to be known to them. It that one XBee also needs to be able to talk to the other XBees, then it must do so in broadcast mode. That is, it's DL must be 0.

Be forewarned, though, that sending data to another XBee using a non-zero DL happens immediately. Sending data using a 0 DL happens only when the network is quiet. In other words, later. Sometimes considerably later.

Ok, I will keep in mind.

Is it possible to send info from the central xbee one by one imnediatley? Maybe the broadcast mode works fine for me, because I just want to send info from the central node for configuring time. I will check. Firstly I want to connect 2 xbee and after, when all go fine, I will try with 3.

Is it possible to send info from the central xbee one by one imnediatley?

How? The XBee has one configured address to send data to - either a specific XBEE (DL != 0) or all (DL == 0).

Perhaps with API mode, but not in AT mode.

I checked reference manual of xbee s1. Maybe API mode is what I need. I will check serial option, if it works, thats ok. If it doesn’t, then I will read more about api mode.
With api mode, I can use xbee as tcp protocol, in that case I can change the header, writing each time the correct destination address. I could have an array and repeat a loop sending to all.

Thanks PaulS. It works!! I will try to do my work with in this way. But I will look for info about api mode. I will ask if I can't or I have doubts.

I want to ask you, is it possible to send a struct by serial connection? I would want to send a struct formed by 2 values:

typedef struct {
  int a;
  int b;
} tiempo; 

tiempo variable;

I want to give 2 values to a and b, and send variable. But I get an error with: Serial.print(variable);

Any librarie for this?

I want to ask you, is it possible to send a struct by serial connection?

It is. But, it might not be the best way.

If you just want to send two integers, using Serial.print(), the integers are converted to strings to be sent, so you need a delimiter, so the receiver knows where one ends and the other begins.

Serial.print(variable.a);
Serial.print(",");
Serial.print(variable.b);

Sending a struct as binary data is possible, and the receiver can reconstruct the struct, but it is not an easy thing to do.

In API mode I can send a struct without problems? I remember programming in C, I could send a struct and on the other side, keep it in a struct variable. Is it possible?