user2389313
user2389313

Reputation: 25

unicast transmission on Xbee

I implemented connexion between Lilypad Arduino and Xbee serie 1. Now I want to send data to 2 Xbee, but I want to notify only one Xbee .I had successfully established the broadcast transmission I had some problems and I don't know if my problem is on configuration the Xbee or in arduino. Here is some of my arduino

int myData = 0;
int const redPin = 9;
int const bluePin = 10;
int const greenPin = 11;

void setup(){
Serial.begin(9600);
pinMode(redPin, OUTPUT);
pinMode(bluePin, OUTPUT);
pinMode(greenPin, OUTPUT);


digitalWrite(redPin, HIGH);
digitalWrite(bluePin, HIGH);
digitalWrite(greenPin, HIGH);
}



void loop(){

if(Serial.available() > 0){

    myData = Serial.read();

    if(myData == '1'){
    digitalWrite(bluePin, HIGH);
    digitalWrite(greenPin, HIGH);
    digitalWrite(redPin, LOW);
    }

    if(myData == '2'){
    digitalWrite(redPin, HIGH);
    digitalWrite(greenPin, HIGH);
    digitalWrite(bluePin, LOW);

}
    if(myData == '3'){
    digitalWrite(redPin, HIGH);
    digitalWrite(bluePin, HIGH);
    digitalWrite(greenPin, LOW);

}
    if(myData == '4'){
    digitalWrite(redPin, LOW);
    digitalWrite(bluePin, LOW);
    digitalWrite(greenPin, LOW);

}
    if(myData == '5'){
    digitalWrite(redPin, HIGH);
    digitalWrite(bluePin, HIGH);
    digitalWrite(greenPin, HIGH);
}


}

}

Can any one Help me ? Any suggestions could be helpful, thx in advance!

Upvotes: 1

Views: 288

Answers (1)

gsp8181
gsp8181

Reputation: 358

I am guessing your XBee is set to AT mode and not API mode. You will need to input AT commands to set the destination of the transmission.

Guide to sending AT commands on Arduino

You will need to run ATSH and ATSL to get the Higher and Lower portion of the serial number on your destination device. On the device you wish to send from, you need to run ATDH and ATDL appending the serial after each part i.e. ATDH0123456. If you mess up, just run ATRE to clear the settings!

You can also set two XBee's on the same network instead of setting a specific destination with ATID1234 for network 1234.

If you are using an Arduino to send, you can run something like this

Serial.print("+++");
delay(1000);
Serial.println("ATRE"); //Resets the settings of the XBee
Serial.println("ATDH13A200"); //Remote XBee's ATSH with this set as 13A200, replace
Serial.println("ATDL1234"); //Remote XBee's ATSL with this set as 1234, replace

//Serial.println("ATWR"); //Uncomment to save settings through poweroff until reset

Upvotes: 1

Related Questions