Teensy 3.5 & XBee Pro 900HP Communication Issues

Status
Not open for further replies.

Asu

New member
I am currently having problems with communication with the Teensy 3.5 using the XBee Pro 900HP. It communicates fine one way, from XCTU to the Teensy. However, I am not able to send commands back the other way, from the Teensy to XCTU. How do I get the Teensy to send data to the XBee to transmit? Below is my code:

Code:
#define XBee Serial3

void setup()
{ 
  // Set up both ports at 115200 baud. This value is most important
  // for the XBee. Make sure the baud rate matches the config
  // setting of your XBee.
  XBee.begin(115200);
  Serial.begin(115200);
}
int incomingByte;
int data =0;
void loop()
{
//  if (Serial.available()) { // If data comes in from monitor, send it out to XBee
//    incomingByte = Serial.read();
//    Serial.write(incomingByte);
//    XBee.write(incomingByte);
//  }
//  if (XBee.available())
//  { // If data comes in from XBee, send it out to serial monitor
//    incomingByte = XBee.read();
//    Serial.write(incomingByte);
//    if(incomingByte == 114) { //'r' = 114
//      Serial.println("Command Recieved");
//      XBee.print("Fuck this shit");
//    }
//  }
if(Serial.available())
  {
    Serial3.write(Serial.read());
  }

  // Take data received from the HW UART and pass it to the serial monitor
  if(Serial3.available())
  {
    Serial.write(Serial3.read());
  }

  //Wait to reduce serial load
  delay(5);
}
 
I actually did not. The code for sending back to the XBee is this:

Code:
  if(Serial3.available())
  {
    Serial.write(Serial3.read());
  }

The XBee.available is equivalent to Serial3.available. What is commented out was just a test. Below is the same code with minor changes to remove the part that confused you.

Code:
#define XBee Serial3

void setup()
{ 
  // Set up both ports at 115200 baud. This value is most important
  // for the XBee. Make sure the baud rate matches the config
  // setting of your XBee.
  XBee.begin(115200);
  Serial.begin(115200);
}
int incomingByte;
int data =0;
void loop()
{
if(Serial.available())
  {
    XBee.write(Serial.read());
  }

  // Take data received from the HW UART and pass it to the serial monitor
  if(XBee.available())
  {
    Serial.write(XBee.read());
  }

  //Wait to reduce serial load
  delay(5);
}
 
Status
Not open for further replies.
Back
Top