Teensy 4.1 USB Host issues

nikutsuki

Member
Hi, I have recently bought a Teensy 4.1 and tried to use the USB Host capability of the board.
I have not bought the official cable for the board and instead bought a normal female USB A to microUSB cable and stripped it to get the 4 wires inside. I connected red wire to 5V, white wire to D-, green wire to D+, and black to the GND on the board.
The problem I am having is that I get the power to the mouse (the LEDs and sensor turn on), but I get no data sent.

The Teensy 4.1 code I use:
C++:
#include "USBHost_t36.h"

USBHost usb_host;
MouseController mouse(usb_host);

void setup() {
  Serial.begin(115200);
 
  usb_host.begin();
}

void loop() {
  usb_host.Task();
  if (mouse.available())
  {  
    Serial.println("mouse input");
    mouse.mouseDataClear();
  }
}

Debug data I get from enabling debug info in "USBHost_t36.h":
Code:
USB2 PLL running
 reset waited 6
USBHS_ASYNCLISTADDR = 0
USBHS_PERIODICLISTBASE = 20003000
periodictable = 20003000
 
Last edited:
White is D+, no?
In the photo for the official usb host cable the white wire is connected to D-, all the photos I have seen for USB 2 wires online also say that white is D- and green is D+.

Though it might not be a bad idea to swap them and check if it works, I will try doing that and let you know how it went.
 
In the photo for the official usb host cable the white wire is connected to D-, all the photos I have seen for USB 2 wires online also say that white is D- and green is D+.

Though it might not be a bad idea to swap them and check if it works, I will try doing that and let you know how it went.
I swapped the white and green wires and sadly it did not work.
 
Mouse objects depend on HID Parser objects.

Have you tried the example sketches like: Mouse?

Maybe try:

C++:
#include "USBHost_t36.h"

USBHost usb_host;
MouseController mouse(usb_host);
USBHIDParser hid1(myusb);
USBHIDParser hid2(myusb);

void setup() {
  Serial.begin(115200);
 
  usb_host.begin();
}

void loop() {
  usb_host.Task();
  if (mouse.available())
  { 
    Serial.println("mouse input");
    mouse.mouseDataClear();
  }
}
 
Mouse objects depend on HID Parser objects.

Have you tried the example sketches like: Mouse?

Maybe try:

C++:
#include "USBHost_t36.h"

USBHost usb_host;
MouseController mouse(usb_host);
USBHIDParser hid1(myusb);
USBHIDParser hid2(myusb);

void setup() {
  Serial.begin(115200);
 
  usb_host.begin();
}

void loop() {
  usb_host.Task();
  if (mouse.available())
  {
    Serial.println("mouse input");
    mouse.mouseDataClear();
  }
}
I have tried the “Mouse” example from the library, I got the same exact output as my code gives with no reaction from the code in the example whatsoever.
I am going to try the code you provided and edit this reply as needed, however I have one question, what’s the “myusb” object you pass to the hid parser?

Edit:
Sadly using the USBHIDParser did not do anything.
 
Last edited:
When I look at Mouse.ino, I think the code should be:
C++:
#include "USBHost_t36.h"

USBHost myusb;
MouseController mouse(myusb);
USBHIDParser hid1(myusb);
USBHIDParser hid2(myusb);

void setup() {
  Serial.begin(115200);
  myusb.begin();
}

void loop() {
  myusb.Task();
  if (mouse.available())
  {
    Serial.println("mouse input");
    mouse.mouseDataClear();
  }
}

Paul
 
When I look at Mouse.ino, I think the code should be:
C++:
#include "USBHost_t36.h"

USBHost myusb;
MouseController mouse(myusb);
USBHIDParser hid1(myusb);
USBHIDParser hid2(myusb);

void setup() {
  Serial.begin(115200);
  myusb.begin();
}

void loop() {
  myusb.Task();
  if (mouse.available())
  {
    Serial.println("mouse input");
    mouse.mouseDataClear();
  }
}

Paul
I have tried doing this, sadly it did not work.
My intention with this post was maybe that I missed something very dumb and there might be a quick solution to the problem, but from what i can see now is that the only possible problem might be that I messed up my soldering somewhere.
I am looking into fixing that though and I will let you know how it went.
 
I have tried doing this, sadly it did not work.
My intention with this post was maybe that I missed something very dumb and there might be a quick solution to the problem, but from what i can see now is that the only possible problem might be that I messed up my soldering somewhere.
I am looking into fixing that though and I will let you know how it went.
Sometimes it helps if you show photos of your wiring.

Also additional information like, what mouse is it that you are plugging in?

For unknown devices I often use the HIDDeviceInfo sketch, as if is a normal HID mouse or the like, it should show us something.
it should show lots of information with the debug enabled in the USBHost_t36.h file.

If you don't see anything in it like a new device detected and this or that and one or more of the objects being called by the claim methods, it would imply that the host code is not seeing your object.
 
Sometimes it helps if you show photos of your wiring.
Going to post some when I find some time.

Also additional information like, what mouse is it that you are plugging in?
I tried with "Razer viper 8khz", "Glorious model o" and some random mouse I found laying around, none of them worked.

For unknown devices I often use the HIDDeviceInfo sketch, as if is a normal HID mouse or the like, it should show us something.
it should show lots of information with the debug enabled in the USBHost_t36.h file.
I will try that and say how it went.

If you don't see anything in it like a new device detected and this or that and one or more of the objects being called by the claim methods, it would imply that the host code is not seeing your object.
The only debug info I get from the library when using both the "Mouse.ino" example and my code is this.
Code:
USB2 PLL running
 reset waited 6
USBHS_ASYNCLISTADDR = 0
USBHS_PERIODICLISTBASE = 20003000
periodictable = 20003000
And that is it, no more information when I connect or disconnect the mouse, only these messages when I restart my Teensy.
 
I was curious and checked with a Teensy 4.1.

Nothing connected the mouse.ino sketch shows:
Code:
USB Host Testing
960
Plugging in a (wireless) mouse shows:
Code:
*** Device HID1 46d:c534 - connected ***
  manufacturer: Logitech
  product: USB Receiver
*** Device HID2 46d:c534 - connected ***
  manufacturer: Logitech
  product: USB Receiver
*** HID Device KB1 46d:c534 - connected ***
  manufacturer: Logitech
  product: USB Receiver
*** HID Device Mouse1 46d:c534 - connected ***
  manufacturer: Logitech
  product: USB Receiver

Using HIDDeviceInfo shows a huge list of info lines.

This example is working here:
Code:
#include "USBHost_t36.h"

USBHost usb_host;
MouseController mouse(usb_host);
USBHIDParser hid1(usb_host);
USBHIDParser hid2(usb_host);

void setup() {
  Serial.begin(115200);
 
  usb_host.begin();
}

void loop() {
  usb_host.Task();
  if (mouse.available())
  {
    Serial.println("mouse input");
    mouse.mouseDataClear();
  }
}

Activating the debug info in USBHost_t36.h gives me this:
Code:
USB2 PLL running
 reset waited 6
USBHS_ASYNCLISTADDR = 0
USBHS_PERIODICLISTBASE = 20005000
periodictable = 20005000

So it seems you don't have a data connection because nothing is happening after that when you plug in your device.
 
I was curious and checked with a Teensy 4.1.

Nothing connected the mouse.ino sketch shows:
Code:
USB Host Testing
960
Plugging in a (wireless) mouse shows:
Code:
*** Device HID1 46d:c534 - connected ***
  manufacturer: Logitech
  product: USB Receiver
*** Device HID2 46d:c534 - connected ***
  manufacturer: Logitech
  product: USB Receiver
*** HID Device KB1 46d:c534 - connected ***
  manufacturer: Logitech
  product: USB Receiver
*** HID Device Mouse1 46d:c534 - connected ***
  manufacturer: Logitech
  product: USB Receiver

Using HIDDeviceInfo shows a huge list of info lines.

This example is working here:
Code:
#include "USBHost_t36.h"

USBHost usb_host;
MouseController mouse(usb_host);
USBHIDParser hid1(usb_host);
USBHIDParser hid2(usb_host);

void setup() {
  Serial.begin(115200);
 
  usb_host.begin();
}

void loop() {
  usb_host.Task();
  if (mouse.available())
  {
    Serial.println("mouse input");
    mouse.mouseDataClear();
  }
}

Activating the debug info in USBHost_t36.h gives me this:
Code:
USB2 PLL running
 reset waited 6
USBHS_ASYNCLISTADDR = 0
USBHS_PERIODICLISTBASE = 20005000
periodictable = 20005000

So it seems you don't have a data connection because nothing is happening after that when you plug in your device.
The problem is solved, I resoldered everything and my bad soldering turned out to be the problem.

Thank you everybody for help, have a nice day guys.
 
Back
Top