0
votes

I'm trying to set up a wireless communication between a Computer (coordinator) and a Arduino Mega (router) using two xbees.

Here is the Coordinator configuration: ZIGBEE COORDINATOR AT Serial high:13A200 and serial low: 407B69E6

PAN ID: 1111
DH: 13A200
DL: 40813BFC (Rooter serial number low)
Baud Rate: 9600

Here is the Router Configuration: ZIGBEE ROUTER AT Serial high:13A200 and Serial low: 40813BFC

PAN ID: 1111
DH: 13A200
DL: 407B69E6 (Coordinator serial number low)
Baud Rate: 9600

I'm using the Xbee Explorer Regulated to connect the Xbee module to the board and the USB explorer board to connect the xbee to the computer. I'm able to communicate from the Arduino to the Computer. All data sent from the serial monitor of the Arduino IDE are received in the terminal window of XCTU. If I switch the modules I am still able to communicate.

Arduino Code

#include <SoftwareSerial.h>

uint8_t pinRx = 4 , pinTx = 2; // the pin on Arduino
long BaudRate = 9600;
char GotChar, getData;
SoftwareSerial xbee(pinRx, pinTx);

void setup() 
{
  Serial.begin(9600);
  Serial.println( "Welcome to the XBee Communication Test" );
  Serial.print("BaudRate:");
  Serial.println(BaudRate);
  Serial.print(" Rx Pin#");
  Serial.println(pinRx,DEC);
  Serial.print(" Tx Pin#");
  Serial.println(pinTx,DEC);
  xbee.begin( BaudRate );
  xbee.println("Setup Completed!");
}

void loop() 
{
  if (Serial.available()) 
  {
    GotChar = Serial.read();
    // Send it to Computer
    xbee.print(GotChar);
    // print it to serial monitor
    Serial.print(GotChar);
  }
  while (xbee.available()>0)
  {  
    //Serial.println("Ohohoh");
    getData = xbee.read();
    Serial.print(getData);
    // send it back
    xbee.println(getData);
  }
}

The problem

I can't send data from the computer to the arduino.

When I send a character from the computer using the XCTU terminal, the TX and the RSSI leds light up on the USB Explorer board. Same thing occurs on the Arduino, the DOUT and RSSI led light up and nothing is received. I have tried setting DH and DL to broadcast mode using 0 and FFFF as values for the coordinator but it didn't solve the problem.

2
Share your Arduino code. If the communication remains one-way when you swap XBee modules, the problem is in the hosts (either hardware or software). The fact that DOUT on the Arduino's XBee module flashes is an indication that the XBee is sending serial data to the Arduino, but it just isn't getting into your program.tomlogic
Ok, I've updated the question.UserK
Your code says 9600 baud but your XBee config says 57600 (but if you're sending OK, I'm guessing that's just a copy/paste error). Are you sure pinRx is correct? If you connect a serial cable to pins 2 and 4 of the Arduino, can you send data over it? Continue to work on isolating the problem until you identify all of the known good/working components of your setup. Note that setting DH and DL to 0 is a shortcut for indicating the coordinator, not for broadcast mode.tomlogic

2 Answers

1
votes

I tought that the problem was related to the wiring so I double checked the circuit I was using. Then as TomLogic suggested I tried to establish another serial communication using pin 12 and 13. And finally I got these two modules working properly!

The configurations for Coordinator and Router are correct and the Arduino code as well! Pin 4 can't be used with SoftwareSeria as RX.

Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69

0
votes

It's simply come from your baud rate, your Xbee communicate in 57600 baud and your arduino in 9600 baud. The fact is the Xbee read slower than you Arduino and vice-versa so there is a problem.

Solution, Try to put both the Xbee and the Arduino to 9600Baud.

Hope I have help you :)