Public Lab is launching a new 🎈 Mini Balloon & Kite Kit as part of Kickstarter Gold -- take a look!

  • 1

Question:Getting a Raspberry Pi to output data by emulating a keyboard

warren is asking a question about raspberry-pi: Subscribe to answer questions on this topic

warren asked on April 29, 2017 20:28
210 | 1 answers | shortlink

What I want to do

Folks are using the Raspberry Pi, a cheap stripped-down computer available for as little as $5, to connect to sensors, record weather data, and even run a DIY spectrometer. But it's hard to get data off of them easily, and hard to set them up.

But there seem to be ways to get them to "act like a keyboard" and, when connected to a computer by USB, to simply "virtually type" out data. This would work on Windows, Linux, and Mac, and be really simple -- no mucking around with Bluetooth, WiFi, SD cards, etc.

I've found a lot of resources on this:

Two approaches to getting a Pi to "act like a keyboard" using the "USB Gadget" system and the "HID" (human interface device) spec:

There's guidance on how to actually use and test it here:

And a bit more on the actual codes and how to get it to "type" any text here:

Ideal outcome

What I'd really like is an image of an SD card with all of this set up already -- or a script that'll run on an image very straightforwardly. That way this could be set up with minimal difficulty by folks who are trying to do sensing with Raspberry Pis!

Anyone want to take a crack at it?


Made some progress; i've gotten the "ethernet" usb gadget to work as shown here (and found this much simpler instruction set with lots of helpful comments)

I found there's an actual utility for piping text to the "virtual keyboard" from the commandline:

Also found this Android-based implementation with a utility to actually output the correct codes to the device once it's running: (although the above does this too)

raspberry-pi usb ease-of-use keyboard hid

question:raspberry-pi question:data-logging


Log in to comment

1 Answers

I think this should be relatively easy if you are using the Pi Zero. See

But for all other Pi devices I think it is not possible without hardware mods since they do not have support USB OTG. See

Sign up or Login to post an answer to this question.