Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Teensy 3.5 & XBee Pro 900HP Communication Issues

  1. #1
    Junior Member
    Join Date
    Jan 2020
    Posts
    2

    Teensy 3.5 & XBee Pro 900HP Communication Issues

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

  2. #2
    You've commented out all the code for sending back to the Xbee

  3. #3
    Junior Member
    Join Date
    Jan 2020
    Posts
    2
    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);
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •