Options for adding Bluetooth keyboard to Teensy 4?

smarrocco

Active member
I'm working on a Teensy 4.1-based project with a touch LCD display (among other things) that requires text input from the user. I was planning to use the USB Host connectors on the T4.1 to connect a USB keyboard, but would like to avoid having to plug a keyboard into my project if possible.

I've looking for options/examples including the following and what might be decent options for wireless text entry.....

-A keyboard with a USB Bluetooth dongle plugged into the Teensy 4.1 USB Host Port (wired adapter) directly (not sure what Library may be needed for this)
-A keyboard such as this (https://www.adafruit.com/product/3601) and some sort of Bluetooth add-on to the Teensy via direct IO Pins (my SPI ports are all currently in use)
-My last options is to make an on-screen keypad, but the smaller size of the display (4") makes this a bit tedious to use for typing.

Suggestions and alternatives appreciated, thanks.
 
At least at one point we had some bluetooth keyboards working with the USBHost_t36 library. It has been a long long time since I played with this stuff, so I have no idea what things work these days and which ones don't.

At one point I know I had one of these working:
But I purchased it something like six years ago. I also don't remember which Bluetooth adapters worked or not.

But you might find some hints back on this thread:
 
By the way, A I2C solution makes sense,no much data speed needed:



I have the same bluetooth as KurtE,but at the time (2 or 3 years ago) i used it on usb hosts,the library adaptation was not complete
in my country language (french),so combinations were very poor.
 
Have you looked for keyboards with it's own proprietary USB dongle? Or is that what you mean in your first option? As such a dongle behaves as a usual, class compliant USB keyboard device this should work fine and reliably.

There are some small keyboards like this, too, if size is important, for example:
(sorry for the German pages - just examples...)
 
Have you looked for keyboards with it's own proprietary USB dongle? Or is that what you mean in your first option? As such a dongle behaves as a usual, class compliant USB keyboard device this should work fine and reliably.
Yes, there are several different ones with their own dongles, like some from Logitech and Microsoft and ...
Note: with some of them we found you have to experiment with which USB Devices that are included within the a sketch.

For example, some of the keyboard only setups are such that their dongle will actually create a few different objects, like
a Mouse and a keyboard, and their keyboard would not work properly if we did nothing with the mouse object...
 
Yes, there are several different ones with their own dongles, like some from Logitech and Microsoft and ...
Note: with some of them we found you have to experiment with which USB Devices that are included within the a sketch.

For example, some of the keyboard only setups are such that their dongle will actually create a few different objects, like
a Mouse and a keyboard, and their keyboard would not work properly if we did nothing with the mouse object...
That sounds like a solvable problem. I am curious now to try some of these small keyboards myself. I have some projects where an affordable and out of the box solution for wireless user control input would come in very handy...

For me, even better would be to have some knobs and even more better would be to have a small display to show some info. At the moment I am using a MIDI controller via USB cable connection which feels great and working absolutely fine. But that controller costs more than a cheap smartphone nowadays.

By the way: I started successfully experimenting with developing an Android app (using MIT App Inventor) to send some serial over bluetooth. Connecting to a cheap bluetooth module worked fine. This bluetooth module sends simple serial data to the Teensy. Needs just some work to make that app but of course it is great to customize completely free your user interface.
Maybe this could be also an interesting option for the thread opener.

Edit: I see that I can get a Cubot J10 smartphone in Germany for 26€ shipping included. How crazy is that?
 
Last edited:
Have you looked for keyboards with it's own proprietary USB dongle? Or is that what you mean in your first option? As such a dongle behaves as a usual, class compliant USB keyboard device this should work fine and reliably.

@TomChiron,
Yes, that sounds like it might be a good alternative technique with the least R&D involved. If the proprietary USB dongle/keyboard doesn't need any type of pairing (which would require some interaction on the Teensy's part) then it could be basically plug & play, then using the Teensy USB_Host library to listen for normal HID keystrokes on the Teensy 4.1's USB Host dedicated port. I'll have to check into some smaller keyboards without the trackballs, trackpads, etc, as KB input is all I really need. It could also be RF or something else besides Bluetooth as long is the connection doesn't require any drivers.
 
Most non-BT wireless keyboards act just like a regular HID keyboard, the PC doesn't even know the difference. So they should work fine with the USBHost_t36 library.
 
Most non-BT wireless keyboards act just like a regular HID keyboard, the PC doesn't even know the difference. So they should work fine with the USBHost_t36 library.
Yes, other than the caveat I mentioned as some of their dongles may have support for multiple devices (Mouse and Keyboard).

I just verified that one of the ones I purchased 5.5 years ago for testing, still works:
(Took me awhile to find the dongle, plus replace the batteries and the like)

At least with the Keyboard viewer example sketch. It shows all of the normal keyboard stuff.

If I run the HIDDeviceInfo, you will see that it actually has several different HIDS it produces. Including normal, keyboard, Multimedia keyboard,
sort of a mouse object and the like.
 
I tried today this nice little keyboard but didn't get it working:
20241005_172704_.jpg

(bought in Germany from Berrybase.de but you get it with different layouts and other brandings)

No luck: Tried different combinations with keyboard and mouse, but it seems that the connection to the dongle is not established. On the keyboard the orange LED is blinking in the same way when the dongle is not plugged in anywhere. Under Windows it shows up in the device manager as mouse and keyboard - as far as I can see. Product description says 2.4GHz, i.e. no Bluetooth. Tried the pairing version in the sketch anyway without success.

HIDDeviceInfo shows nothing at all.

Used Teensy 3.6`, Arduino 1.8.19, Teensyduino 1.59
With other wireless devices with USB dongles all examples are working: Mouse, keyboard/touchpad-combination.

Any ideas?


@smarrocco: Have you found a solution which is working for your needs?
 
Try to turn on debug (about line 63 in USBHost_t36.h): uncomment:
//#define USBHOST_PRINT_DEBUG

And see if it shows anything interesting.
 
This is all which is coming out from the debug (enabled in USBHost_t36.h, using HIDDeviceInfo):

Code:
sizeof Device = 36
sizeof Pipe = 96
sizeof Transfer = 64
power up USBHS PHY
 reset waited 5
USBHS_ASYNCLISTADDR = 0
USBHS_PERIODICLISTBASE = 1FFFA000
periodictable = 1FFFA000
port change: 10001C03
    connect
  begin reset
port change: 10001005
  port enabled
  end recovery
new_Device: 12 Mbit/sec
new_Pipe
port change: 1C00100A
    disconnect
disconnect_Device:
USBDriver (available_drivers) list: 1FFF8900 -> 1FFF8CC0 -> 1FFF1018 -> 1FFF64A0 -> 1FFF6BE0 -> 1FFF7320 -> 1FFF7A60 -> 1FFF81A0
USBDriver (dev->drivers) list: (empty
USBDriver (available_drivers) list: 1FFF8900 -> 1FFF8CC0 -> 1FFF1018 -> 1FFF64A0 -> 1FFF6BE0 -> 1FFF7320 -> 1FFF7A60 -> 1FFF81A0
delete_Pipe 1FFFA9E0
  shut down async schedule
  Free transfers
    * 536849216 * remove * free
    * 536849024
    * 536849088 * remove * defer free until QH
  Free transfers attached to QH
    * 536849024
    * 536849088
    * 536849152
* Delete Pipe completed
removed Device_t from devlist
  disable
port change: 10001803
    connect
  begin reset
port change: 10001005
  port enabled
  end recovery
new_Device: 12 Mbit/sec
new_Pipe
enumeration:
enumeration:
enumeration:
Device Descriptor:
  12 01 10 01 00 00 00 08 00 00 00 00 00 00 00 00 00 00
    VendorID = 0000, ProductID = 0000, Version = 0000
    Class/Subclass/Protocol = 0 / 0 / 0
    Number of Configurations = 0
From my very limited understanding there is a "Configuration Descriptor" needed which is not there and therefore it is not possible to detect keyboard and mouse / decide for the neede communication protocols...?
It seems also strange that there is a "disconnect"?
No idea what I could do.
 
Sorry, not sure what to do at this point... More in @PaulStoffregen arena.

We have seen a few strange devices. As for disconnect... Seen some strange ones. I think it was a tablet that @mjs513 and I
debugged to try to make work. Don't remember if we got it to work properly or not. The device when it would come up would
first show up like, an FTDI USB To Serial Adapter, then do something like a USB reset, where it then would switch to a new
device descriptor for the table... Or something like that. Been a while, so don't remember all the details. It also may be one of the ones
we both purchased, we thought were the same thing, but they internally different.

I think it is this one?

I don't see any Sertronics keyboards anywhere so even if I wanted to try to debug...
 
I tried today this nice little keyboard but didn't get it working:
View attachment 35994
(bought in Germany from Berrybase.de but you get it with different layouts and other brandings)

No luck: Tried different combinations with keyboard and mouse, but it seems that the connection to the dongle is not established. On the keyboard the orange LED is blinking in the same way when the dongle is not plugged in anywhere. Under Windows it shows up in the device manager as mouse and keyboard - as far as I can see. Product description says 2.4GHz, i.e. no Bluetooth. Tried the pairing version in the sketch anyway without success.

HIDDeviceInfo shows nothing at all.

Used Teensy 3.6`, Arduino 1.8.19, Teensyduino 1.59
With other wireless devices with USB dongles all examples are working: Mouse, keyboard/touchpad-combination.

Any ideas?


@smarrocco: Have you found a solution which is working for your needs?
Hi Tom,did you success to communicate directly with those modules,using bluetooth BLE dedicated sketch with an ESP32
and without using the dongle?
 
Just to jump in here for a minute. With the Logitech Keyboards that I have tried I paired the dongle to the keyboard on the PC side first. Then I plugged the already paired dongle and keyboard into the USB host port. You can give that a try. It may be recognizing the dongle but not the paired device.
 
From that debug log I would guess the device is pulling too much power when it initially connects, causing the disconnect. Try connecting it via a powered USB hub.
 
From that debug log I would guess the device is pulling too much power when it initially connects, causing the disconnect. Try connecting it via a powered USB hub.
That helped!
Using a powered USB hub makes it work! MouseKeyboardForward working. Keyboard without mouse is also possible.

Not sure if it is really the power or something else is going on here? I will check the voltages when I have more time. Would be nice to find a solution without needing these extras.

Would be nice to use the caps lock LED as status / feedback ... or with some blink codes ... as this is this the only way to show something on the keyboard. I think it should be possible to set it manually. I will look into keyboard.cpp - there seems to be a function to update all LEDs.
(I would like to use this device as a simple solution to control different programs of a light installation setup - I am not so much interested in using it as a usual keyboard)

Sorry, not sure what to do at this point... More in @PaulStoffregen arena.

We have seen a few strange devices. As for disconnect... Seen some strange ones. I think it was a tablet that @mjs513 and I
debugged to try to make work. Don't remember if we got it to work properly or not. The device when it would come up would
first show up like, an FTDI USB To Serial Adapter, then do something like a USB reset, where it then would switch to a new
device descriptor for the table... Or something like that. Been a while, so don't remember all the details. It also may be one of the ones
we both purchased, we thought were the same thing, but they internally different.

I think it is this one?

I don't see any Sertronics keyboards anywhere so even if I wanted to try to debug...
Yes, this is the one I have here right now (to be precise, I have the QUERTZ layout). On the back is a label "Berrybase by Sertronics" but I assume you can get other brandings from the same manufacturer.
Like this one:
Yes, this should be the same. There seems to be different versions with white LED and colored LED light and different brandings. But everything should be the same hardware.

Just to jump in here for a minute. With the Logitech Keyboards that I have tried I paired the dongle to the keyboard on the PC side first. Then I plugged the already paired dongle and keyboard into the USB host port. You can give that a try. It may be recognizing the dongle but not the paired device.
Tried that already and it made no difference.

Edit: Starting everything with the powered USB hub, then disconnecting the hub and plugging the dongle into the Teensy USB cable directly keeps it working.
This is not working when I connect it to the PC first.

Hi Tom,did you success to communicate directly with those modules,using bluetooth BLE dedicated sketch with an ESP32
and without using the dongle?
From my understanding this is a proprietary 2.4 GHz dongle with no bluetooth functionality.
 
Last edited:
That helped!
Using a powered USB hub makes it work! MouseKeyboardForward working. Keyboard without mouse is also possible.

Not sure if it is really the power or something else is going on here? I will check the voltages when I have more time. Would be nice to find a solution without needing these extras.
A tiny receiver like that shouldn't need much power to run, it's probably just pulling too much when it initially starts up (would probably need a scope to monitor the level when it gets plugged in). Maybe putting a capacitor between the USB Host 5V pin (not the 5V rail that supplies the Teensy!) and GND would help, or otherwise using a separate 5V supply for the USB Host socket.
 
A tiny receiver like that shouldn't need much power to run, it's probably just pulling too much when it initially starts up (would probably need a scope to monitor the level when it gets plugged in). Maybe putting a capacitor between the USB Host 5V pin (not the 5V rail that supplies the Teensy!) and GND would help, or otherwise using a separate 5V supply for the USB Host socket.
I did some further testing:

working:
1. connect the dongle to power from external power supply
2. start Teensy
(state of the keyboard does not matter. Switching it on and off keeps it working)

Unpowering the Teensy and start it again is working, too.

Not working:
- Starting Teensy and then plug in / power the dongle
- unplugging the working dongle and plug in in again does not re-connect it (with other dongles that works)
- capacitor does not help

I lowered the voltage with my lab power supply and the dongle works down to ~3.5V.
On the Teensy 3.6 I measure ~4.2V at the USB port, but that does not seem to be the problem also for a second reason: The reconnection problem is also there with external power.

So my guess now is that this a timing problem and the dongle needs to be powered for a certain time before the data communication from the Teensy is starting. As far as I remember the power at the USB host port is activated somehow from the library - so it should be possible to add some waiting time? Just a guess.
And the Windows PC seem to make also something different.


... haven't checked a Teensy 4.1 if that makes a difference btw.
 
... checked with Teensy 4.1 now: working.
Reconnecting or plugging in the dongle later is also no problem. Works also with a hub without additional power.

That's good news.

I wasn't aware of the fact that there could be relevant differences at the Teensy 3.6 regarding the USB host behaviour. So I still assume that this has something to do with the control of activating the power for the USB host. Possible that this is a kind of bug that could be fixed.

I just had this 3.6 by hand for a quick test. In all future projects I will use Teensy 4.1. So I am glad to have found a nice little keyboard which I can use as a remote control.
 
Back
Top