Teensy 3.6 won't communicate with Raspberri Pi Serial

nd456

New member
Hi All,

I have a Teensy 4.0 and Teensy 3.6 to connect to a Raspberry Pi 3B+ (Running a fresh copy of Raspberry Pi OS) and use the python serial library to read the data.
I use the same sketch and code for the Teensy 3.6 and Teensy 4.0, the Teensy 4.0 works fine and reliably to read the serial data on the Raspberry Pi but the Teensy 3.6 won't print anything to the Raspberry Pi.
I have connected to a windows computer and the Teensy 3.6 and Teensy 4.0 both print correctly using the Teensy port and standard com port on the windows computer through the Arduino IDE.
I installed the Arduino IDE onto the Raspberry Pi and I get the serial messages for the Teensy 4.0 but not for the Teensy 3.6, making me think there is some kind of serial problem with the Teensy 3.6 to the Raspberry Pi.
I also tried a Arduino Uno and it works fine on the Raspberry Pi as well. The only issue I have is with the Teensy 3.6.

I did have the Teensy setup for "Dual Serial" and changed it back to "Serial". Could this have caused the issues with the Teensy communicating with the Raspberry Pi?
I need to use the Teensy 3.6 for the enhanced i2c_t3 library.

Teensy Code:
Code:
void setup() {
  Serial.begin(115200);
}
void loop() {
  Serial.println("Hello from Teensy!");
  delay(100);
  Serial.println(1);
  Serial.println(2);
  Serial.println(3);
  Serial.println(4);
  delay(100);
}

Python Code (Change between ttyACM0 and ttyACM1 to match result from dmesg | grep tty)
Code:
import time
import serial
from serial.tools import list_ports

print("Script Started")

ser= serial.Serial('/dev/ttyACM0', 115200, timeout=1)
data=0

while True:
    if ser.in_waiting >0:
        data=ser.readline().decode('utf-8').rstrip()
        print(data)
 
I have not used a T3.6 with RPI in awhile, but it always used to work for me. Although I typically never used Python.

It might help to see more debug data here.

Usually when I had issues, I would look at the data like you mentioned for dmesg
Often I will print out stuff like: Here is a quick run on RPI4 with T3.6
Code:
pi@RPI4LSS:~ $ lsusb
Bus 002 Device 002: ID 174c:55aa ASMedia Technology Inc. Name: ASM1051E SATA 6Gb/s bridge, ASM1053E SATA 6Gb/s bridge, ASM1153 SATA 3Gb/s bridge, ASM1153E SATA 6Gb/s bridge
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 04ca:0027 Lite-On Technology Corp.
Bus 001 Device 003: ID 046d:c063 Logitech, Inc. DELL Laser Mouse
Bus 001 Device 005: ID 16c0:0483 Van Ooijen Technische Informatica Teensyduino Serial
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
pi@RPI4LSS:~ $ lsusb -v -d 16c0:0483

Bus 001 Device 005: ID 16c0:0483 Van Ooijen Technische Informatica Teensyduino Serial
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            2 Communications
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x16c0 Van Ooijen Technische Informatica
  idProduct          0x0483 Teensyduino Serial
  bcdDevice            2.77
  iManufacturer           1 Teensyduino
  iProduct                2 USB Serial
  iSerial                 3 2416110
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0043
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0xc0
      Self Powered
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         2 Communications
      bInterfaceSubClass      2 Abstract (modem)
      bInterfaceProtocol      1 AT-commands (v.25ter)
      iInterface              0
      CDC Header:
        bcdCDC               1.10
      CDC Call Management:
        bmCapabilities       0x01
          call management
        bDataInterface          1
      CDC ACM:
        bmCapabilities       0x06
          sends break
          line coding and serial state
      CDC Union:
        bMasterInterface        0
        bSlaveInterface         1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0010  1x 16 bytes
        bInterval              64
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass        10 CDC Data
      bInterfaceSubClass      0
      bInterfaceProtocol      0
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x03  EP 3 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x84  EP 4 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0000
  (Bus Powered)
