Category Archives: Hacks

A USB adapter for the Apple Newton keyboard

Back in the pre-smartphone days, the Apple Newton was the first device in the PDA category.  Newtons were only sold for five years between 1993 and 1998, when Steve Jobs pulled the plug on the program.  Although Apple frequently took a ribbing for problems with the Newton’s handwriting recognition feature, its main problem with achieving market dominance was Newton’s high cost.  Although it beat the wildly successful Palm Pilot to market, Newton could not compete on price.

One of Newton’s accessories was a very compact keyboard (just a hair over 10 inches wide).  I had one rattling around in my spare parts bin and it was the perfect size to use with the SunFounder Display and Raspberry Pi one-piece computer that I recently assembled.

Only one problem, no way to plug it in.  The Newton keyboard outputs a serial data stream and the RasPi (like most other modern computers) requires a USB keyboard.  Further complicating matters, the Newton keyboard does not produce ASCII characters.  Like the legacy IBM XT and AT keyboards, the Newt keyboard outputs a unique scan code for each key.  One code is sent when the key is pressed and another gets sent when the key is released.

I was surprised to find that nobody currently sells a pre-built adapter to do the serial to USB conversion.  (Such adapters exist for IBM keyboards, but are not pin or code compatible with the Newt keyboard).  The only homebrew solution I could locate was from a guy in Japan who posted this video but little else in the way of details.

I was able to piece together the following information from various sources:

  • The Newton keyboard runs at 5V (technically 4.5 volts) and produces a 5V TTL compatible signal
  • Baud rate is 9600-N-8-1
  • We can connect it to a microcontroller using three pins:  pin 2 – +5V, pin 8 – signal, shield – ground
  • The key scan codes are similar but not identical to those use by IBM AT keyboards

To make the Newt keyboard impersonate a USB keyboard, I would need to remap the serial data to USB.  This job calls for a small, cheap, 5V tolerant microcontroller having both serial and USB interfaces.

The Teensy 2.0 board is perfect for this purpose.  It can impersonate all kinds of HID devices like mice, keyboards, joysticks, etc. and it is compatible with the Arduino IDE, which comes with a great keyboard library that can do all the heavy lifting.

If you want to build your own adapter and are familiar with building Arduino projects, feel free to grab the sketch here.  Pinouts are in the readme file and you can install the Teensy (or MC board of your choice) within the Newton keyboard or in an external enclosure.

If you’d like step-by-step directions for my build, please continue reading.

Bill of Materials

  • Teensy 2.0 microcontroller development board (there are several Teensy versions;  make sure you use one that operates at 5 volts).
  • An 8-pin mini-DIN M/F or F/F cable like this one from Cables to Go.  We will be cutting off the female end to connect to the Newton keyboard.  Any similar legacy Apple serial cable would work
  • A suitable enclosure for the Teensy.  Note that there is plenty of room inside the Newton keyboard case.  If you don’t mind opening it up, you can mount the Teensy board inside.
  • A short USB A to mini B cable to connect your computer to the Teensy board

Hardware Assembly

  1. Cut off the female end of your serial cable leaving at least a couple inches of wire.
  2. If you are using the Cables to Go cable, solder the brown  wire to VCC (+5 Volts), the purple wire to D2, and the uninsulated shield to GND (ground) as shown above.  Use a piece of shrink wrap tube or tape to cover the shield wire so it doesn’t short anything on the Teensy.

    If you are using a different mini-DIN connector, use a multimeter to find the wires attached to pins 2, 8 and the connector outer case.  Pin 2 gets soldered to VCC and pin 8 gets soldered to D2.  Looking at the female connector that you will plug the keyboard into, pin 8 is on the upper left.  Here is my sketch of the connector that will surely end up hanging in the Louvre:

  3. Connect the keyboard to the connector you just soldered on and connect a USB cable to the Teensy.  Mount it either inside the keyboard case or in a suitable enclosure.

