Teensy 3.2 Won't Receive Serial Data Through RX Pins

Status
Not open for further replies.

Haybur

Active member
Hi all,

I've been building LED stuff for ~4 years with Teensys and I'm stumped with this problem. My LED projects include an ESP32 that hosts a webserver control panel and when you click a button on your phone, the ESP32 sends a serial message from its TX2 pin to the Teensy's RX1 pin. I have had this system working flawlessly for a couple years now.

My new project requires a flatter PCB design so the Teensy and ESP32 are now soldered to it instead of mounting onto female header sockets like I usually do. Because they're soldered on, I don't think I can remove them to try new microcontrollers on this specific PCB. I have desoldering wick but I've never been able to get it to remove 100% of the solder. Also yes, I placed the Teensy too close to the audio adapter... Have to fix that on my next revision.
Here's a pic: pcb_layout.jpg

I've confirmed with a voltmeter that the Teensy's RX1 pin (pin 0) and the ESP32's TX2 pin have a resistance of less than 1 ohm, so they're connected.

Teensy code
Code:
void setup() {
  Serial.begin(115200);
  Serial1.begin(115200);
}

void loop() {
  // If serial1 data is availble, print it.
  while (Serial1.available()) {
    char x = Serial1.read();
    Serial.println(x);
  }
}

ESP32 code
Code:
void setup() {
  Serial2.begin(115200);
}
void loop() {
  Serial2.write('a');
  delay(2000);
}

The Problem
The Teensy 3.2 in the picture above is not receiving the serial data ('a'). What's strange is that the Teensy 3.2 in the picture is able to do everything else I ask of it, like it receives audio data from the audio adapter and drives 968 WS2812b LEDs with no issues. It just won't receive serial data.

Things I've Tried
I simplified my code to just include this serial communication.
I've uploaded this exact code to my default Teensy3.2 + ESP32 PCB and it works as expected.
I've used jumper cables to:
  • connect the pictured ESP32's TX2 pin to other RX pins on the pictured Teensy (RX2 and RX3) but that didn't work either.
  • connect the pictured ESP32's TX2 pin to other Teensy boards and I've confirmed it is sending serial data.
  • connect a different ESP32 that was confirmed to be sending serial data to the pictured Teensy and it still didn't receive anything.


My next step is to solder a new PCB together and test it again, I'm just trying not to throw away another Teensy and ESP32 since they're soldered on and I can't remove them.

Does anyone know what could be going on? Is there any way I can fix the Teensy? Thanks for reading!
 
If you want to remove the Teensy, or the ESP, take a pair of snips and gently cut the headers, pin by pin.
Then when it is away from the PCB de-solder/remove each pin in turn.
Attempting to remove a multipin device simply by solder sucking is virtually impossible, just a little bit of solder will be left on multiple pins and it just will not come apart.

EDIT: Have you tried to see if there is a short RX to TX?
 
No short between Tx and Rx, good idea though. I'll try to get some snips in there but it's a tight fit
 
With some issues like this, I sometimes use a simple ring out program that @defragster and myself did:

Which we called the HiLowTest.ino
Code:
void setup() {
  Serial.begin(115200);
  while (!Serial && millis() < 4000 );
  Serial.println("Compile Time:: " __FILE__ " " __DATE__ " " __TIME__);
  Serial.printf("Num Digital Pins: %d\n", NUM_DIGITAL_PINS);

  testForShorts();
  
}

uint32_t cnt = 0;
void loop() {
  cnt++;
    allPinTest( cnt );
}

uint32_t pinLast[NUM_DIGITAL_PINS];
void allPinTest( uint32_t cnt ) {
  uint32_t ii, SET;
  Serial.print("PULLDOWN Start Vals:\n  ");
  SET = 0;
  Serial.print("PULLDOWN :: TEST to 3.3V\n  ");
  for ( ii = 0; ii < NUM_DIGITAL_PINS; ii++) {
    pinMode( ii, INPUT_PULLDOWN );
    delayMicroseconds( 5 );
    pinLast[ii] = digitalReadFast( ii );
    if (pinLast[ii]) {
      Serial.print("\nd#=");
      Serial.print( ii );
      Serial.print( " val=" );
    }
    Serial.print( pinLast[ii] );
    Serial.print(',');
  }
  Serial.println();
  Serial.println();
  while ( 1 ) {
    uint32_t jj, dd = 0, cc = 0, ee=4;
    cc = 0;
    for ( ii = 0; ii < NUM_DIGITAL_PINS; ii++) {
      jj = digitalReadFast( ii );
      if ( jj != pinLast[ii] ) {
        dd = 1;
        cc++;
        pinLast[ii] = jj;
        Serial.print("d#=");
        Serial.print( ii );
        if ( pinLast[ii] ) Serial.print( "\t" );
        Serial.print( " val=" );
        Serial.print( pinLast[ii] );
        Serial.print(',');
      }
      if ( cc > 1 && ee ) {
        Serial.println(">>> MULTI CHANGE !!");
        ee--;
      }
      if ( Serial.available() ) {
        while ( Serial.available() ) Serial.read();
        if ( 0 == SET ) {
          SET = 1;
          Serial.print("PULLUP :: TEST TO GND\n  ");
        }
        else {
          SET = 0;
          Serial.print("PULLDOWN :: TEST to 3.3V\n  ");
        }
        for ( ii = 0; ii < NUM_DIGITAL_PINS; ii++) {
          if ( 0 == SET )
            pinMode( ii, INPUT_PULLDOWN );
          else
            pinMode( ii, INPUT_PULLUP );
          delayMicroseconds( 20 );
          pinLast[ii] = digitalReadFast( ii );
          if (SET != pinLast[ii]) {
            Serial.print("d#=");
            Serial.print( ii );
            Serial.print( " val=" );
            Serial.println( pinLast[ii] );
          }
        }
      }
    }
    if ( dd ) {
      dd = 0;
      Serial.println();
      delay( 50 );
    }
  }
}

