Bluetooth HID using just an ESP32 (inc Bluetooth macro keypad)
Vložit
- čas přidán 8. 02. 2020
- In this video we are going to take a look at using the built-in Bluetooth of the ESP32 to emulate a Bluetooth Keyboard.
With some ESP32 development boards starting at less than $5 delivered, this is a really inexpensive and simple way to create wireless custom keyboards such as a Macro keypad that could be used for controlling scenes in OBS.
We’ll first look at how to use the ESP32 HID keyboard library and then I will show you how I used this to build a battery powered Bluetooth Macro Keypad.
---------------------------------
Software used:
---------------------------------
ESP32-BLE Keyboard library: github.com/T-vK/ESP32-BLE-Key...
Code for the macro keypad (inc new Bluetooth one):
github.com/witnessmenow/ardui...
---------------------------------
Hardware used:
---------------------------------
D1 Mini ESP32 Board*: s.click.aliexpress.com/e/_rujrNG
TinyPico ESP32 Board: www.tinypico.com/
4*4 Matrix Keypad* - s.click.aliexpress.com/e/nKw2LcCu
USB Bluetooth 4.0 Dongle*:
Amazon.co.uk: amzn.to/2uuZovu
Amazon.com: amzn.to/39oGvtg
Amazon.de: amzn.to/2S9DS8C
---------------------------------
My Discord:
---------------------------------
Come hang out and talk about this video or any project you are working on!
/ discord
---------------------------------
Github Sponsorship:
---------------------------------
I have set up a Github Sponsorship page, it's similar style thing to patreon, but Github are offering to match all sponsorships for the first year! (you sponsor $2, I receive $4)
github.com/sponsors/witnessme...
Some people have said they would prefer a once off way of supporting the channel, here is a Paypal link if you would prefer that!
www.paypal.me/bloughyt
---------------------------------
My Tindie Store:
---------------------------------
I've started to sell stuff on Tindie, check it out!
www.tindie.com/stores/brianlo...
---------------------------------
Other Platforms:
---------------------------------
Twitter: @witnessmenow - / witnessmenow
Instagram - / brian_lough
Instructables: witnessmenow - www.instructables.com/member/...
---------------------------------
Support the Channel:
---------------------------------
If you would like to support the channel, here are some ways you can.
1 - Like and comment on the videos - I really like hearing from you and apparently it helps!
2 - Share my videos - If you know somewhere that might be interested in my channel, please share it!
3 - Affiliate links - Where I get a small percentage of the purchase price but doesn't cost you anything extra.
Amazon.co.uk: amzn.to/2g7mJIO
Amazon.com : amzn.to/2ykDQ42
Amazon.de: amzn.to/2WMq7vF
Aliexpress: s.click.aliexpress.com/e/wdhojba
LCSC (where I buy most of my parts for Tindie stuff): lcsc.com/?promote=ODM5ZTB5Nlk...
4 - My Amazon "store" - Really it's just a collection of stuff I use that I think are useful
www.amazon.co.uk/shop/brianlough
5 - Check out my Tindie Store
www.tindie.com/stores/brianlo...
---------------------------------
My Tools & Kit*:
---------------------------------
Ender 3 Pro 3d Printer - I got one of these recently and I love it!
- UK : amzn.to/31bebXT
- US : amzn.to/2IlSLid
Ts-100 Soldering Iron - I have this a couple of years and I love it, I thinking about getting a second!
- UK : amzn.to/2nlOF23
- US : amzn.to/2jDcyxl
Logitech C920 HD 1080p Pro webcam - I use one of these for my videos
- UK: amzn.to/2pnxk9Z
- US: amzn.to/2BsLMiF
Blue Snowball USB Microphone
- UK: amzn.to/2C0x4TH
- US: amzn.to/2DEA85J
Self Adjusting Wire Strippers
- UK: amzn.to/2C0urkR
- US: amzn.to/2BXQAh1
*= Affiliate Links - Věda a technologie
Perfect timing. I've been thinking about making a Bluetooth macro keyboard for the last week or so to use while drawing on my Surface Pro. Most of the official tablet shortcut key devices use a dongle, are wired or cost a fortune. I didn't really want to use up the single USB port. I think this will do perfectly. Thanks Brian.
Thanks for all your informative videos and I would suggest that you add a part II to this video which includes ESP32 interrupts to make it more battery friendly. I look forward to watching another great tutorial from you.
Brian - this video solved an issue I had with HID on the ESP32 for a looooooooong time. So thank you very much. This deserves a like, subscribe and a share.
That's great! I have been planning a Bluetooth hid video for a while, but using the gist method, but i had some problems around pressing multiple keys I think. I found this library a couple of weeks ago and couldn't believe how simple it made it!
Excellent work from you and the BT library writer. I got an ESP32 with inbuilt OLED - my planned usage is to wire in a couple of footswitch operated buttons to send page up/down to an Android music page turner app. Should be considerable cheaper and more versatile than commercial hardware.
I’m brand new to this. This was very helpful! Thank you!
This was a super useful and well made video, cheers man 👍
The ctrl+alt+delete every 100ms and awkward part gave me a good laugh! Good stuff
Awesome project Brian!!
Thanks for all this. That's what I needed for my project and it works fine !
Dude, you are a genius. Thanks for this!
Thanks Brian, just what I was looking for.
Thanks you for share it, it is perfect to make a custom wireless keyboard and more!!
Thank you, works perfectly on esp32 too, you just need to change the pins.
THANK YOU! This is just what I was looking for.
Great timing, just started working on a small project that's in the same vein. I'm putting together a wireless (BT) volume knob using an encoder and some media control buttons, so all this info will be really helpful.
This sounds perfect for this, I haven't tested the volume media button commands but I imagine they work fine !
A couple of cheapy slider potentiometers, for mic & speaker, a lil 3d design/printing for a case. U could even go look at some of the esp/Arduino midi controller projects for a variety of DIY inputs, i made an esp32 pressure sensitive drums and button combo midisynth a few months back(still haven't made the case or its own amp for it, but it's fun wired up to an old stereo).
Excellent work!
Thanks.
I love the library, I'm using it for a game controller !
Thanks Brian, well done!
This is the video I am looking for. Exact tech for the same use case for OBS. Thanks. Ok, next day. Just plugged everything in, set up the IDE for my ESP32, installed the code and it worked perfectly. Next is getting that battery set up for wireless, although how I have my OBS set up with my laptop, It's fine even with a powered ESP32. I typically use the number keypad on a full size keyboard for OBS hotkeys and even and a Bluetooth number keypad that I bought for remote use. That's set up where I normally stream with a full computer. This is going to be the remote for mobile streams.
Excellent work. I was ran out of space on a digiStump. And promicro didn't like to compile. Never used the ESP8266 but looks like I am going to thanks!
I have two applications - one to use old PS2 keyboard to control computer games (so I can map.keys to USB but if I can instead send via Bluetooth then even better)
The 2nd app - to send Bluetooth to Android app to operate sheet music viewer. I do this at the moment with a Bluetooth keypad and some mechanical foot switch. With the above I can simply make a couple of buttons and send page up / page down.
Thanks again for sharing.
I know it's an old comment but for everyone's information, he used an ESP32 here, not ESP8266. ESP8266 doesn't have Bluetooth (and some deviations of ESP32 may not have it either).
Hope your project worked out great!
I think this could make a very useful mqtt keypad for triggering home automations via bluetooth to a rpi running eg node red. Ive a number of modified tradfrei switches (A Speisse video) with 5 buttons for this purpose, but I always seem to need one more button. This plus a little screen could make a menu driven, keypad for such use.
Very nice video, thank you for making it...
It would be great to have the codes in a file stored onboard that would be accessible like a drive over the USB connection. That way you wouldn't need to redo and Arduino code when you want to change a button function.
Thank you that was a great video - helped me a lot.
great video, thanks for your work, something that I would like is the implementation of the creation of a virtual "Com" position through esp32 and thus be able to use devices through my network, greetings from Mexico
Thanks for sharing this !!
Very helpful! Thanks!
This is really valuable. Thanks
Your welcome!
Interesting stuff !
Great video.
I think I'll use this for when my mobile is in the case 8n the motorbike.
Unlocking the screen and other basic functions are difficult when wearing gloves and not safe during motion.
Really helpful. Thank you.
Can you tell me how long it takes the device to reconnect to the pc? I know it can vary, but I wanna know if it's a viable solution to a shortcut keyboard which goes to deepsleep between presses.
Hi. I'm trying to make the ESP32 Bluetooth that you posted on CZcams, but I'm a total layman and I can't understand it. Would you have the sketch ready to download to the ESP32, .ino file? Would you mind sharing it?
Hey, awesome video, thanks for sharing!
I'm looking forward to making a similar build but my use case is different and I need it to be as small as possible, is there a smaller version of ESP32? or of a keypad that isn't setup like the one you have but rather, a single button? I'm only need 3 but 4 would be nice.
Any ideas?
Thanks alot!
I tried programming a BLE-Keyboard in MicroPython and failed miserably. I guess i have to learn the Basics of Bluetooth. The T-vK/ESP32-BLE-Keyboard Library works out of the Box, connecting to a Windows 11 Machine instantly. I will continue from there, this looks quite easy.
I like it. It seems that it can emulate the keyboard on a Windows O/S PC. What is the equivalent key modifiers for Mac O/S? For example: Shift + Command + Control
Nice tutorial. Did you have issue with bluetooth not automatically connect after a power cycle?
Hey, great project. Does your code handle the situation of idle user time where it reduces power consumption if nothing has been pressed?
Top of the pops! 👍
Can you explain that magical on/off switch of yours? I searched Digikey but couldn't find a "cardboard" part. ;)
Great project. Inspired me to try a 4x4 BLE keypad for a button box for a game.
I cant seem to get rid of the CTL ALT DEL (which is confusing the game) without an error compiling.
Any suggestions Brian.
you are awesome ... as you know :) ... one Q , instead of BLE .. is it possible to emulate real usb ? so i connect the esp32 usb to my pc and act as digispark to send keyboard keystroke to the pc?
this is realy helpful fo rme to understand the use of BLE keyboard library! However, im interested in making usb2bt converter for my TKL-sized mechanical keyboard. do you have any advice on starting buiilding it using esp 32? it would really help me out to do this project. cheers
Thanks! How can I control the bluetooth power in the ESP32? make it more or less
thanks you very much!!!
very good thank you!
can you use the ESP32 create a project NB-lot control temperature drive ...........
How would you add a regular single push button to this in stead of a push button matrix?
Hey thanks for the detailed video, i have just come across it, question Is it possible to use 28 buttons? I have 28 commands,
How can i do to achieve the oposite? I have a bluetooth joystick, and i wanted to connect it to my esp 32 and extract the signals from the axis.
Will this work on a Wemos D1 Mini which has an ESP8266? It's a very informative video! I didn't know it could work over bluetooth.
I want to serial Bluetooth to hid Bluetooth keyboard ... Possible in one board ??
Very interesting video. Can I use this on an ESP8266?
Hello Brian. I am a few years behind you, following the same path as you. Have you learned much over the last couple of years that you want to share ? I am in the middle of a project, and very hung up on the implementation of a small/tiny bluetooth keyboard.
Any chance you could keep sharing some of your data ?
can this be done if I've only got a USB output header on the keyboard? D+ and D- instead of the 8 pins like the keypad.
Hi, I've tried with the example and esp32keyboard is not showing up in my bluetooth options for my laptop. I am using a Macbook. How am I supposed to do the pairing?
Nice Video
I have a question, would this work on an iOS device like an iPad? Are the keystrokes the same on something like an iPad?
Hi Sir can you make a ble mouse ? Joystick , for controlling onscreen cursor ?
Hi. I confused. How i make a 2(rows) x 4 ( collums) ? I need a diagram and the code.
I’m having trouble deciding what battery to use with mine. Any pointers?
ı have always faced problems with the bluetooth why not ESP8266 wifi with lower power consumption and benefits of 2.4 ghz?
I have trouble with this library, that i am must reconect wheen esp32 sleep
Can we use it in wired mode? Like the Arduino Leonardo.
Can I control vol up and down of my android phone using this library with Arduino board+BT hc 05 module,,?? Thank you,
trying to build this, does anyonre know of any smaller batteries/battery packs i could use?
can this be used with a usb host to make a wired usb keyboard wireless?
Hmm but if i want to use their Mouse Library as well, i would have to disconnect and connect again with the other device constructor. With HID-Project for example over USB, you can send either keyboard or mouse codes
Wait, it really different, the old one or from evan kale it self, to convert your old wired hid, keyboard or mouse into wireless mouse with bluetooth
dude, my Bluetooth conection didnt always fixed, it always in pairing mode after unused for couple of minute
Windows 10 does not connecting to esp32 keyboard. It seen in bluetooth. But it says "Try connecting your device again". Any suggestions?
Hello! Nice project! I made similar project, but got following problem: Android is connected to this HID Keyboard, but if I send every 100ms for example 1 key - 1 second it does not send anything and then after got all those 10 presses. (Very bad response time). Do You know how to to fix unstable timing for key presses? (I am using ESP32 as external arrow buttons for my android phone to control map with 4 arrows and Letter C)
Does it for the 'Enter' key?
i've seen a few videos like this and feel compelled to ask.
what does the "inc" in the title mean?
con el poco ingles que yo se y me pense que estabas haciendo un pad de estos modernos para tocar musica y lanzar muestras pero en pequeño y bluetooth, pero no, debe ser para una puerta.
Does this work on the older d1 mini?
thanks for your video. i learned something. Is it also possible to use an ESP as a Bluetooth receiver? I was thinking of an AB shutter3 or keyboard to switch a GPIO port.
Technically possible, but I haven't seen a good implentation. Search for "ESP32 BLE HOST"
hi Brian, can you make tutorial for programable wireless esp32 macropad using QMK and VIA?
is there any update regarding the battery level ?
hey, thanks for the tut! can this be used as a controller for a diy keyboard (where you solder wires to the switches without using a pcu).
Also can this be used to make a keyboard that has a wired only pcu have bluetooth compatibility? thanks again!
If you can read the inputs from the keyboard I don't see why not. A full keyboard, even using button matrix or something, would use a lot of pins
How long does the battery last you before you have to charge it again?
Can I add a password authentication before paring?
Hi, is it possible to use the keyboard without Bluetooth?
Hi. Great work
I wanted to know if there's any way uptill now that we can use esp32 an an HID wired keyboard. Just like people have implemented it on stm32
Nope, ESP32 doesnt support HID over USB. ESP32-S2 should, but I havent tried it
Can you do the same, but without bluetooth?
I was looking for a tutorial for converting wired keyboard into bluetooth keyboard.
Could you us this to create a keyboard bluetoothifier? Connect and power a keyboard via usb OTG, listen to incoming keycodes, send those over bluetooth HID to the main PC? Not the world's speediest bluetooth but, hell, the flexibility!
In theory yes, but usb host is not very straightforward. But if you could do the usb host part you definitely could
@@BrianLough Yeah I had a look into it and using an OTG cable helps (they have a 5th pin grounding the drain wire). The leaf can't charge a lipo though can it? Neither can a pi pico without a shim. I'm struggling to find a way to get it put together affordably - i suspect there's board out there.
Can i connect a full laptop keyboard (an Alienware 15r3 to be precise) to that controller an turn it into a "normal" bluetooth keyboard to use on my desktop PC? I just love the feeling of that keyboard and would like to use it on PC
If you could integrate the keyboard with the Arduino then you could in theory make it
Can you still purchase the tinypico you use in this video? Seen similar looking ones but they are very expensive now.
I believe the tinypico available now is a different revision but it's essentially the same
its awesome
Thanks man! Can I use it as a keyboard and in parallel send information to an application on the smartphone without print the key or an entire word?
Someone can help me?? using the bluetooth as keyboard will affect the use with a smartphone application?
hello, how to connect it with android phone?
Hi.
I'm trying to understand how to redo function on the number 1 on the keypad.
1 on keypad should be used for play / pause
2 for "next"
and so on.
Can do make a simple example that shows how to do
so I can get started
Please John
just replace sendMacroCommand(KEY_F1);
with
bleKeyboard.press(KEY_MEDIA_PLAY_PAUSE);
bleKeyboard.press(KEY_MEDIA_NEXT_TRACK);
bleKeyboard.press(KEY_MEDIA_PREVIOUS_TRACK);
ig this will help u
for more help just comment on any one of my video
@@thecreatorandreviewer9680 Hello , do know where i can find list of all keycodes , John
I used tesp32 ble a while ago when wow classic came out and people had to not go afk in the login q
Wow that is really cool. Now has anyone done the opposite, use a real Bluetooth keyboard to send key presses to an ESP32 and let the ESP32 turn on motors, lights etc with GPIOs?
There is someone on my discord who has done some work around getting BLE gamepads working on the esp32, not sure about keyboards, you could ask him though, bitbank is his name on there, link in the description
I'd like to build an adaptor that turns any wired keyboard into a BT/wifi one, plus adds multimedia buttons and volume knob - buy any low-cost wired mech and have the benefit of expensive wireless mechs with extra fruit! Can I use a tinypico (or similar) and this library to do this? Is it just a matter of reading the key-press and sending it on with these library constants? Will it work for all keys including modifiers and such? And can I use the same USB port as both an "in" (for charging and control when hooked to a PC) and an "out" (for providing power to the kb and receiving keystrokes from it when hooked to a kb)? Sorry for so many questions, just wondering if it's possible and if a tinypico is the way to go. Thanks
Hey, a few things to get through, but I'll try!
The TinyPico is an ESP32 board, so the same will apply for all ESP32 based boards.
1) This library should be able to emulate the keyboard fine, I was using modifiers in my example so I don't think that should be a problem, I haven't done much more with this library than shown here though.
2) No, you will not be able to receive USB commands via the micro USB cable. Check out this video by Bitluni where he uses an external chip to act as USB host, but it's still early in development. czcams.com/video/po3FBdY0GS4/video.html
The other part of this question, the USB port will charge the battery when plugged in.
@@BrianLough Thanks so much!
Brother. You use the Esp32 program. If you can share it quickly.
awesome
can i use to diy controller ps4 ?, im from vietnammese, so my english so bad
Gaming buttons? I suppose that would be a BLE game controller.
This could be a noob question, but I want to know will I be able to use an esp32 as a wired hid keyboard? Will this library work?
Nope, doesn't support hid through USB
Hello friend, sorry for any errors in this text (I'm using Google Translate). I'm thinking about transforming my keyboard (wired Razer Huntsman) into a wireless keyboard, do you think that using the DOIT ESP32 - ESP32-WROOM-32D I can do it?
Not on its own. You need something to read the input from the razer keyboard. What you are looking for is a "USB host". There are some shields that can do it, or something like the rp2040 can either