Communication between 2 Arduino using Xbee.

Hello all,

First, sorry for my English, that's not my native language. And please excuse me if that's too easy for you, I'm a novice. I tryied to find some help on the French (yes, I'm French :) ) forum but it seems that no one can help me...

[u]My project :[/u] I'm trying to make a weather station with 2 Arduino : one outside that take an send the weathers data, and a second inside and that will receive and write it on a SD card. Not very complicated...

[u]Equipment :[/u] - 2 Arduino Uno - 2 Xbee Shields - 2 Xbee - 1 Sparkfun Weather Shield - 1 Sparkfun Weather Meters - 1 Adafruit data logging Shield

[u]Software :[/u] - Computer using Windows XP Pro SP3 - IDE 1.6.1

[u]What I already do :[/u] I write on the SD card and my 2 Arduino are communicating with the following programs :

byte var1 ;
unsigned int var2, var3;

void setup() {
  Serial.begin(9600);
  
  var1, var2, var3 = 0;
  
}

void loop() {
  var1 += 1;
  var2 += 10;
  var3 += 100;
  Serial.print(var1);
  Serial.print(',');
  Serial.print(var2);
  Serial.print(',');
  Serial.print(var3);
  Serial.print("\n");
  delay(1000);
}

And ...

void setup() {
  Serial.begin(9600);
  Serial.flush();
}

void loop() {
  int varr1 = 0, varr2 = 0, varr3 = 0;
  while (Serial.available() > 0) {
    int varr1 = Serial.parseInt();
    int varr2 = Serial.parseInt();
    int varr3 = Serial.parseInt();
    if (Serial.read() == '\n') {
      Serial.print("Varr1 =");
      Serial.println(varr1);
      Serial.print("Varr2 =");
      Serial.println(varr2);
      Serial.print("Varr3 =");
      Serial.println(varr3);
    }
  }
}

On the Xbee Shield I can see : - ASSOC is blinking - RSSI LEDs are switched on - Data are received and displayed on the Serial Monitor

[u]My problem :[/u] When I use the Sparkfun program to send data, nothing happen on the receiver and : - ASSOC LEDs are still blinking - only the receiver RSSI LED is switched on.

Does anyone has any idea of what is the problem ? Can someone try those programs ?

Thanks a lot for your help.

In addition to the undefined XBee shields, you'll need two XBees. Series 1 are point to point, which is what you need. Series 2 are mesh network models, that allow 3 or more radios to communicate, via a coordinator. While just two could be used, they are more complicated to configure.

Do not drink the digi.com Koolaid. The XBees DO need to be configured, at least they do if you want any performance out of them.

So, what IS the problem?

Sorry I hadn’t finish my post, miss click !
I also want to tell you that I’m using the Sparkfun program, but I changed the end transmission character with \n. Here is my receiver program :

void setup() {
  Serial.begin(9600);
  Serial.flush();
}

void loop() {
  while (Serial.available() > 0) {
    int winddir = Serial.parseInt();
    int windspeedmph = Serial.parseInt();
    int windgustmph = Serial.parseInt();
    int windgustdir = Serial.parseInt();
    int windspdmph_avg2m = Serial.parseInt();
    int winddir_avg2m = Serial.parseInt();
    int windgustmph_10m = Serial.parseInt();
    int windgustdir_10m = Serial.parseInt();
    int humidity = Serial.parseInt();
    int tempf = Serial.parseInt();
    int rainin = Serial.parseInt();
    int dailyrainin = Serial.parseInt();
    int pressure = Serial.parseInt();
    int light_lvl = Serial.parseInt();
    if (Serial.read() == '\n') {
      Serial.print("winddir =");
      Serial.println(winddir);
      Serial.print("windspeedmph =");
      Serial.println(windspeedmph);
      Serial.print("windgustmph =");
      Serial.println(windgustmph);
      Serial.print("windgustdir =");
      Serial.println(windgustdir);
      Serial.print("windspdmph_avg2m =");
      Serial.println(windspdmph_avg2m, 1);
      Serial.print("winddir_avg2m =");
      Serial.println(winddir_avg2m);
      Serial.print("windgustmph_10m =");
      Serial.println(windgustmph_10m, 1);
      Serial.print("windgustdir_10m =");
      Serial.println(windgustdir_10m);
      Serial.print("humidity =");
      Serial.println(humidity);
      Serial.print("tempf =");
      Serial.println(tempf);
      Serial.print("rainin =");
      Serial.println(rainin);
      Serial.print("dailyrainin =");
      Serial.println(dailyrainin);
      Serial.print("pressure =");
      Serial.println(pressure);
      Serial.print("light_lvl =");
      Serial.println(light_lvl);
    }
  }
}
  Serial.begin(9600);
  Serial.flush();

