Technical Playground

Simple Bluetooth LE USB Keyboard


I’ve been interested in Bluetooth LE ever since going to WWDC 2012 during the CoreBluetooth sessions. An easy, wireless, no-MFI (Made For i) device interface to do pretty much whatever you wanted. Unfortunately, like a lot of my ideas, my time to work on it languished more than I’d care to admit. Recently, I came across a different problem – interfacing with embedded computers without requiring a separate keyboard and mouse. The idea hit to try using a a BLE device with a USB interface to emulate a keyboard and control it via my iPhone.

Initial Experiments

For simplicity’s sake, I started with an Arduino Leonardo and one of Red Bear Lab’s BLE shields. This shield uses one of the Nordic NRF8001 chips. I was able to get the BLE test applications working properly but this did nothing for any kind of keyboard setup. I found a webinar and some details on how to modify the shield code and interface more directly with the Leonardo. The nRF8001 is a SPI-ish device and setup is controlled by whatever Arduino library (or other microcontroller) you prefer. I experimented with this a bit further but never got everything working the way I wanted.

I moved on to a different shield, one of Dr. Michael Kroll’s BLE-Shield 1.0 devices. These use the BlueGiga BLE-112a devices (which are in turn TI CC2540 based) and are pretty flexible. The board is a little expensive (~$60 USD), but it tends to be way more accessible for certain things. Given that this board is setup as a BLE interface to the UART on the Leonardo, this makes my basic testing very easy. I found one of Dr. Kroll’s examples showing any data received on the BLE side printed to a serial output on the Arduino side. For my purposes, I modified this to use Keyboard.write() instead:

void setup()
  // Set the data rate for the Software Serial port

void loop()
  if (Serial1.available()) {

I uploaded the code and connected the Leonardo / Shield combo to a Raspberry Pi I had available. Using the included BLE-Shield iPhone app, I was able to type characters on my phone and have them appear on the RaspPi’s screen. Now this code works, but doesn’t properly handle control characters nor can it handle more than about 12-15 characters at once. I’m working on the code for a UART based protocol that properly handles receiving data, typing it on the remote device, etc.

Excited by the options, I debated building a simple board containing a BLE chip and an ATMEGA32u4 (the same one used in the Leonardo.) While I’m still working on this for practical purposes, right now I’d point to 3 other projects that have appeared in the past week:

  • Babuino – This is an interesting implementation, offering a simple stick device, or a breakout style board. You also have the option of traditional Bluetooth (easy for Android or desktop devices) as well as BLE (iPhone / iPad / newer Macs, etc)
  • BLEDuino – This is almost exactly what I envisioned designing with a very open firmware.
  • BLE-Duino – An integrated version of Dr Kroll’s BLE-Shield with an ATMEGA32u4. This is built with the typical Arduino shield format allowing interfacing to pretty much any Arduino shield. This is still in early design, but bears mentioning here.

All of these devices are capable of what I’m describing here and could very easily implement any firmware or apps written to support it. I’ll have more details soon on making these devices usable in this fashion.