Best way to connect T4.1 To RPi5

Hello everyone, I am wondering if anyone can give me some guidance/advice on the best way to create a high speed buffered data connection between a Teensy 4.1 and a raspberry Pi 5 (which would be running some sort of java program to listen for incoming data)? My thoughts were to use the Ethernet or USB connections to send data. But not sure which is best. My use case is for the teensy to send data logging data to the raspberry Pi (currently writing to SD card) and for the Pi to send back flight navigation set points (currently going to be used in an autonomous drone application). Any info/guidance would be greatly appreciated, thanks!
 
Since the Teensy 4.1 USB port can comunicate at 480Mbps, I would go for the USB option.
Search this forum for "USB transfer speed" and/or "USB data transfer" for more information.

Paul
 
Since the Teensy 4.1 USB port can comunicate at 480Mbps, I would go for the USB option.
Search this forum for "USB transfer speed" and/or "USB data transfer" for more information.

Paul
what would be involved in the receiving/replying of data on the Pi if the Teensy can only operate in "usb host mode"? likely some sort of "COM port" shenanigans I'm guessing? Thanks for your reply btw! :)
 
Well the simplest is just to use USB where the Teensy is a client and the PI is the host. If the PI can power the Teensy, then all you need is a simple USB cable. You would send data via writing text to the serial connection.

Alternatively if you want to send files and more complex things, you could use MTP where the PI can remotely access files on the Teensy (either stored in the various flash memories or on the Teensy's SD card). Like using USB in serial text mode, all you need to use is a USB cable. If the PI has other USB connections, you would need to use a USB hub/switch.

I haven't kept tract of the PI for a bit. I don't know if it supports wired ethernet. If so, you could use the ethernet support on the Teensy 4.1. You would need setup support on the PI, the Teensy 4.1 PHYP connector, and possibly a cross over cable (or use a normal cable, and have some sort of USB hub to bridge the two).

I could imagine adding a wifi or bluetooth card to the Teensy, so that it can communicate wirelessly with the PI.

Other forms of communication with various tradeoffs are I2C or SPI.

You could also use USB host on the Teensy, and make the PI a USB client instead of a USB host. The issue is whether the PI can be a USB client instead of a host.
 
Last edited:
what would be involved in the receiving/replying of data on the Pi if the Teensy can only operate in "usb host mode"? likely some sort of "COM port" shenanigans I'm guessing? Thanks for your reply btw! :)
I would suspect PaulS meant having the Teensy in USB client mode (i.e. the PI is the host). When the Teensy is a USB client, and the PI is the host, you would just write to the USB serial port with normal text print statements and use Serial.Read on the Teensy end. You would have to structure your I/O as a text stream.

With USB host mode, you need to solder the 5 internal pins to bring out the USB connection (PJRC sells a cable that provides a USB A port on one end). However, the PI would have to act as a USB client, not a USB host. The USB protocol requires one side to be the host and the other side to be the client.
 
Why would you need to use text over a serial connection? 8 bit no parity means binary protocols over serial are fine, and often used in fact.
 
Why would you need to use text over a serial connection? 8 bit no parity means binary protocols over serial are fine, and often used in fact.
The default usb connection is set up as a serial connection. Maybe it works with 8-bit binary data, maybe it doesn't (for example it might convert \n into \r\n strings). There are ways to get additional USB devices on the Teensy side, but I was trying to describe the simplest way to connect things, using the existing serial connection.

For example using the MTP connection that I mentioned is a higher method of communication. Normally you use the file explorer on the host system, but you can program both sides to have their own protocols. For example, you could write the data into flash memory as files, and then you can use MTP to retrieve the file or replace it.
 
using the standard libraries, how would someone run the usb port at its full 480Mbps speed, I assume "Serial.begin(480000000);" wouldn't work, I guess what I'm asking is how to actually set and use a 480Mbps USB connection on the teensy 4.1. Thank you. :)
 
using the standard libraries, how would someone run the usb port at its full 480Mbps speed, I assume "Serial.begin(480000000);" wouldn't work, I guess what I'm asking is how to actually set and use a 480Mbps USB connection on the teensy 4.1. Thank you. :)

See:
Unlike a Arduino Uno & Mega which use slow serial baud rates, the Teensy USB Serial objectalways communicates at native USB speed, either 12 or 480 Mbit/sec.The baud rate setting with Serial.begin(baud) is ignored with USB serial (but it isof course used with hardware serial).With Teensy 4.x, a delay is recommended to avoid printingso quickly that scrolling the serial monitor consumes too much processingpower.

Regarding Ethernet 100 Mbps vs. USB 480Mbps:
I don't know how this is using a Rpi but USB is not necessarily the better/faster choice. See, e.g.:
 
Back
Top