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

Thread: teensy 3.2 + software serial

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

    teensy 3.2 + software serial

    Hello Guys,

    right now I am working on a project with a teensy 3.2.
    I want to transmit data wirelessly to the teensy. The Teensy reads the incoming data on serial1. I then want to control 9 different devices via rs232 and rs485. The teensy is acting like a distributor here.

    I already started with the the project but only now I noticed that the teensy won't read incoming data on software serial ports.
    Is there any way to get the teensy to read the incoming bytes from the other serials? It is not a problem for me that i can only read 1 port at a time. The other devices only transmit data when they are requested.

    Any ideas to get the software ports to read the incoming bytes?

    Best regards...

  2. #2
    Senior Member
    Join Date
    Nov 2015
    Location
    Wales
    Posts
    579
    I'm not 100% sure what you're asking but do you mean:
    Code:
    Serial1.read();

    Here is a block of code that copies the USB interface serial to the Serial1 output on the Teensy:
    Code:
    // set this to the hardware serial port you wish to use
    #define HWSERIAL Serial1
    
    void setup() {
      Serial.begin(4000000);
      HWSERIAL.begin(4000000);
    }
    
    void loop() {
      char incomingByte;
            
      if (Serial.available() > 0) {
        incomingByte = Serial.read();
        HWSERIAL.print(incomingByte);
      }
    
    }

  3. #3
    Junior Member
    Join Date
    Jan 2016
    Posts
    2
    I am going to give you more detail about what I want to do:

    So I want to send data to the teensy over serial. The teensy receives the data on hardware serial port 1.
    Depending on the data that have been sent to the teensy, it will send a correspondent command or status request to one of the other 9 devices that are connected to the teensy via the 2 other hardware serial ports and 7 software serial ports.
    The problem now is that the teensy can only read data on the hardware serial ports. The software serial ports are not able to read data on the teensy. The software serial library does not work on the teensy 3.2 board. It can ony send but not read data.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,651
    On Teensy 3.2, you get 3 real hardware serial ports. You can get 1 more by software using AltSoftSerial.

    The SoftwareSerial library on Teensy 3.2 is just a compatibility wrapper. It only works if using 2 pins for a real hardware serial port.

    That's it. 4 is the limit. Well, until someone writes another software serial library.... (which I've actually considered, but haven't done)

  5. #5
    Senior Member
    Join Date
    Nov 2015
    Location
    Wales
    Posts
    579
    You could just stick all the Teensy's on the same Serial line.
    Then just transmit an address byte followed by what you wish to send. Basically I2C

Posting Permissions

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