XBee Wireless Communication Serial Not Transmitting

Hi everyone,

I am new on the forum, and apologise if my format for posting is not up to standard.

I am working on a project with two separate Arduino Mega 2560 boards, and am trying to communicate sensor data gathered from one Arduino to the other (let's call them XBee 1 sending to XBee 2).

My sensor data is gathered just fine, and appears to be transmitted properly as well, with XBee 2 sending a successful response to XBee 1 upon transmission. However, XBee 2 seems to not send the data that was received to my Arduino. The Serial.read() command comes up as -1 (no data), and getresponse().isAvailable() comes up as false.

Here is a sample of my receiving code:

void receive(int *temp_value, int *keypad)
{
  xbee.readPacket();
  if (xbee.getResponse().isAvailable())
 {
    Serial.println("Available");
   if (xbee.getResponse().getApiId() == ZB_RX_RESPONSE) 
    {
      Serial.println("Data Received");    
      xbee.getResponse().getZBRxResponse(rx);
      int tvalue = rx.getData(0) << 8 | rx.getData(1);
      int kvalue = rx.getData(2) << 8 | rx.getData(3);
      *keypad = kvalue - 48;
      *temp_value = tvalue & 0x2fff;
    }
  }
  else
  {
    Serial.println("Not Available");    
  } 
}

And a sample of my transmission code:

void transmit (int tempvalue, int keyvalue) {
    //payload for key press
    payload[0] = keyvalue >> 8 & 0xff;
    payload[1] = keyvalue & 0xff;

    //payload for temperature reading
    payload[2] = (tempvalue >> 8 & 0xff) | 0x40;
    payload[3] = tempvalue & 0xff;

  xbee.send(zbTx);
  Serial.println(tempvalue);
  if (xbee.readPacket(500)) 
  {
    if (xbee.getResponse().getApiId() == ZB_TX_STATUS_RESPONSE) 
    {
      xbee.getResponse().getZBTxStatusResponse(txStatus);
      Serial.println("Transmission Successful");   
    }
  } else Serial.println("XBee did not provide a timely TX status response");
}

If I plug XBee 2 directly into my computer, using XCTU, I am able to read the sent packets without a problem.

I have searched around the forums as well as on other websites, but seem to come up short, though I think that may be due to my lack of google-fu.

Thank you very much for your help! If there is anything that anyone needs from me, I would be happy to provide.