top of page

Fitness Group

Public·60 members
Isaiah Ward
Isaiah Ward

Emulating A Bluetooth Keyboard With The ESP32



One option would be to emulate a bluetooth keyboard, and skip the USB altogether. This device made me think of it Bluefruit EZ-Key - 12 Input Bluetooth HID Keyboard Controller - v1.2 - discontinued, but they probably make something else now.




Emulating a Bluetooth Keyboard with the ESP32


Download File: https://www.google.com/url?q=https%3A%2F%2Fvittuv.com%2F2tU5hC&sa=D&sntz=1&usg=AOvVaw1CWz9A97-UKqNuyyJv3nkh



Newer boards and microprocessors have migrated to a new type of USB interface called TinyUSB. It is likely that most future boards will take advantage benefits of the TinyUSB platform. Additionally many new boards provide Bluetooth BLE capability that can emulate Bluetooth mouse and keyboard devices. Both TinyUSB and Adafruit Bluefruit libraries have powerful capabilities for emulating mouse and keyboard. However these APIs are not fully compatible with the old traditional Arduino Mouse.h and Keyboard.h APIs. Lots of legacy code has been written using these older Arduino APIs.


In this tutorial, 2 new libraries are presented which convert the traditional Arduino APIs into calls to the newer TinyUSB and Bluefruit commands. Although TinyUSB and Bluefruit HID interfaces provide capability not available in the traditional Arduino Mouse.h and Keyboard.h interfaces, these new conversion libraries will let you run legacy code and will be a stepping stone for new users to become familiar with mouse and keyboard emulation using a simpler interface. Using these simpler libraries does not require as much direct knowledge of USB and BLE protocols.


There are two different methods of transmitting USB data between your microcontroller board and your PC. They are called "USB Stacks". They are layers of code that handle all of the protocols for transmitting data whether you are using it to upload your program to the board, receiving data via the serial monitor or serial plotter, or talking back to your computer emulating a mouse, keyboard or other device.


The other library we used in this tutorial relied on communication over a USB cable between your Arduino device that was emulating mouse or keyboard and your PC, tablet or other similar device. However many PCs, tablets and other devices allow you to connect a mouse or keyboard using Bluetooth Low Energy or BLE for short. Establishing a Bluetooth link between your board and another device is pretty complicated programming. This library attempts to not only translate the traditional Arduino Mouse and Keyboard API calls into a BLE call, it also isolates you from all of the overhead necessary to establish and maintain a Bluetooth link.


In this section, we will try running one of the sample programs and pairing it with your PC, phone, or other device capable of using Bluetooth mouse or keyboard. We will show you how to do this pairing on a Windows 10 computer but the process should be straightforward on other operating systems or platforms.


Note that there is no way to separate Mouse and Keyboard inclusion in our system. It was much easier to implement both at once rather than implementing them separately. Your board will present itself over Bluetooth as a single Bluetooth device with both mouse and keyboard capabilities. It is possible that if you do not use Keyboard for example and only Mouse that the linking loader will eliminate the Keyboard code from your final compile and vice versa if you use keyboard and not mouse. However the nRF52840 has plenty of program memory and it shouldn't hurt if we have to waste a little bit on applications that use mouse or keyboard but not both.


In the examples folder of the TinyUSB_Mouse_and_Keyboard library you will find 3 sample programs. The BLE52_Mouse_and_Keyboard library also has three similar files. There are only minor differences between the two. The BLE52 version will attempt to pair your nRF52840 with your PC or other device. See the earlier section on how to do the pairing. Once it is paired you should not need to pair it again and you can run on the examples with no further effort. The TinyUSB keyboard example looks like this.


In the examples folder of the TinyUSB_Mouse_and_Keyboard library you will find 3 sample programs. The BLE52_Mouse_and_Keyboard library also has three similar files. There are only minor differences between the two. The BLE52 version will attempt to pair your nRF52840 with your PC or other device. See the earlier section on how to do the pairing. Once it is paired you should not need to pair it again and you can run on the examples with no further effort. This TinyUSB example combines both mouse and keyboard capabilities. It looks like this.


