Teensy 4.1 Serial (USB port)

danieltsz

Well-known member
Can serial data be read on Teensy's USB port without opening any serial terminal emulator?

I'm trying to interface an industrial datalogger (CR350) with Teensy 4.1. I'm trying to send data from CR350's USB port to Teensy's USB port. However, I cannot read any of the serial data coming from CR350. When I try to use Putty or Arduino's Serial monitor, I can read the output of the CR350 USB port.

Upon checking, I'm stuck in this part of my Teensy code

Code:
  while (!Serial) {
    digitalWrite(LED_DataLogger, HIGH);
  }

When using Arduino's serial monitor, this statement becomes false.

Is there a way to bypass the opening of the serial monitor so I can read any serial data in Teensy's USB port?
 
How exactly are you connecting the USB ports of the Teensy and CR350 together? I suspect they're both device ports, which can only be connected to host ports.
 
How exactly are you connecting the USB ports of the Teensy and CR350 together?
From CR350, I connected a Type-C cable going to the Micro-USB port of Teensy 4.1.

I suspect they're both device ports, which can only be connected to host ports.
To be honest with you, I don't have any idea about this 😥
 
CR350, I connected a Type-C cable
Does this same USB-C cable connect to a Host computer and work for data transfer?

If so, then the CR350 is acting as a Device - the same as the Teensy. This was the reference for p#2

The T_4.1 has pins for USB Host usage - but this would require writing the interface for the CR350 as a Device to connect and transfer.
 
Does this same USB-C cable connect to a Host computer and work for data transfer?

If so, then the CR350 is acting as a Device - the same as the Teensy. This was the reference for p#2
Yes, sir, it works with data transfer. Same as the micro USB cable.

The T_4.1 has pins for USB Host usage - but this would require writing the interface for the CR350 as a Device to connect and transfer.
If I understand this correctly, the only way for this to work is through CR350 right sir, and not in Teensy programming?
 
If I understand this correctly, the only way for this to work is through CR350 right sir, and not in Teensy programming?
No, it would be Teensy programming. Using the T_4.1 USB Host connection pins allow attaching a device to the Teensy.
For this to work the Teensy Host software needs to recognize and connect the device and then process the USB messages.
The device may work similar to an existing Serial device for transfer. Seems there may be an example of this, but to associate the device may take some discovery of the details.
 
A Forum search should find the threads for this library ...

From https://www.pjrc.com/store/teensy41.html
USB HostA second USB port operates in host mode, which allows you to connect USB devices to Teensy 4.1. It is fully independent of the main USB device port, so USB devices you connect on the host port can simultaneously communicate with Teensy while Teensy communicates with your computer via the USB device port. This USB host port runs at 480, 12 or 1.5 Mbit/sec, depending on the speed if the device you connect. USB hubs may be used to connect many USB devices. The USBHost_t36 library is used for the USB host port. This USB host cable is normally used to connect a USB device or hub.

To connect see: https://www.pjrc.com/store/cable_usb_host_t36.html

@PaulStoffregen : This points out a spelling typo: simultaeously
 
A Forum search should find the threads for this library ...

From https://www.pjrc.com/store/teensy41.html
USB HostA second USB port operates in host mode, which allows you to connect USB devices to Teensy 4.1. It is fully independent of the main USB device port, so USB devices you connect on the host port can simultaneously communicate with Teensy while Teensy communicates with your computer via the USB device port. This USB host port runs at 480, 12 or 1.5 Mbit/sec, depending on the speed if the device you connect. USB hubs may be used to connect many USB devices. The USBHost_t36 library is used for the USB host port. This USB host cable is normally used to connect a USB device or hub.

To connect see: https://www.pjrc.com/store/cable_usb_host_t36.html

@PaulStoffregen : This points out a spelling typo: simultaeously
one more question, can the 5v pin from this USB host pin power the Teensy 4.1? Or this 5v will power the device connected here? Thanks
 
The VBus connection on the USB host port is intended to supply power to a connected device. The power out is controlled by a special protection device that prevents too much power getting pulled and the processor has the ability to shut the power off on that port. Without checking I'd guess that the output power is only enabled if the USB host code is running.

Feeding power in on that port would probably be a bad idea.
 
Feeding power in on that port would probably be a bad idea.
Seems it may be against the SPEC - but have a Powered USB/HDD box here that once USB Host is activated - it does backfeed power to the Teensy.
Most powered Hubs don't do that over USB-A connects it seems.

though as @AndyA notes - that switch only opens after USB Host is activated.
 
I can use this breakout board, right? Same pin config with Teensy 4.1 USB host so I can solder it directly with header pins to Teensy's USB host port

IMG_5131.jpeg
 
I can use this breakout board, right? Same pin config with Teensy 4.1 USB host so I can solder it directly with header pins to Teensy's USB host port
Should work if the board won't be in the way (or get bumped or pulled) as the pins do seem to have the correct order.

The included USBHost_t36\examples includes this that would be a starting point.
"...\arduino-1.8.19\hardware\teensy\avr\libraries\USBHost_t36\examples\Serial\SerialTest\SerialTest.ino"

It works to plug a T_4.1 in to the USB_Host port with this change - based on the comment:
Code:
//USBSerial userial(myusb);  // works only for those Serial devices who transfer <=64 bytes (like T3.x, FTDI...)
USBSerial_BigBuffer userial(myusb, 1); // Handles anything up to 512 bytes

With a T_4.1 that just starts and prints this is shown - then the Teensy output shows:
Code:
USB Host Testing - Serial
*** Device USERIAL1 16c0:483 - connected ***
  manufacturer: Teensyduino
  product: USB Serial
  Serial: 9706380

Not sure what the CR350 device presents as, and requires.
If it needs a specific baud rate the code notes how to do that.
It seems to work with a generic USB Device as I just plugged in a USB GMRS radio that connects but doesn't 'print':
Code:
USB Host Testing - Serial
*** Device USERIAL1 1a86:7523 - connected ***
  product: USB Serial

It works to connect, disconnect, reconnect.

There is a second "...\arduino-1.8.19\hardware\teensy\avr\libraries\USBHost_t36\examples\Serial\USBtoUSBHostSerial\USBtoUSBHostSerial.ino"
That may show more about the device and offer more usage details.
 
Last edited:
Back
Top