pi@RPI4LSS:~ $ ls /dev/ttyA*
/dev/ttyACM0  /dev/ttyAMA0
pi@RPI4LSS:~ $ ls /dev/ttyA*
/dev/ttyACM0  /dev/ttyAMA0
pi@RPI4LSS:~ $ dmesg | tail -40
[    9.285651] bcmgenet fd580000.ethernet: configuring instance for external RGMII
[    9.285935] bcmgenet fd580000.ethernet eth0: Link is Down
[   10.219581] broken atomic modeset userspace detected, disabling atomic
[   10.832857] broken atomic modeset userspace detected, disabling atomic
[   11.855951] broken atomic modeset userspace detected, disabling atomic
[   12.444283] broken atomic modeset userspace detected, disabling atomic
[   13.468780] broken atomic modeset userspace detected, disabling atomic
[   14.052423] broken atomic modeset userspace detected, disabling atomic
[   14.716378] Bluetooth: Core ver 2.22
[   14.716417] NET: Registered protocol family 31
[   14.716422] Bluetooth: HCI device and connection manager initialized
[   14.716434] Bluetooth: HCI socket layer initialized
[   14.716442] Bluetooth: L2CAP socket layer initialized
[   14.716455] Bluetooth: SCO socket layer initialized
[   14.719966] Bluetooth: HCI UART driver ver 2.3
[   14.719975] Bluetooth: HCI UART protocol H4 registered
[   14.720011] Bluetooth: HCI UART protocol Three-wire (H5) registered
[   14.720164] Bluetooth: HCI UART protocol Broadcom registered
[   14.835687] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[   14.835701] Bluetooth: BNEP filters: protocol multicast
[   14.835738] Bluetooth: BNEP socket layer initialized
[   14.875335] Bluetooth: RFCOMM TTY layer initialized
[   14.875350] Bluetooth: RFCOMM socket layer initialized
[   14.875364] Bluetooth: RFCOMM ver 1.11
[   14.983238] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[   15.119348] broken atomic modeset userspace detected, disabling atomic
[   15.675851] broken atomic modeset userspace detected, disabling atomic
[   16.709949] broken atomic modeset userspace detected, disabling atomic
[   17.297729] broken atomic modeset userspace detected, disabling atomic
[   31.831566] vcc-sd: disabling
[   71.168900] ICMPv6: process `dhcpcd' is using deprecated sysctl (syscall) net.ipv6.neigh.wlan0.retrans_time - use net.ipv6.neigh.wlan0.retrans_time_ms instead
[  456.458382] usb 1-1.2: new full-speed USB device number 5 using xhci_hcd
[  456.593831] usb 1-1.2: New USB device found, idVendor=16c0, idProduct=0483, bcdDevice= 2.77
[  456.593849] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  456.593865] usb 1-1.2: Product: USB Serial
[  456.593879] usb 1-1.2: Manufacturer: Teensyduino
[  456.593893] usb 1-1.2: SerialNumber: 2416110
[  456.635197] cdc_acm 1-1.2:1.0: ttyACM0: USB ACM device
[  456.637543] usbcore: registered new interface driver cdc_acm
[  456.637556] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
pi@RPI4LSS:~ $
Note If I do:
Code:
pi@RPI4LSS:~ $ cat /dev/ttyACM0
ILI9488 Test!
You see that it output one line of text ... I know not overly conclusive, but without seeing additional information, not sure what else to tell you.

Since you said T4 worked I assume you installed the udev rules as mentioned in the installation instructions for Teensyduino.
 
Didn't hit post before walking away - KurtE's attention may lead to solution - was going to note:

Try adding this to setup before printing: while (!Serial && millis() < 4000 );

Assuming the T_3.6 properly compiles with USB Type Serial selected - then finding the right port ... That will prevent the USB - for 4 seconds - from getting a barrage of prints before the rPi connects.
 
I did not have the udev rules installed.
I installed them and nothing changed. It 's interesting that if I reboot the RPI and connect, the first time the script runs with the Teensy 3.6, the loop prints out once but then won't print anymore (as if it was stored in a buffer).

I added in the "while (!Serial && millis() < 4000 );" into the Arduino setup and get the same results.

Here are the lsusb command results:
Code:
pi@raspberrypi:~ $ lsusb
Bus 001 Device 009: ID 16c0:0483 Van Ooijen Technische Informatica Teensyduino Serial
Bus 001 Device 005: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 001 Device 006: ID 0424:7800 Standard Microsystems Corp. 
Bus 001 Device 003: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

pi@raspberrypi:~ $ lsusb -v -d 16c0:0483
Bus 001 Device 009: ID 16c0:0483 Van Ooijen Technische Informatica Teensyduino Serial
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            2 Communications
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x16c0 Van Ooijen Technische Informatica
  idProduct          0x0483 Teensyduino Serial
  bcdDevice            2.77
  iManufacturer           1 Teensyduino
  iProduct                2 USB Serial
  iSerial                 3 7183300
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0043
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xc0
      Self Powered
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         2 Communications
      bInterfaceSubClass      2 Abstract (modem)
      bInterfaceProtocol      1 AT-commands (v.25ter)
      iInterface              0 
      CDC Header:
        bcdCDC               1.10
      CDC Call Management:
        bmCapabilities       0x01
          call management
        bDataInterface          1
      CDC ACM:
        bmCapabilities       0x06
          sends break
          line coding and serial state
      CDC Union:
        bMasterInterface        0
        bSlaveInterface         1 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0010  1x 16 bytes
        bInterval              64
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass        10 CDC Data
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x03  EP 3 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x84  EP 4 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0000
  (Bus Powered)

To compare to yours, it looks like the only difference is in the "Device 009 vs Device 005" and "iSerial 3 2416110 vs iSerial 3 7183300".
 
As far as I can tell it is working fine for me.

I ran your script on my RPI4 on a sketch slightly modified from yours:
Code:
void setup() {
  // put your setup code here, to run once:
  while (!Serial && millis() < 5000) ;
  Serial.begin(115200);

}
uint32_t count = 0;
void loop() {
  // put your main code here, to run repeatedly:
  Serial.println(count++);
  Serial.println(count++);
  Serial.println(count++);
  Serial.println(count++);
  delay(100);

}
So that I could see if it continued or not...
Here is about the 5th run of your script:
Code:
pi@RPI4LSS:~ $ python test.py
Script Started
19052
19053
19054
19055
19056
19057
19058
19059
19060
19061
19062
19063
19064
19065
19066
19067
19068
19069
19070
19071
19072
19073
19074
19075
19076
19077
19078
19079
19080
19081
19082
19083
19084
19085
19086
19087
19088
19089
19090
19091
46240
46241
46242
46243
46244
46245
46246
46247
46248
46249
46250
46251
46252
46253
46254
46255
46256
46257
46258
46259
46260
46261
46262
46263
46264
46265
46266
46267
^CTraceback (most recent call last):
  File "test.py", line 11, in <module>
    if ser.in_waiting >0:
  File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 467, in in_waiting
    s = fcntl.ioctl(self.fd, TIOCINQ, TIOCM_zero_str)
KeyboardInterrupt
pi@RPI4LSS:~ $
Some other things I would look at include:
Code:
pi@RPI4LSS:~ $ ls -l /dev/ttyA*
crw-rw-rw- 1 root dialout 166,  0 Jul 22 08:43 /dev/ttyACM0
crw-rw---- 1 root dialout 204, 64 Jul 22 08:28 /dev/ttyAMA0
pi@RPI4LSS:~ $ groups
pi adm dialout cdrom sudo audio video plugdev games users input netdev gpio i2c spi
pi@RPI4LSS:~ $
Which the udev rules should have mostly handled anyway...
But it shows that the ACM0 is in the dialout group. Also shows that my user (pi) is a member of the dialout group.

But again warning I am not the biggest linux expert here. hopefully someone else will have some more suggestions.

But if it is not working for you, it runs once and but not again, would wonder if maybe file (device) being left open?

Not sure of best way to see if it is or not. My first guess at this may be something like:
Code:
pi@RPI4LSS:~ $ lsof | grep /dev/tty
bash       759                              pi    0u      CHR        4,1       0t0       1045 /dev/tty1
bash       759                              pi    1u      CHR        4,1       0t0       1045 /dev/tty1
bash       759                              pi    2u      CHR        4,1       0t0       1045 /dev/tty1
bash       759                              pi  255u      CHR        4,1       0t0       1045 /dev/tty1
python    2371                              pi    3u      CHR      166,0       0t0      26981 /dev/ttyACM0
 
I ran it here on a Teensy 3.6 connected to a Raspberry Pi 4. Seems to work fine.

screenshot.png

(fwiw, this screenshot is a window on my Ubuntu 20.04 PC desktop machine, remotely logged into the Pi)
 
Back
Top