X-bee digimesh communication

Hi,
I set up a 3 node network in digimesh.
I set up one as a router and other two as end device.
I connected all the three radios to the computer through usb explorer and from the X-CTU console I found they are all able to communicate bidirectionally.
But when I connected these three x-bee radios to arduino using x-bee sheild,the communication is not happening.
I loaded the following program in arduino with xbee radio configured as router which sends 'H' and 'L' alternatively.

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

void loop()
{
  Serial.print('H');
  delay(1000);
  Serial.print('L');
  delay(1000);
}

This is the program at the other two receiver ends of the arduino.

byte byteRead;
void setup() {                
// Turn the Serial Protocol ON

  Serial.begin(9600);
}

void loop() {
   /*  check if data has been sent from the computer: */
  if (Serial.available()) {
    /* read the most recent byte */
    byteRead = Serial.read();
    Serial.print("msg received");
    Serial.write(byteRead);
  }
}

When I connected other two receivers using USB explorer and checked their console in X-CTU. I found that they are receiving the 'H' and 'L' properly.So I guess there is some problem only when I interface with arduino. Can someone help me in this?

Hi,
I think I found the issue, I named the router which transmits 'H' and 'L' as '1' and other two receivers as '2' and '3' .
Its because since there is a command in the two receivers '2' and '3'

Serial.print(''msg received");

the second receiver instead of getting the data from transmitter,it receives the 3rd receiver output msg received serially and it outputs msg received serially into the serial monitor.

When i had only one receiver and one transmitter, the communication was happening smoothly. So i guess the issue is with interference between two receivers.

so I changed the code in the sender to send with an identification mark say '1' and wrote the program in the receiver so that it displays only data which it got with identification mark '1'.
here is the program at the sender

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

void loop()
{
  Serial.print('1');
  Serial.print('H');
  delay(1000);
  Serial.print('1');
  Serial.print('L');
  delay(1000);
}

the code at the receiver

byte byteRead;
void setup() {                
// Turn the Serial Protocol ON

  Serial.begin(9600);
}

void loop() {
   /*  check if data has been sent from the computer: */
  if (Serial.available()==2) {
    /* read the most recent byte */
    if(Serial.read()==1)
    {
    byteRead = Serial.read();
    Serial.write(byteRead);
  }
  }
}

But i didnt get any output from the receiver serial monitor. Can someone help me with the code to selectively display only data from particular node say '1'
Also I want the node '1 ' to receive data from other two nodes and display them in serial monitor also.Any help on this front will be appreciated.

Hi, which version of the xbee radios do you have? 1 or 2? Is there a special reason why you use digimesh instead of the ZigBee Protocol?

I only use the ZigBee protocol so i cannot help with the digimesh, but at ZigBee you need to define the sender and receiver mac address correctly to communicate. Is this the same with digimesh?

By the way, i wrote a short library to communicate with two serial ports on an arduino. Please have a look at GitHub - solick/twoSerialComm: Library for working with two serial lines on arduino (e.g. hardware serial and XBee Software serial) maybe it can be of any help.

Kind regards

Solick

Hi,
I did it with digimesh since I considered it easy to implement compared to zigbee. In digimesh one node is set up as router and other two nodes as end device.
I am able to communicate between three nodes bidirectionally which I checked with X-CTU.
Now I need to know how to program to take the serially communicated data and display in serial monitor when they are connected with Arduino. Each node must be able to send and receive data from other two nodes and able to identify from which node it came and display the received data in serial monitor.

Hi You need to address your nodes. There are apis you can use. Or you build your own frame (only hex strings).

Maybe you have a look into that guide: Docs - Waspmote

I am able to communicate between all the three nodes. They are all able to transmit,receive and also display the received information in the serial monitor.

code at node A

char incomingByte; //a variable to read data
char add;// a variable to read identifier 
char b;//variable to read identifier
void setup() {
  // initialize serial communication:
  Serial.begin(9600);
  
}

void loop() {
  Serial.write('A'); //sends identifier A for node A
  Serial.write('5'); //data from node A
  delay(5000);
  // see if there's incoming serial data:
  if (Serial.available()>1) {
   add=Serial.read();
   // Serial.write(add);
    
//if identifier is B, read the data and display that
    if (add=='B')
    {
      //Serial.println("second node");
    incomingByte = Serial.read();
    Serial.write(incomingByte);
     }
//if identifier is c, read the data and display that
     if (add=='C')
     {
       //Serial.println("third node");
       b=Serial.read();
       Serial.write(b);
     }
//read the data if identifier doesnt match with B or C
     else 
     {
       b=Serial.read();
     }
}
}

char incomingByte; //a variable to read data
char add;// a variable to read identifier
char b;
void setup() {
// initialize serial communication:
Serial.begin(9600);
// Serial.println("welcome");
}

code at node B

void loop() {
  Serial.write('B');
  Serial.write('8');
  delay(5000);
  // see if there's incoming serial data:
  if (Serial.available()>1) {
    //Serial.println("start");
    add=Serial.read();
    //Serial.write(add);
    if (add=='A')
    {
      //Serial.println("first node");
    incomingByte = Serial.read();
    Serial.write(incomingByte);
     }
     if (add=='C')
     {
       //Serial.println("third node");
       b=Serial.read();
       Serial.write(b);
     }
     else 
     {
       b=Serial.read();
     }
}
}

code at node C

char incomingByte; //a variable to read data
char add;// a variable to read identifier 
char b;
void setup() {
  // initialize serial communication:
  Serial.begin(9600);
  // Serial.println("welcome");
}

void loop() {
  Serial.write('C');
  Serial.write('9');
  delay(10000);
  // see if there's incoming serial data:
  if (Serial.available()>1) {
    //Serial.println("start");
    add=Serial.read();
    //Serial.write(add);
    
//if identifier is 1,print the received data
    if (add=='A')
    {
     // Serial.println("first node");
    incomingByte = Serial.read();
    Serial.write(incomingByte);
     }
     if (add=='B')
     {
      // Serial.println("second node");
       b=Serial.read();
       Serial.write(b);
     }
     else 
     {
       b=Serial.read();
     }
}
}

But there is no consistency.Initially I am getting the other node data in the serial monitor but as time goes I am getting only the corresponding node transmit data say., A5 for node A and B8 for node B.I think the problem is that as I am using the same serial for both wireless communication and serial monitor communication. or does it have anything to do with delay I have introduced in the program?..Kindly help.I couldn't sort out the issue and my project is due for submission this month :frowning: