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);
}