void testForShorts() {
  uint32_t ii;
  Serial.print("Quick Test for Shorts to adjacent pin");
  Serial.println("First pull pins down and see if the next one follows");
  for ( ii = 0; ii < NUM_DIGITAL_PINS-1; ii++) {
    pinMode( ii+1, INPUT_PULLDOWN );
    pinMode( ii, OUTPUT);
    digitalWrite(ii, HIGH);
    delayMicroseconds( 5 );
    if (digitalRead(ii+1)) {
      Serial.printf("%d:%d ", ii, ii+1);
    }
  }
  Serial.println("\n Now try Pull up and see if setting low follow");
  for ( ii = 0; ii < NUM_DIGITAL_PINS-1; ii++) {
    pinMode( ii+1, INPUT_PULLUP );
    pinMode( ii, OUTPUT);
    digitalWrite(ii, LOW);
    delayMicroseconds( 5 );
    if (!digitalRead(ii+1)) {
      Serial.printf("%d:%d ", ii, ii+1);
    }
  }
  Serial.println();  
}

It is setup to allow you to either use jumper from GND or 3.3v (by hitting enter key you can alternate which one) and then touch different IO pins and it will tell if a connection is made and which pin.
If multiple pins show up, sign of short. If your pin does not show up, maybe bad solder...

The other thing I would try include, use a meter of some type, and verify that you have a connection from RX of Teensy to TX of ESP and likewise TX to RX, and that you have a common ground.

I would also try to verify that the ESP32 is actually outputting...
 
Thanks for the response Kurt! I have confirmed with a meter that the ESP32's TX and the Teensy's RX are connected with a common ground. I've also connected the ESP32's TX pin with a different Teensy 3.2 and it receives data through serial, so it is outputting data.

I uploaded your test code and have done some poking around. When I use a jumper from 3.3v, all the pins work except for 0, 18, and 19. When I use a jumper from GND, all the pins work except 0, and 13. None are shorted. Looks like the 18, 19, and 13 not working are expected?

I also just re-melted the solder on the top of pin 0 to see if that'd fix anything but it didn't.

Since my projects use FastLED and the Audio Adapter, I've been using serial1 because pins 0 and 1 don't interfere with the other ones being used. It looks like I might be able to use serial4 but when I go to compile, I get these errors:
Code:
C:\Users\Dan\AppData\Local\Temp\arduino_build_191721\sketch\New_Visualizer_Teensy.ino.cpp.o: In function `HardwareSerial4::available()':
C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/HardwareSerial.h:398: undefined reference to `serial4_available'
C:\Users\Dan\AppData\Local\Temp\arduino_build_191721\sketch\New_Visualizer_Teensy.ino.cpp.o: In function `HardwareSerial4::read()':
C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/HardwareSerial.h:400: undefined reference to `serial4_getchar'
C:\Users\Dan\AppData\Local\Temp\arduino_build_191721\sketch\New_Visualizer_Teensy.ino.cpp.o: In function `setup':
C:\Users\Dan\Documents\Arduino\New_Visualizer_Teensy/New_Visualizer_Teensy.ino:75: undefined reference to `HardwareSerial4::begin(unsigned long)'
C:\Users\Dan\AppData\Local\Temp\arduino_build_191721\sketch\New_Visualizer_Teensy.ino.cpp.o: In function `CLEDController::CLEDController()':
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\FastLED/controller.h:67: undefined reference to `Serial4'
collect2.exe: error: ld returned 1 exit status
Error compiling for board Teensy 3.2 / 3.1.
 
What pins are you trying to connect to? I don't believe Teensy 3.2 has Serial4
I know in the T3.x code base part, only T3.5/6 have Serial4
 
Also maybe for the fun of it try changing the Teensy code to:
Code:
void setup() {
  Serial.begin(115200);
  Serial1.begin(115200);
}

void loop() {
  // If serial1 data is availble, print it.
   int ch; 
   while ((ch = Serial1.read) != -1) {
    Serial.println(ch);
  }
}

And see if anything comes out...
 
Status
Not open for further replies.
Back
Top