Programming the Teensy

  1. Install the latest Arduino IDE, if necessary.  It can be downloaded here.
  2. Download and install Teensyduino, which is an add-on for the Arduino software that adds Teensy support to it.
  3. Download the Apple Newton Keyboard to USB Converter library  (Mac users:  please Ctrl-click and choose Save As to prevent the ZIP file from automatically unpacking)
  4. Launch Arduino and install from the ZIP file by selecting
    Sketch–>Include Library–>Add .ZIP Library
  5. Open the Sketch named NewtonKeyboardToUSB, which is located in the folder Arduino/libraries/newtonKeyboard/examples
  6. Upload the sketch to the Teensy.  If this is the first time you are uploading a sketch from the Arduino IDE, you will need to
  7. Your computer should immediately recognize that a new keyboard has been plugged in

Further improvements

There are lots of digital inputs and outputs available on the Teensy.  It might be nice to use one of the outputs to drive an LED that indicates Caps Lock state.  Or perhaps it would be useful to assign some inputs to keyboard macros.


Importing RadioRA 2 devices into Indigo

In a recent post, I wrote about a plugin I made for Indigo to add support for Lutron RadioRA 2 devices.  I can’t say enough good things about this software.  It’s rock solid reliable and extremely flexible.  Among other things, I have Indigo set up to email a picture to me when somebody comes up the driveway (but only when nobody is home; how cool is that!) and detect house occupants’ presence by looking for their cellphones on the wifi network.

So it got to be time to add the 80+ RadioRA 2 devices in the house to Indigo’s database.  Although this would be a one-time task, I really dreaded the drudgery of typing in all those device names and properties.  So I fetched the device database from the RadioRA 2 main repeater (at http://[Repeater IP Address]/DbXmlInfo.xml).  This produces an XML file with complete information about the RadioRA 2 installation.

Indigo allows devices to be added to its database programatically.  The Python syntax looks like this:

    name="Device Name Here", 
    description="Description Here", 

So far so good.  My original plan was to use Python to parse the XML file and create the devices.  So I cracked open Mark Lutz’s excellent reference book Learning Python.  Despite Lutz’s clear examples, I just couldn’t get the XML file to parse.  (It turned out to be an issue with the XML file itself).

Not wanting to invest too much time writing a program I’d only use once, I came up with a different approach.  If I could extract the XML data into an Excel friendly format, I knew I’d be able to cobble together the Python code I needed for Indigo.  I found this awesome online XML to Excel conversion tool but it threw an error when I tried to upload the XML file.

I opened the file with BBEdit and used the Tidy, Reflow Document from the Markup menu to make the unformatted XML more readable (you just gotta love BBEdit).  Something didn’t look right.  The node “Areas” was defined twice.  WTF?  So I trimmed everything from the top of the file to just before the second “<Areas>” tag.  Then I jumped to the bottom of the file and trimmed everything after the first “</Areas>” tag.  Voila!  The file was processed by the online conversion tool and it returned a nicely formatted Excel workbook.

After a bit of further manipulation in Excel (and one string concatenation function that will make your head swim), I had all the Python code generated.

If you’d like to use this technique, take a look at the Excel Spreadsheet that I posted here.  It should be self-explanatory but give me a shout if you get stuck.  Copy the results from column H of the first tab and paste into Indigo’s scripting shell.  You should name all of your areas/rooms in Indigo’s devices tab prior to importing your devices.

Six hacks from 5 grams of Sugru

If you’re not familiar with Sugru, you should be.  It’s a moldable rubber compound that can be formed into any shape and cures at room temperature.  Sugru is amazing stuff.

Sugru comes in little 5 gram pouches in various colors (which can be blended together to create new colors).  The contents of each pouch needs to be used pretty much immediately after opening so I always try to batch my hacks/repairs to utilize a full pouch.  This might be my personal best–six objects improved with one pouch of Sugru!


This otherwise lovely set of fish plates had rough, scratchy bottoms.



A few rubber feet later, problem solved!  Tip:  after forming each rubber foot, place the object right side up on a piece of waxed paper and press lightly to flatten and level the feet.  The waxed paper will peel off easily after the Sugru cures (around 24 hours).


Same problem and same solution for this nice Spanish platter.


Now what to do about about an otherwise perfect place to keep a bedroom clock radio?  (The problem is that it isn’t possible to see the “alarm off” button without getting out of bed and kneeling down.)


Well, let’s just add a nub of Sugru to the Off button and feel it instead!!

There you go.  Six objects improved for an investment of a few minutes time and under a gram of Sugru each.