0
\$\begingroup\$

I'm working on something at the moment that uses an ESP32. I would like to have simple strings that I can specify within the ESP32 code to automatically "type" on the screen. For example, if I did keyboardWrite("Hello World") and I had a blank notepad open on the PC/Mac, it would automatically write Hello World.

I realise the ESP32 does not have a USB interface, so I decided on using an MCP2210(SPI->USB bridge) to take information (simple strings) from the ESP32 via SPI and then transfer them to the PC. Microchip claims that it is a plug n' play device however they supply a .dll to develop applications for it.

My question is - is there any way to carry this out without having to develop/install any custom software or drivers or any .dll and it would simply be a plug n' play device for PC/Mac. For example, is there any way to embed the functionality of sending keyboard strokes from the MCP2210 itself, rather than through an application on the PC/Mac.

In short, how can I interface an ESP32 to USB to emulate a USB keyboard without any extra software.

\$\endgroup\$
4
  • \$\begingroup\$ Welcome to EE.SE. It's not clear what WiFi and BLE have to do with your question which, I think, can be summarised as, "How can I interface an ESP32 to USB to emulate a USB keyboard?". \$\endgroup\$ – Transistor Aug 5 '18 at 21:04
  • \$\begingroup\$ My apologies. I'll clear this up now. \$\endgroup\$ – FShiwani Aug 5 '18 at 21:05
  • 1
    \$\begingroup\$ I know very little about this but suspected that some of the Arduinos can do this. Read Arduino.cc's Keyboard page to get a flavour of the problems you might encounter. A quick search for USB keyboard emulation will give you a load to digest. \$\endgroup\$ – Transistor Aug 5 '18 at 21:13
  • \$\begingroup\$ Do you need USB or could you use bluetooth HID as a keyboard? I've used the FLipMouse project to send keyboard commands to a PC/phone via GPIO contact closure on an ESP32 github.com/asterics/FLipMouse-esp32 \$\endgroup\$ – nvuono Feb 6 '20 at 19:38
0
\$\begingroup\$

USB devices never send anything on their own. To operate, they need a driver on host side to initiate transfers.

In most cases with odd bridges the USB devices are designated to "miscellaneous class" 0xEF, and need a device driver to start communications/device configurations. Usually MCHP supplies these drivers that need to be installed. Then these bridges use proprietary interface to get actual data in and out. That's why you need a library of various API calls on host side, and write an application that uses these calls to communicate with USB bridges as MCP22xx.

The MCP2210 bridge uses HID class as its basic interface, and thus it uses standard OS drivers, with no need of MCHP proprietary drivers. That's apparently is their definition of "plug-n-play". However, conformance to HID class doesn't mean automatically that it is a keyboard, it can be mouse, or joystick, or barcode reader, so you still need their tools and libraries to configure the bridge and send/receive SPI data.

\$\endgroup\$
14
  • \$\begingroup\$ Wouldn't emulating a keyboard work as the USB keyboard drivers are usually there by default. No development work required on Win, Lin, Mac, etc. \$\endgroup\$ – Transistor Aug 5 '18 at 21:08
  • \$\begingroup\$ I'm just curious why Microchip advertises it as Plug n' play if you always need a .dll incorporated within an application for it to function. Like - I literally just need it to type a few letters based on what the MCP2210 is getting from it's SPI bus. \$\endgroup\$ – FShiwani Aug 5 '18 at 21:09
  • \$\begingroup\$ OK, as commented under the original question, I know little about this. I thought this would be configurable in the MCP221x (whatever that is!). \$\endgroup\$ – Transistor Aug 5 '18 at 21:16
  • \$\begingroup\$ @Transistor, actually there might be a difference, MCP 2210 does advertise in datasheet as "HID class", unlike MCP2221. \$\endgroup\$ – Ale..chenski Aug 5 '18 at 21:18
  • 1
    \$\begingroup\$ If your device tells OS it is a keyboard it should behave as real keyboard, i.e. use same protocol other keyboards use and send scan codes, not letters. It is a task for several layers of drivers in OS to transform scan codes into letters of currently selected language in currently active upper/lower case, locale etc. \$\endgroup\$ – Maple Aug 5 '18 at 23:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.