Start the serial port. Then, block until all pending outgoing serial data has been sent.

I fail to see the usefulness of THAT.

So, do you have a problem, or not?

PaulS: Do not drink the digi.com Koolaid. The XBees DO need to be configured, at least they do if you want any performance out of them.

I have to do it even if it works with an other program ?

PaulS: Start the serial port. Then, block until all pending outgoing serial data has been sent.

This Serial.flush() is just here because of the several test I did...

PaulS: So, do you have a problem, or not?

Yes ... :slightly_frowning_face:

Zgybze: My problem : When I use the Sparkfun program to send data, nothing happen on the receiver and : - ASSOC LEDs are still blinking - only the receiver RSSI LED is switched on.

It seems that data are sent (I can see that with the serial monitor of the transmitter) but nothing seems to arrive at the receiver because nothing is deplayed on its serial monitor (serial.available() is empty) ... Oh, and the jumpers are in the "communication position", so it's not the problem.

Oh, and the jumpers are in the "communication position", so it's not the problem.

What jumpers are in what position? That shield has jumpers that you need to position to connect the XBee TX pin with some Arduino pin, and to connect the XBee RX pin with some Arduino pin. "In the communication position" doesn't mean anything.

Post the code for BOTH Arduinos.

I have to do it even if it works with an other program ?

at least they do if you want any performance out of them.

But, of course, that doesn't mean that you have to configure them, if you are happy with the way that they are performing.

What jumpers are in what position? That shield has jumpers that you need to position to connect the XBee TX pin with some Arduino pin, and to connect the XBee RX pin with some Arduino pin. "In the communication position" doesn't mean anything.

What I mean with "communication position" is that I have one jumper between 0 and digital for XB_TX line and the other is between 1 and digital for XB_RX line on the Seeedstudio Xbee shield.

The transmitter code is very similar to the sparkfun code that I linked. And it's too long tu be posted directly. You should be able to download both files on this link. Tell me if it doesn't work.

But, of course, that doesn't mean that you have to configure them, if you are happy with the way that they are performing.

Do you think there is any chance that this configuration could resolve my problem ?

I hope I'm understandable, and thanks for your help !

Hi all,

Nobody is able to help me ? Or just to try my programs with two arduino and two Xbee ? Others shield are not needed, you will just have wrong values...

Thanks anyway if you can't !

What I mean with "communication position" is that I have one jumper between 0 and digital for XB_TX line and the other is between 1 and digital for XB_RX line on the Seeedstudio Xbee shield.

So, you are using the hardware serial port to communicate with the XBee AND with the PC.

Why? Why not use two other pins, and SoftwareSerial, to talk to the XBee, so the hardware serial port is available for debugging?

Tell me if it doesn't work.

I'm not even going to try. You want help here, you post YOUR code HERE. (Use Reply, and the Additional Options link, not the Quick Reply field, to attach your code here).

Do you think there is any chance that this configuration could resolve my problem ?

Yes.

Nobody is able to help me ? Or just to try my programs with two arduino and two Xbee ? Others shield are not needed, you will just have wrong values...

The specific XBee shield you have IS needed. The specific configuration of the XBees IS needed. The code for both ends IS needed, and, personally, I am NOT chasing any links to find code that may not be IDENTICAL to the code you have.

PaulS: Why? Why not use two other pins, and SoftwareSerial, to talk to the XBee, so the hardware serial port is available for debugging?

Because I didn't know this before... Yeah I'm a newbie. I'm going to google it, to see what I can do with that. But communicate with both computer and Xbee seems to be allowed, I already did it (the computer only receive and print on the serial monitor).

PaulS: I'm not even going to try. You want help here, you post YOUR code HERE. (Use Reply, and the Additional Options link, not the Quick Reply field, to attach your code here).

Zgybze: it's too long tu be posted directly.

The code exceeds the maximum allowed lenght. I tried to post before uploading it on Onedrive.

PaulS: The specific XBee shield you have IS needed. The specific configuration of the XBees IS needed. The code for both ends IS needed, and, personally, I am NOT chasing any links to find code that may not be IDENTICAL to the code you have.

Trying with another shield could help me to see if the problem come from mine or not. And you have my code, but it's note on any post, just on the cloud.

But anyway, it seems to be annoying for you. I think my programming skills are too weak for this project.

Thanks.