Teensy USBHost_t36 Lib Problem with Teensy 4.0

I am using Teensy 4.0, and need to include USBHost_t36.h
There is a problem adding USBHost_t36 lib. Get all sorts of lib compile issues when adding
#include “USBHost_t36.h” to a blank sketch.

Yet works just fine when using Arduino 1.8.19.
I followed the installation information here.

Any ideas?

But the library in the registry says

Connect USB devices to the USB Host of Teensy 3.6.

So no compatiblility with 4.0 mentioned. That is however because the library was last updated in the registry 4 years ago and the library has recent improvements. So, you should try

lib_deps = https://github.com/PaulStoffregen/USBHost_t36/archive/refs/heads/master.zip

instead.

After my PR is merged, a new version is now available: PlatformIO Registry

Try using that directly.

1 Like

Hi, sorry to revive this thread.

I am having a similar problem even though the Teensy 4.0 is now fully supported by USBHost_t36. I am just trying to run “Basic.ino” from the examples, link here: USBHost_t36/examples/MIDI/Basic/Basic.ino at master · PaulStoffregen/USBHost_t36 · GitHub

I create a new project for the Teensy 4.0 using the Arduino framework, and paste this code into the main.cpp file. When I try to build, I get all sorts of compile errors, the first few errors are shown below:

I’ve tried to add the dependency directly using “lib_deps = paulstoffregen/USBHost_t36@^0.2” in my platformio.ini, but that also does not solve the problem.

I can run this code just fine with no modifications on the Arduino IDE, so I am not sure what the issue is.

Any help would be appreciated, thank you.

Please check the Teensy platform version installed in the ArduinoIDE.
In PlatformIO you are using version 5.0.0, which was released only 6 months ago.
This thread is 2 years old. At that time, Teensy 4.15.0 must be the latest version.

The last commit in the library repository was also 10 months ago.
I therefore assume that there is no compatibility with Teensy 5.0.0 (yet).

1 Like

Hi Sivar2311,

Thank you for your answer. I am not familiar with the meaning of platform in this context, I made sure that the version of the core between the two is the same (Teensyduino v1.59) but I am unsure how to check for the platform version in the Arduino IDE (or what platform means). Can you help me with this?

Thank you!

Platform is the build system, toolchain and libraries for the specific micrcontroller family. For mor details see Development Platforms — PlatformIO latest documentation

Per Releases · platformio/platform-teensy · GitHub you can see the PlatformIO Teensy platform version and which Teensyduino version it contains:

Teensy Platform
version
Teensyduino
version
Release Date
5.0.0 1.59 Feb 27, 2024
4.18.0 1.58 Apr 6, 2023
4.17.0 1.57 Jul 31, 2022
4.16.0 1.56 May 30, 2022
4.15.0 1.56 Jan 28, 2022

This thread is from March 2022. That time Teensyduiny 1.56 (Teensy 4.15.0) must have been the latest version.

The last commit to the library’s repository was ten months ago. That time Teensyduino 1.58 (Teensy 4.18) was the latest.

To get this version you have to use in your platformio.ini:
platform = Teensy @ 4.18.0

Thank you again for your help Sivar2311, and for the link to learn more about PlatformIO. Still wrapping my head around the differences in this IDE.

Unfortunately, changing the version still did not allow the project to compile. Luckily after spending too long looking at this, I did figure out the issue.

The example code I was using does not declare the functions before they are defined AFTER the loop. I put after in caps because this is apparently very important, as you will need to define a “function prototype” before the setup and loop in PlatformIO. I believe that the Arduino IDE is just doing this automatically at compile-time. After adding function prototypes for all of the functions in the code (and needing to #include EEPROM.h for some reason) the code builds without a problem, even in the current teensy platform version.

Not sure if this is widely understood knowledge or not, but it was new to me so hopefully this will help someone else if they are having this problem.

Here is a link to the forum post where I found this answer: functions ahead of setup() and loop() - #5 by Danois90 - Programming Questions - Arduino Forum

Post #5 has an example of a prototype function.

Hi @bobbyflay ! Thanks for your detailed reply.

Unfortunately, the reason was not obvious from the error message - at least not to me.

In short: *.ino files are not valid C / C++ files.
For details, please see Convert Arduino file to C++ manually — PlatformIO latest documentation

1 Like