0

I have 2 Xbee Series2 modules, one set to Coordinator AT (Connected to PC with XCTU via USB dongle) and other set to Router AT(Connected to Arduino is connected to PC USB... RX>TX TX>RX and 5V GND)

http://continentalee.com.sg/xbee-adapter My xbee adapter

I have the programme uploaded into Arduino, a very simple sketch to test xbee wireless communication.

Code is here

char msg = ' '; //contains the message from arduino sender
const int led = 13; //led at pin 13


void setup() {
Serial.begin(9600);//Remember that the baud must be the same on both arduinos
pinMode(led,OUTPUT);
}
void loop() {
while(Serial.available() > 0) {
           msg=(char) Serial.read();

           if(msg=='H') {
               digitalWrite(led,HIGH);
           }
           if(msg=='L') {
                digitalWrite(led,LOW);
           }
delay(1000);
}
}

The problem comes.

When I type "H" in the Serial Com, the led light up, and the letter "H" appears in the XCTU console.

however, when I type something into the XCTU console, nothing appears on my Serial monitor and no light is seen on arduino

Thank you for your help in advance.

1 Answer 1

0

Your example does not show your code that sends correctly but I will assume that it used 9600 speed and that the xbees are configured to 9600.

Not sure if this will help ...

Arduino is connected to PC USB... RX>TX TX>RX

1) In this case maybe you should ensure that xbee tx is connected to the correct rx pin on the Arduino? I know you have stated this above but with the basic xbee configuration, if data works one way then it should also work the opposite way.

however, when I type something into the XCTU console, nothing appears on my Serial monitor and no light is seen on arduino

2) Your example doesn't show any code to send data to XCTU and the pin13 LED will only light up when an 'H' is sent from XCTU

You could try this for better diagnostics

    void loop() {
while(Serial.available() > 0) {
           msg=(char) Serial.read();

      Serial.print("data arrived from xctu: ");
      Serial.print(msg);
      Serial.println();


           if(msg=='H') {
               digitalWrite(led,HIGH);
           }
           if(msg=='L') {
                digitalWrite(led,LOW);
           }
delay(1000);
}
}
2
  • Hi, thank you for your response. I checked the baud and the connection, everything is fine. Do you mind to enlighten me how to write code to send messages to XCTU using the arduino serial monitor Jul 14, 2015 at 9:38
  • Hi, my code example shows how to do this. You should see a message in xctu showing the text "data arrived from xctu:". Have you configured xctu to 9600 baud and opened the port? Jul 14, 2015 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.