ArduinoGeneral

Xbee Series 2 not receiving on arduino mega + Mega Sensor Shield V2.4

userHead cookieboyz 2015-01-14 01:00:02 3965 Views3 Replies
Hi all, Im hoping to get some help on wireless communication. I basically just want to do a simple transparent communication on AT mode. Ive ensured that both Xbees were on the same PAN IDs and ive double checked their address to be correct. That was pretty much what i changed on the setups of the Xbees.

Coordinator AT
Xbee Series 2 on a USB sparkfun explorer, connected to computer

Router AT
Xbee Series 2 on a DFrobot Mega Sensor shield V2.4 connected on top of an Arduino Mega R3. I believed ive placed the Xbee S2 on the serial1 location

Problem: On the XCTU terminal, whenever i type 1. "1" is printed twice like this "11" on the terminal. same for any other characters "22", "33" etc. Nothing comes on the receiving end at the arduino. The green light ( Assoc2) light on the sensor shield is blinking when its being plugged into power( i believe this is good).
Anyone had this problem before or could spot the silly mistakes im making? Its really frustrating me and halting any progress i was hoping to make on my wireless robot project. Would appreciate any help. Thanks in advance.

int incomingData = 0;
int const ledpin = 13;

void setup(){
// Start up our serial port, we configured our XBEE devices for 9600 bps.
Serial1.begin(9600);
pinMode(ledpin, OUTPUT);
}

void loop()
{
if(Serial1.available() > 0)
{
digitalWrite(ledpin, HIGH);
incomingData = Serial1.read();

if(incomingData == '1')
digitalWrite(ledpin, HIGH);

else if(incomingData == '2')
digitalWrite(ledpin, LOW);
}
}
2015-01-14 21:38:00 OK, managed to fix the problem. Just to share with anyone else facing issues like that. I made a really stupid mistake.

Destination DH and Destination DL address.... I went to input the xbee's own address. hence it was only communicating with itself. That explains the double "11"s on the screen when i press 1. Happy to move on my project and thanks Grey for replying to the post!
userHeadPic cookieboyz
2015-01-14 20:10:33 Hi Grey,

Thanks for the reply. I tried your code. Doesnt work. Nothing's happening.

Steps I take to upload code:
plug out Xbee on the xbee shield, then upload the code, followed by placing the xbee back on to the shield. Now im beggining to doubt if the two xbees are even communicating. How do i verify this. I only have one computer, and one usb xbee explorer for coordinator AT
userHeadPic cookieboyz
2015-01-14 05:39:01 Hello,

Try this code on the mega Serial1 port. it will print what it received in the serial monitor.
[code]void setup()

  Serial.begin(9600);
  Serial1.begin(9600);
}

void loop()

  if(Serial1.available()>0)
  {
    char inbyte=Serial1.read();
    Serial.print(inbyte);
  }
}
[/code]
userHeadPic Grey.CC