3

I need to be able to connect a USB keyboard, like a tiny Xbox keyboard, or a nice wireless one, into an ESP8266-based thing to type passwords into the MCU. Adapting the PS2 lib for AVRs (PS2==USB pinouts for KBs) proved unreliable, so I tried a fake Pro Mini.

It worked much better, perfect with PS2, but only with a subset of my USB keyboards, namely a 104 Das Keyboard and an old-school Dell one. My 2002-era Mac keyboard doesn't work, none of my 5 wireless keyboards work, and neither do Xbox or foldable keyboards. Nothing that presents as a composite device works (like a keyboard with USB slots), only dead-simple (no fancy keys/knobs) keyboards seem to work.

  1. Would a USB host module (like the Uno shield, but not a shield) let me read from more than just basic PS2-emulating USB keyboards?

  2. Is the code to read basic alphanumeric keys consistent among different keyboards, or will each model need special instructions? (much like a driver would provide an actual OS)

  3. If it's anything but "plug and play", what would be a simple way (no soldering) to securely input passwords into an MCU?

EDIT:

Early USB keyboards and PS2 keyboards have the same pinout and behavior, so you can use a Pro Mini and the Arduino ps2keyboard demo to read such USB keyboards, either with a passive USB keyboard to PS2 male adapter for less than $1 USD, or via a female USB wired the same. Fancier keyboards don't work as such, at all, hence the possible need for a USB host module.

4
  • it is unclear what you are describing .... you say that you want to use a USB keyboard, but you talk about PS2 keyboard ... please update your question to make it clear
    – jsotola
    Jan 5, 2018 at 6:30
  • look at this arduino.stackexchange.com/questions/48447/… ...... use arduino nano
    – jsotola
    Jan 5, 2018 at 6:41
  • @jsotola: i want to type into the ESP w/ a USB keyboard, hopefully wireless, no PC in sight...
    – dandavis
    Jan 5, 2018 at 8:04
  • some, maybe most, usb keyboards have a "boot keyboard mode" ( or something like that), that is used to allow keyboard functionality when navigating bios menus. .... arduino usb host module should work for you. ... the problem is figuring out the software
    – jsotola
    Jan 5, 2018 at 8:20

2 Answers 2

4

My 2002-era Mac keyboard doesn't work,

That doesn't surprise me - modern Macs have never needed PS/2 support.

none of my 5 wireless keyboards work,

That's because they're not keyboards, they're wireless transceivers that provide USB HID interfaces.

and neither do Xbox or foldable keyboards.

Too modern, and of course XBox has never needed PS/2 support.

Nothing that presents as a composite device works (like a keyboard with USB slots), only dead-simple (no fancy keys/knobs) keyboards seem to work.

Of course, they aren't PS/2 keyboards, they're USB devices.

Older keyboards provided dual operation - USB and PS/2. This is a function provided by the keyboard, not the USB standard. Mac keyboards, since the Apple computers never had PS/2 ports (since PS/2 is an IBM standard from the PS/2 computers back in the 80s & 90s). Modern keyboards that provide more than just a simple keyboard functionality cannot really provide PS/2 as well since that can't provide the other features of the keyboard. The same goes for composite devices, or wireless devices - they facilities they provide are in excess of what PS/2 can provide, so it would be illogical trying to provide PS/2 support - especially as PS/2 ports are getting rarer on computers now.

Would a USB host module (like the Uno shield, but not a shield) let me read from more than just basic PS2-emulating USB keyboards?

Sure, if you can get the libraries working on the ESP8266, which may well be a huge challenge in- and of itself.

Is the code to read basic alphanumeric keys consistent among different keyboards, or will each model need special instructions? (much like a driver would provide an actual OS)

All USB keyboards are class-compliant HID devices. They send HID reports in a standard format, maybe with custom additions. The basics are always the same though.

If it's anything but "plug and play", what would be a simple way (no soldering) to securely input passwords into an MCU?

It'd be far from "plug and play" getting a USB host interface working with the ESP8266. Consider other more simple routes, such as using serial, or configuring the ESP8266 as an access point and using a web browser to configure it.

1
  • i feel slightly battered, but much more informed; thanks for your time. i guess i'll have to have it "learn" a cheap IR kb...
    – dandavis
    Jan 5, 2018 at 19:44
1

The USB Host Shield Library 2.0 has supported the ESP8266 for about a year. Support for the ESP32 was added more recently.

The following is a link to the project README listing the supported boards and microcontrollers.

https://github.com/felis/USB_Host_Shield_2.0#boards

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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