# USB Host to BLE Keyboard Adapter

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/129/702/medium800thumb/hacks_fox2.jpg?1714413783)

Do you dream of a world without wires? This project gets you one step, or keystroke, closer to that. A Feather ESP32-S3 TFT runs Arduino code that utilizes its BLE capabilities to act as a BLE keyboard. Alongside the Feather is the USB Host FeatherWing that lets you plug in a USB device, in this case an HID keyboard, and pipe its inputs to the Feather. The Feather then sends these key inputs over BLE to your computer or other connected device.

The TFT lets you check the status of the project at a glance, which is very helpful for wireless projects.

![hacks_edited_P1440705.jpg](https://cdn-learn.adafruit.com/assets/assets/000/129/692/medium640/hacks_edited_P1440705.jpg?1714404293)

The 3D printed case lets you store a large lipoly battery safely underneath the FeatherWing Doubler. The battery monitor on the Feather lets you monitor its charge percentage on the TFT and over BLE.

![hacks_edited_P1440613.jpg](https://cdn-learn.adafruit.com/assets/assets/000/129/693/medium640/hacks_edited_P1440613.jpg?1714404305)

## Parts
### Adafruit ESP32-S3 TFT Feather - 4MB Flash, 2MB PSRAM, STEMMA QT

[Adafruit ESP32-S3 TFT Feather - 4MB Flash, 2MB PSRAM, STEMMA QT](https://www.adafruit.com/product/5483)
We've got a new machine here at Adafruit, it can uncover your deepest desires. Don't believe me? I'll turn it on right now to prove it to you! What, you want your very own soft serve ice cream machine? OK well, that's not something we can provide. But we can provide your...

Out of Stock
[Buy Now](https://www.adafruit.com/product/5483)
[Related Guides to the Product](https://learn.adafruit.com/products/5483/guides)
![Top view of a purple rectangular microcontroller with a color TFT screen and powered by an ESP32-S3 chip. It is also connected to a Li-Poly battery and a lux sensor breakout. The TFT display reads in colored text: "Adafruit Feather
ESP32-S3 TFT Demo
Battery: 3.8V / 45%
I2C: 0xB, 0x10, "](https://cdn-shop.adafruit.com/640x480/5483-06.jpg)

### Adafruit USB Host FeatherWing with MAX3421E

[Adafruit USB Host FeatherWing with MAX3421E](https://www.adafruit.com/product/5858)
Lots of microcontrollers these days have USB ports on them, to program or debug, act like a keyboard or disk drive, or simply&nbsp;send data between a computer and your firmware. But did you know that you can also add a USB Host port? That means that your microcontroller project can have a...

In Stock
[Buy Now](https://www.adafruit.com/product/5858)
[Related Guides to the Product](https://learn.adafruit.com/products/5858/guides)
![Video of a Black woman's green-manicured hand plugging in a USB TrinKey board into a USB Host FeatherWing assembled on a Doubler below an Adafruit TFT microcontroller board.](https://cdn-shop.adafruit.com/product-videos/640x480/5858-05.jpg)

### Mini Chiclet Keyboard - USB Wired - Black

[Mini Chiclet Keyboard - USB Wired - Black](https://www.adafruit.com/product/1736)
Add a good quality, slim keyboard to your&nbsp;Raspberry Pi, Beagle Bone Black, or other single-board-computer with this sleek black chiclet keyboard. It's a full QWERTY keyboard with a USB cable and is compatible with all operating systems. We tried many keyboards to find one that felt...

In Stock
[Buy Now](https://www.adafruit.com/product/1736)
[Related Guides to the Product](https://learn.adafruit.com/products/1736/guides)
![Angled shot of a Black woman's silver-blue manicured hands on a slim, black keyboard.](https://cdn-shop.adafruit.com/640x480/1736-04.jpg)

### FeatherWing Doubler - Prototyping Add-on For All Feather Boards

[FeatherWing Doubler - Prototyping Add-on For All Feather Boards](https://www.adafruit.com/product/2890)
This is the **FeatherWing Doubler** - a prototyping add-on and more for all Feather boards. This is similar to our [FeatherWing Proto](https://www.adafruit.com/products/2884) except there are two! The magic of the Doubler comes when stacking a Feather and another...

In Stock
[Buy Now](https://www.adafruit.com/product/2890)
[Related Guides to the Product](https://learn.adafruit.com/products/2890/guides)
![Double prototyping feather wing PCB with socket headers installed](https://cdn-shop.adafruit.com/640x480/2890-01.jpg)

### Breadboard-friendly SPDT Slide Switch

[Breadboard-friendly SPDT Slide Switch](https://www.adafruit.com/product/805)
These nice switches are perfect for use with breadboard and perfboard projects. They have 0.1" spacing and snap in nicely into a solderless breadboard. They're easy to switch no matter what size fingers you have, but not so easy that they'll get flipped by accident. Work great as...

In Stock
[Buy Now](https://www.adafruit.com/product/805)
[Related Guides to the Product](https://learn.adafruit.com/products/805/guides)
![Small, black, SPDT slide switch.](https://cdn-shop.adafruit.com/640x480/805-03.jpg)

### Lithium Ion Polymer Battery - 3.7v 2500mAh

[Lithium Ion Polymer Battery - 3.7v 2500mAh](https://www.adafruit.com/product/328)
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This battery has a capacity of **2500mAh** for a total of about 10 Wh. If you need a smaller battery, <a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/328)
[Related Guides to the Product](https://learn.adafruit.com/products/328/guides)
![Lithium Ion Polymer Battery 3.7v 2500mAh with JST 2-PH connector](https://cdn-shop.adafruit.com/640x480/328-06.jpg)

### Part: Silicone Wire
quantity: 1
30AWG
[Silicone Wire](https://www.adafruit.com/product/2051)

### Part: M2.5 Black Nylon Machine Screw and Stand-off Set
quantity: 1
M2.5 Thread
[M2.5 Black Nylon Machine Screw and Stand-off Set](https://www.adafruit.com/product/3299)

### Part: M3 Black Nylon Machine Screw and Stand-off Set
quantity: 1
M3 Thread
[M3 Black Nylon Machine Screw and Stand-off Set](https://www.adafruit.com/product/4685)

# USB Host to BLE Keyboard Adapter

## 3D Printing

![](https://cdn-learn.adafruit.com/assets/assets/000/129/678/medium800/hacks_edited_P1440604.jpg?1714402153)

The adapter may be assembled with 3D printed parts, described below. The enclosure has four parts: a case, a lid, a battery cover and a slide switch holder.

The STL files can be downloaded directly here or from Printables.

[USB_Host_to_BLE_Keyboard_Adapter_Case_STL_Files.zip](https://cdn-learn.adafruit.com/assets/assets/000/129/700/original/USB_Host_to_BLE_Keyboard_Adapter_Case_STL_Files.zip?1714407045)
[Printables Download](https://www.printables.com/model/861950-usb-host-to-ble-keyboard-adapter-case)
The battery cover keeps the lipoly battery away from the header solder points on the bottom of the FeatherWing Doubler. It also doubles as the Doubler mounting plate.

![hacks_edited_P1440613.jpg](https://cdn-learn.adafruit.com/assets/assets/000/129/679/medium640/hacks_edited_P1440613.jpg?1714402160)

The case has cutouts for the TFT, USB ports and the slide switch.

![hacks_edited_P1440622.jpg](https://cdn-learn.adafruit.com/assets/assets/000/129/680/medium640/hacks_edited_P1440622.jpg?1714402169)

# USB Host to BLE Keyboard Adapter

## Code the Adapter

![](https://cdn-learn.adafruit.com/assets/assets/000/129/694/medium800/hacks_edited_P1440717.jpg?1714404321)

The Arduino code for the project is available as a pre-compiled .UF2 file that you can drag and drop onto your Feather ESP32-S3 TFT board.

[USB_Host_to_BLE_Arduino.uf2](https://cdn-learn.adafruit.com/assets/assets/000/129/670/original/USB_Host_to_BLE_Arduino.uf2?1714146876)
## Load the UF2
 **Click the link above to download the UF2 file.**

Save it wherever is convenient for you.

![hacks_uf2.png](https://cdn-learn.adafruit.com/assets/assets/000/129/669/medium640/hacks_uf2.png?1714146867)

![reset](https://cdn-learn.adafruit.com/assets/assets/000/114/082/medium800/adafruit_products_FS3TFT_NeoPixel_and_reset_button.jpg?1660235941 )

Plug your board into your computer, using a known-good data-sync USB cable, directly, or via an adapter if needed.

Double-click the **reset** button (highlighted in red above), wait for the **NeoPixel LED to turn purple** (highlighted in green), and as soon as it turns purple, tap **reset** again. The second tap needs to happen while the LED is still purple.

You will see a new disk drive appear called&nbsp; **FTHRS3BOOT**.

&nbsp;

Drag the **UF2** file to **FTHRS3BOOT**.

![hacks_bootUF2.png](https://cdn-learn.adafruit.com/assets/assets/000/129/671/medium640/hacks_bootUF2.png?1714146902)

The code will begin running by starting the BLE advertisement and mounting the USB keyboard. Once both of these connections are completed, you can begin using the connected keyboard over BLE.

## Code
https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/USB_Host_to_BLE_Arduino/USB_Host_to_BLE_Arduino.ino

## How the Code Works
The code is based on the [ESP32 BLE Keyboard example](https://gist.github.com/manuelbl/66f059effc8a7be148adb1f104666467), the&nbsp;[HID Remapper example](https://github.com/adafruit/Adafruit_TinyUSB_Arduino/blob/master/examples/DualRole/HID/hid_remapper/hid_remapper.ino) from the [Adafruit\_TinyUSB\_Arduino Library](https://github.com/adafruit/Adafruit_TinyUSB_Arduino) and the [Feather ESP32-S3 TFT Factory Test](https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Factory_Tests/Feather_ESP32S3_TFT_FactoryTest/Feather_ESP32S3_TFT_FactoryTest.ino). These examples have been smooshed together to make a delicious Arduino/USB/BLE/TFT Feather sandwich.&nbsp;

There are some user configurable variables that you can update at the top of the code. You can change the `DEVICE_NAME` and `BLE_MANUFACTURER` for the device. These names will show up when you connect to the device from your computer.

In the `setup()`, the BLE connection is established followed by mounting the USB keyboard. The status of these tasks are shown on the TFT. Additionally, the battery monitor is initialized over I2C. There are checks for either the LC709203F or the MAX17048 since your Feather ESP32-S3 TFT may have either one depending on when you purchased it.

In the `loop()`, the TFT shows the battery percentage and the last USB keyboard HEX code sent over BLE. `USBHost.task()` runs the TinyUSB tasks. The main task is the `tuh_hid_report_received_cb()` function. This function reads the incoming keystrokes, sends them over BLE, updates the battery percentage over BLE so that it shows on your computer and updates the last sent HEX code on the TFT.

# USB Host to BLE Keyboard Adapter

## Assembly

![](https://cdn-learn.adafruit.com/assets/assets/000/129/681/medium800/hacks_edited_P1440629.jpg?1714403754)

## Soldering
Solder wires to the center and left leads on the slide switch. Cover the leads with heatshrink.

![hacks_edited_P1440640.jpg](https://cdn-learn.adafruit.com/assets/assets/000/129/682/medium640/hacks_edited_P1440640.jpg?1714403761)

Solder socket headers to the FeatherWing Doubler. Then, solder the center lead wire to the **EN** pin on the FeatherWing Doubler. Solder the left lead to the **GND** pin on the FeatherWing Doubler.&nbsp;

![hacks_edited_P1440650.jpg](https://cdn-learn.adafruit.com/assets/assets/000/129/683/medium640/hacks_edited_P1440650.jpg?1714403774)

Solder plug headers to the Feather ESP32-S3 TFT and the USB Host FeatherWing.

![hacks_edited_P1440659.jpg](https://cdn-learn.adafruit.com/assets/assets/000/129/684/medium640/hacks_edited_P1440659.jpg?1714403781)

## Case Assembly
Insert the battery into the case lid.

![hacks_edited_P1440662.jpg](https://cdn-learn.adafruit.com/assets/assets/000/129/685/medium640/hacks_edited_P1440662.jpg?1714403791)

Attach the FeatherWing Doubler to the battery lid mounting holes with M2.5 screws.

![hacks_edited_P1440666.jpg](https://cdn-learn.adafruit.com/assets/assets/000/129/686/medium640/hacks_edited_P1440666.jpg?1714403800)

Cover the battery with the battery lid. Route the battery cable thru the cutout in the lid.

![hacks_edited_P1440672.jpg](https://cdn-learn.adafruit.com/assets/assets/000/129/687/medium640/hacks_edited_P1440672.jpg?1714403808)

Plug the Feather ESP32-S3 TFT and USB Host FeatherWing into the FeatherWing Doubler. Run the slide switch wires so that the switch is opposite the USB ports on the boards.

![hacks_edited_P1440675.jpg](https://cdn-learn.adafruit.com/assets/assets/000/129/688/medium640/hacks_edited_P1440675.jpg?1714403825)

Place the slide switch into the slide switch mount. Plug the battery into the Feather JST battery port.

![hacks_edited_P1440687.jpg](https://cdn-learn.adafruit.com/assets/assets/000/129/689/medium640/hacks_edited_P1440687.jpg?1714403844)

Attach the slide switch mount to the case with M3 screws and nuts.&nbsp;

![hacks_edited_P1440691.jpg](https://cdn-learn.adafruit.com/assets/assets/000/129/690/medium640/hacks_edited_P1440691.jpg?1714403853)

Close up the case, making sure to have the USB ports on the Feather and FeatherWing flush with their cutouts.

![hacks_edited_P1440695.jpg](https://cdn-learn.adafruit.com/assets/assets/000/129/691/medium640/hacks_edited_P1440695.jpg?1714403863)

# USB Host to BLE Keyboard Adapter

## Use

![](https://cdn-learn.adafruit.com/assets/assets/000/129/701/medium800thumb/hacks_counting2.jpg?1714413685)

Power up the project by switching on the power switch. Plug in a USB keyboard to the USB Host FeatherWing. After the Feather ESP32-S3 TFT initializes the BLE and USB connections you can connect the project to your computer or any device that allows for a BLE keyboard connection.

In your operating system, navigate to **adding a BLE device**.

![hacks_addBLE_1.png](https://cdn-learn.adafruit.com/assets/assets/000/129/672/medium640/hacks_addBLE_1.png?1714154711)

The device will show up as **ESP32 Keyboard**.&nbsp;

![hacks_deviceDiscovered.png](https://cdn-learn.adafruit.com/assets/assets/000/129/673/medium640/hacks_deviceDiscovered.png?1714154770)

Once the device connects, you're ready to start using the project. You should see it listed with your keyboard and mouse peripherals. The battery percentage will also be visible.

![hacks_listedInKeyboards93batt.png](https://cdn-learn.adafruit.com/assets/assets/000/129/675/medium640/hacks_listedInKeyboards93batt.png?1714154842)

The battery charge percentage updates over BLE so you'll be able to get alerts if your battery starts to get too low.

![hacks_bleBatteryWarning.png](https://cdn-learn.adafruit.com/assets/assets/000/129/676/medium640/hacks_bleBatteryWarning.png?1714154910)

The code will pipe all keyboard inputs over BLE. Modifier keys will work as well. Advanced users could try modifying the code to remap keys or create a giant macro keyboard. You could also try adapting the code for a mouse or gamepad.

![](https://cdn-learn.adafruit.com/assets/assets/000/129/699/medium800/hacks_edited_P1440702.jpg?1714406438)


## Featured Products

### Adafruit ESP32-S3 TFT Feather - 4MB Flash, 2MB PSRAM, STEMMA QT

[Adafruit ESP32-S3 TFT Feather - 4MB Flash, 2MB PSRAM, STEMMA QT](https://www.adafruit.com/product/5483)
We've got a new machine here at Adafruit, it can uncover your deepest desires. Don't believe me? I'll turn it on right now to prove it to you! What, you want your very own soft serve ice cream machine? OK well, that's not something we can provide. But we can provide your...

Out of Stock
[Buy Now](https://www.adafruit.com/product/5483)
[Related Guides to the Product](https://learn.adafruit.com/products/5483/guides)
### Adafruit USB Host FeatherWing with MAX3421E

[Adafruit USB Host FeatherWing with MAX3421E](https://www.adafruit.com/product/5858)
Lots of microcontrollers these days have USB ports on them, to program or debug, act like a keyboard or disk drive, or simply&nbsp;send data between a computer and your firmware. But did you know that you can also add a USB Host port? That means that your microcontroller project can have a...

In Stock
[Buy Now](https://www.adafruit.com/product/5858)
[Related Guides to the Product](https://learn.adafruit.com/products/5858/guides)
### FeatherWing Doubler - Prototyping Add-on For All Feather Boards

[FeatherWing Doubler - Prototyping Add-on For All Feather Boards](https://www.adafruit.com/product/2890)
This is the **FeatherWing Doubler** - a prototyping add-on and more for all Feather boards. This is similar to our [FeatherWing Proto](https://www.adafruit.com/products/2884) except there are two! The magic of the Doubler comes when stacking a Feather and another...

In Stock
[Buy Now](https://www.adafruit.com/product/2890)
[Related Guides to the Product](https://learn.adafruit.com/products/2890/guides)
### Breadboard-friendly SPDT Slide Switch

[Breadboard-friendly SPDT Slide Switch](https://www.adafruit.com/product/805)
These nice switches are perfect for use with breadboard and perfboard projects. They have 0.1" spacing and snap in nicely into a solderless breadboard. They're easy to switch no matter what size fingers you have, but not so easy that they'll get flipped by accident. Work great as...

In Stock
[Buy Now](https://www.adafruit.com/product/805)
[Related Guides to the Product](https://learn.adafruit.com/products/805/guides)
### Lithium Ion Polymer Battery - 3.7v 2500mAh

[Lithium Ion Polymer Battery - 3.7v 2500mAh](https://www.adafruit.com/product/328)
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This battery has a capacity of **2500mAh** for a total of about 10 Wh. If you need a smaller battery, <a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/328)
[Related Guides to the Product](https://learn.adafruit.com/products/328/guides)
### Silicone Cover Stranded-Core Wire - 30AWG in Various Colors

[Silicone Cover Stranded-Core Wire - 30AWG in Various Colors](https://www.adafruit.com/product/2051)
Silicone-sheathing wire is super-flexible and soft, and its also strong! Able to handle up to 200°C and up to 600V, it will do when PVC covered wire wimps out. We like this wire for being extremely supple and flexible, so it is great for wearables or projects where the wire-harness has to...

Out of Stock
[Buy Now](https://www.adafruit.com/product/2051)
[Related Guides to the Product](https://learn.adafruit.com/products/2051/guides)
### Mini Chiclet Keyboard - USB Wired - Black

[Mini Chiclet Keyboard - USB Wired - Black](https://www.adafruit.com/product/1736)
Add a good quality, slim keyboard to your&nbsp;Raspberry Pi, Beagle Bone Black, or other single-board-computer with this sleek black chiclet keyboard. It's a full QWERTY keyboard with a USB cable and is compatible with all operating systems. We tried many keyboards to find one that felt...

In Stock
[Buy Now](https://www.adafruit.com/product/1736)
[Related Guides to the Product](https://learn.adafruit.com/products/1736/guides)
### Black Nylon Machine Screw and Stand-off Set – M2.5 Thread

[Black Nylon Machine Screw and Stand-off Set – M2.5 Thread](https://www.adafruit.com/product/3299)
Totaling 380 pieces, this **M2.5 Screw Set** &nbsp;is a must-have for your workstation.&nbsp;You'll have enough screws, nuts, and hex standoffs to fuel your maker tendencies&nbsp;for days on end! M2.5 size screws fit almost all of the Adafruit breakout/dev board mounting holes...

In Stock
[Buy Now](https://www.adafruit.com/product/3299)
[Related Guides to the Product](https://learn.adafruit.com/products/3299/guides)

## Related Guides

- [Adafruit ESP32-S3 TFT Feather](https://learn.adafruit.com/adafruit-esp32-s3-tft-feather.md)
- [Adafruit USB Host FeatherWing with MAX3421E](https://learn.adafruit.com/adafruit-usb-host-featherwing-with-max3421e.md)
- [Using a Keyboard with USB Host](https://learn.adafruit.com/using-a-keyboard-with-usb-host.md)
- [RP2040 RunCPM Emulator with USB Keyboard & HDMI screen](https://learn.adafruit.com/rp2040-runcpm-emulator-with-usb-keyboard-hdmi-screen.md)
- [NeoPixel Mini VU Meter](https://learn.adafruit.com/neopixel-mini-vu-meter.md)
- [Feather RP2350 Audio Reactive Video Synth](https://learn.adafruit.com/feather-rp2350-audio-reactive-video-synth.md)
- [Metro Minimalist Clock](https://learn.adafruit.com/metro-minimalist-clock.md)
- [AS5600 Super Smooth Rotary Encoder](https://learn.adafruit.com/as5600-smooth-rotary-encoder.md)
- [Adafruit Floppy FeatherWing with 34-Pin IDC Connector](https://learn.adafruit.com/adafruit-floppy-featherwing-with-34-pin-idc-connector.md)
- [Adafruit CAN Bus FeatherWing](https://learn.adafruit.com/adafruit-can-bus-featherwing.md)
- [Numpad 4000 Mechanical Keyswitch Data Entry Device](https://learn.adafruit.com/numpad-4000-mechanical-keyswitch-data-entry-device.md)
- [Pi SSD Media Server](https://learn.adafruit.com/pi-ssd-media-server.md)
- [MAC Address Finder](https://learn.adafruit.com/mac-address-finder.md)
- [Split Ortho Keyboard with TCA8418 Matrix Expanders](https://learn.adafruit.com/split-ortho-keyboard.md)
- [NeoKey Emoji Keyboard](https://learn.adafruit.com/neokey-emoji-keyboard.md)
- [RGB & HSV NeoPixel Dialer](https://learn.adafruit.com/rgb-hsv-neopixel-dialer.md)
- [Disconnected CO2 Data Logger](https://learn.adafruit.com/disconnected-co2-data-logger.md)
- [DIY Pico Mechanical Keyboard with Fritzing and CircuitPython](https://learn.adafruit.com/diy-pico-mechanical-keyboard-with-fritzing-circuitpython.md)