Notice that approximately line 31 of the BLE52 version of this program we only check for Mouse.isConnected(). We previously mentioned that your board presents itself as a single USB or BLE device with both mouse and keyboard capabilities so you only need to check if one is connected.


hey guysso ive been working on a project where I use a rotary encoder as a bluetooth controller.I've already used it to write to the serial monitor like if i turn clockwise it says clockwise and vice versa.what I want to do now is have my lolin32 lite act like a bluetooth keyboard,it will send a w if i turn clockwise.I've searched for a couple of hours but I've found nothing that works yet.kind regardsEthan


The new box I made had more of an ergonomic pitch that matched my keyboard, starting at around an inch high in the back and thinning down to around half an inch in the front (making sure to leave room for the Cherry MX key body). I used CA glue to hold five of the six sides in place, and black electrical tape to keep the top in place. I was pretty happy with the shape and feel, and I reclaimed some of the functions the previous keyboard had, plus a few new ones:


Hi Alex! Great post! In my experience, BuzzardEagle can use all the help it can get! (I prefer to use KiCad or gEDA, though the latter hasn't had much support in recent years).One thought: It seems to me that an Artemis solution might allow for even lower power consumption, and has enough pins that you could switch (pardon the pun) from a voltage divider scheme to a grid pull-up/pull-down scheme for the keyboard interface. (Pardon me -- I'm not very familiar with the ESP-32 -- looking at the Thing Plus page, it looks like maybe it has enough GPIO pins to do that, too, but I haven't looked at the "wake-up" capabilities.)


-I opted for a micro-controller as this would allow me toprototype without worrying about my electronic skills. Thecontroller needed to have battery control, bluetooth, andpreferable an energy efficient screen; I ended up with anesp32.


The esp32 is a hybrid chip that has both Wi-Fi and bluetoothcapabilities. The esp32 consists of different versions thatvaries in (mainly) in the number of pins, battery connector,and or screen. The version I ended with (LORA-V2) had abattery connector and a tiny OLED screen.


Especially important (as it turned out later) is that theesp32 has the capabilities of using both Wi-Fi and bluetoothlow energy simultanaously. In addition, through ESP-NOW,different eps32 modules can form a mesh, which I willharness to do server-client communication.


A layer is implemented as a 2D vector for the moment, butwill likely change in finalizing the keyboard. An activelayer is set as a pointer to the current active layer. Eachkeyswitch has information on where in the grid they fit;keys are read by using these indices in the 2D vector. I didconsider an unordered_map use the keyswitch directly as anindicator. This could then be combined with pointers to makea layer dynamic, i.e. instead of having the concept oflayers, each key has a different layer that can be accessed.This adds some complexity and I decided against this. Themain reason is that the client side would then need to storeinformation on what each keyswitch points to. This wouldincrease communication between each halves if modifiers areused for example. I am afraid that this added communicationis not as trivially solved, i.e. one needs to send modifierkey across ESP-NOW and then shift all affected keys and whenactivated send this information back. The ESP-NOW channel isnot designed for high information throughput.


When not in use I aim to put the keyboard in deep sleep.Some pins on the esp32 can be used to wakeup the keyboardfrom deep sleep. The RTC_GPIO pins and Touch pins can beused for waking the device from deep sleep. The RTC pins are


Luckily, my keyboard will only require 5 + 6 = 11 pins.There are in total 10 touch pins which would make this apossible target if they work. Initial testing shows that atouch wake up would work with a touch threshold of 45. Thiswould require either the columns or the rows to be hooked upto the touch sensors. By monitoring any current change ofthe rows or columns would result in the board to wake upfrom sleep (which is ideal). 350c69d7ab


About

Welcome to the group! You can connect with other members, ge...

Members

  • jaibarra3
  • Shapiro Bathrooms
    Shapiro Bathrooms
  • Ojasvi Jain
    Ojasvi Jain
  • Snehal Kulkarni
    Snehal Kulkarni
  • Hawaii Facial Plastic Surgery
    Hawaii Facial Plastic Surgery
bottom of page