This is one of the most satisfying projects I have done I think. Mainly because this is a real device and something so historically important. It is a fully functioning Enigma machine you can wear on your wrist. This is a three rotor Enigma machine as used by German Wermacht in WW2 for encoding messages. If you don’t know what an Enigma machine is you can read all about it here. Or watch this great YouTube film that explains it (all the Numberphile films are great). Since most people don’t read the details here are some pictures. The technical details are below!
A film of the watch in action is here on YouTube.
I’ve always been interested in the Enigma machine. For years I had it in the back of my mind to make one using Meccano or LEGO Technic. I never did that though.
Last Christmas I was visiting the UK and one of my trips was to Bletchley Park, home of the WW2 code breakers. For a geek like me this place is heaven. It was absolutely amazing being there. Definitely worth a visit. I only had a day and it wasn’t enough time (especially if you want to visit the National Museum of Computing next door). One of the most impressive things at Bletchley is the Bombe machine. I vaguely knew about it but sadly didn’t spend enough time studying it while I was there.
Back in London after visiting Bletchley I decided to go see the film The Imitation Game film. At Bletchley Park they had an exhibition about it and the actual bar set used in the film is in the mansion house. Unfortunately I had missed it by a day and it wasn’t showing anymore so I had to wait till I was back in NZ to go see it with some friends.
The first viewing of that film was really annoying. To me it seemed like it was Benedict Cumberbatch playing Sherlock Holmes playing Alan Turing. The character didn’t seem right. And the film was full of Hollywoodisms and the technical details were all very obvious wrong. Or rather very, VERY over simplified (the Bombe doesn’t crack Enigma, it just reduces the possibilities). I decided to find out the real story and figure out exactly how the Bombe actually works (nothing like in the film).
To cut a long story short my aim is to recreate a Bombe using Orwell, the little 8 bit computer I have built. In order to know how a Bombe works you need to know how an Enigma machine works (and is used). And the best way to know how something works is to build it yourself.
So I did.
To convince myself I knew how it works I coded up my own version using an Arduino. It’s been done before of course but the whole point was to ensure I understood how it works. I had to redo it all myself.
To start with I just used the serial port to input and input characters. It occurred to me though that if I could get that working I could probably make a real working Enigma machine. With a tiny Arduino and a equally tiny OLED screen and a LiPo battery I could make a very small Enigma machine. I decided to make one that was possible to wear on your wrist.
The idea here wasn’t to make the smallest one possible. I decided to make a device that was practical and useable. And something that looks like it was from WW2. Something that could actually be used in the field in place of a real Enigma machine. Obviously there were some limitations. I could have a 26 key keyboard for a start so I had to come up with a UI that would work with a minimal number of keys. I bought a small 128×64 OLED, a suitable battery and started breadboarding it all up. With it working on a normal Arduino I bought an Arduino Pro Mini (or a good replica!) and started looking at getting it running on that. That was pretty easy to get working. The only tricky thing being having to use a USB to TTL programmer to download to it and those can be fiddly.
The code for the actual Enigma is all my own. I used the brilliant UG8Lib graphic library to drive the screen. This allows you to create your own fonts. The font I am using is a free gothic one called Fraktur which I got from here. I had to convert that into .bdf format using FontForge then I could use the UG8lib tool to convert that to suitable code format.
Fraktur is an interesting font. It’s one that most people would associate with being ‘that Nazi lettering’. It actually is much earlier than the Nazis and they, Hitler himself even, were trying to get people NOT to use it because it was un-German! It’s a funny one that seems to appear in odd places. I used it since it looks right and it was used on WW2 documents such as the covers of the code books. This enthusiastic guy explains it pretty well. Of course the whole UI is in German because it is meant to be a German WW2 device. Trying to find short German words that would fit on such a tiny screen was tricky! Thanks to my German friend Bernd who helped me a bit here.
With the tiny processor, tiny screen, tiny German words, and tiny 150mAh battery I could start designing a suitable housing. Remember the idea wasn’t to make the smallest working Enigma possible, I am sure you could make it smaller, the idea was to make a functioning, practical device. I decided something about the size of a matchbox would be about right. That seems about right for a WW2 era device and it wouldn’t be so tiny to be impossible to build.
My wrists aren’t huge and my normal watch isn’t massive. I started making a casing from steel approximately matchbox sized after laying out the main components on some 1mm graph paper to get an idea of sizes.
The case is made from 0.8mm panel steel. When you’re into making cars it’s the sort of stuff you have lot of lying about. It was some simple metalworking to make a suitable base. I got to use my new Dremel to cut the slots and used some scrap oak wood to make a former to make the rest of the base.
The holes either end are for the on/off switch and a recharging socket. The rectangular slots are for the strap. Recharging is via a little USB single cell LiPo charging board from Sparkfun similar to this one.
With the base done I made a simple top. To make this I used a tool called a joggler which bends a step into the metal (used for doing flush lap joints in car repair). This made a lid that would slot nicely into the base without leaving any open gaps along the sides.
To attach the lid I used counter sunk, domed head screws, similar to those used on a real Enigma machine. They are quite hard to find these days but I got some from the local RS supplier. I had to get 100 but I can use them on Orwell too. To give the screws something to attach to I machined up some brass standoffs. These have a small nipple on the base that fitted into a hole in the bottom casing. They were then soldered in place. To get the position accurate I first made the holes in the top panel, countersunk them then ran a drill through the hole to make a centering dimple in the base. I could then drill the mounting holes in exactly the right place.
The stand offs were soldered in place and the bottom sanded smooth.
I then thought about how to actually mount everything inside the casing. I decided to use a small circuit board to which I could mount the screen and buttons. The Arduino Pro Mini would fit into a cut out in the middle of the board. I cut a suitable shape from some PCB board blank. Here you can also see the 2.5mm recharge socket and the main power switch. That was a toggle switch with the toggle cut down to more reasonable proportions.
The screws I had for the lid were too long so needed cutting down. The trick to getting these all the same length it so cut them roughly then insert them into a steel plate you have drilled and tapped previously. The screw protrudes though the plate then you can simply grind the exposed thread until it is flush with the plate. This makes all the screws the same length and makes the ends of them square. If I need to buy a lot of screws or bolts I tend to go for longer than I need since you can always cut them down but it’s much harder to make a short screw longer!
The next step was etching the board. I use the laser printer toner transfer method to do this (plenty of info of that online). I used the same technique to etch a tiny brass nameplate.
There is actually a mistake on this board I didn’t notice until it was fully assembled but it was easy to fix (see if you can spot what it is).
Around this time I also started making the strap. I recently decided to learn how to sew so now I have a sewing machine of my own. I used that and some scraps of leather to make the straps. I actually hand wound the machine instead of using the motor so I could accurately position the stitches. I sewed first then cut out the straps to ensure the leather would feed evenly though the dogs. The straps are two layers of leather glued back to back. Masking tape gave me the lines to follow when sewing. The masking tape also allowed me to mark the centre line so I could punch holes and fit the eyelets. After sewing the tape is removed.
The final part of making the straps was to insert short lengths of piano wire between the two layers to form pins that stop the straps pulling out of the watch. This makes inserting the straps easy. You remove the pin, insert the end through the slot in the case, reinsert the pin then pull the strap home.
The straps and pins also hold the PCB board down in place. Next I made little brass stand offs to mount the screen. This is held down with some 2mm brass screws. I also fitted the tactile switched and machined up some little brass buttons (which are a top hat shape) that poke through the top panel and rest on the tactile switches. I had another OLED screen that I accidentally burnt out I used for mocking up. The one I used in the watch has tape over the rear to prevent short circuits from happening.
I was then able to test fire everything up, first with the board outside the casing. Unfortunately it didn’t work! I’d forgotten I had changed the pin ordering to the OLED to make the wiring simpler. A quick re-download to the Arduino fixed that. I was able to measure the current consumption at this point. When displaying the splash screen about 40mA is drawn. On all the other screens the current draw is about 25mA.
The piece of black felt is there to fill the gap between the screen and the top cover. It also stops the brass buttons from rattling about in the casing.
After that all that remained was to take everything apart and paint the case. The inside is painted with zinc primer just to stop the bare steel rusting. The outside was painted crackle black. I baked the finish in my oven to give a nice hard coating.
The finishing touch was the tiny Enigma badge I had etched. This was infilled in black then glued to the housing.
The actual UI is described below. The device is designed to be used in the field as a real Enigma machine was. The flow is based on the key sheets the Enigma operators used to set up their machines as described here. The UI is simple. The left two buttons work as left and right selectors. The right most button is the select button. Left and right selection are indicated on screen by left and right arrows.
First you turn the machine on.
A key press on any key takes you to the Walzenlage, or rotor setting, screen. Here you can view the current setting or change the settings. It was hard to find suitable German words for the menus. I used Beibehalten, meaning ‘Maintain’ and Ändern meaning ‘Change’. I had to think of words that would have made sense in WW2 so things like ‘Save’ and ‘Edit’ might not have made sense as these seem more modern UI terms.
The first screen you see is the rotor selection screen. You can edit the selection and choose each wheel from left to right. The selection list gets smaller as each wheel is selected of course.
Next is the Ringstellung, or ring settings screen. Again we can edit and choose each wheels ring setting.
Next we go onto the Steckerverbindungen, or plug board settings, screen. This was the trickiest part of the UI to get working with only three keys. The way it works is this. The left and right buttons increment the left and right columns. You select the pairs of letters you with to plug together (called steckering). The UI will tell you how many current pairs you have. If you reconnect a letter that is already in a pair it will break the previous connections and make a new one so the total number of pairings won’t increase. If you stecker a letter to itself it will break any previous connections to either of those letters. If you are reading from the daily key sheets you simply enter the ten pairings indicated. If you want to enter less there is is blank letter setting. If you select this the plugboard editing will end and show you the list of current connections. Clearing connections is as simple as connecting a letter to itself (called self-steckered in Enigma talk).
Next we get to the Grundstellung, or initial indicator setting, screen.
Next we go to the Umkehrwalze, or reflector screen. Since this is a three rotor Enigma we have the choice of the ‘B’ or the ‘C’ reflectors only.
Then we finally get to the encoding screen. The left and right buttons let you select the letter to encode. As you encode each letter the display shows the current rotor positions and the encoded letter in a ticker. The ticker displays 5 letter groups as this is how Enigma messages were transmitted by radio.
This is where I deviate a bit from a real Enigma. I believe that only the Naval Enigmas used rotor wheels with letters on them (I think I remember that from Bletchley Park?). The Army and Airforce machines used rotors with numbers instead. That doesn’t work so well on a UI so I went with letters instead. Funnily enough it seems most online simulations do the same as does this brilliant kitset you can get from the Bletchley Park shop.
As well as the letter we have two additional settings. Klar, to clear to reset the ticker, and Ausgang to exit from encoding.
That takes you back into the settings pages. The grundstellung will now be set to whatever the rotors were at after encoding and they can be reset back to the initial settings as per normal Enigma operating procedure.
That’s basically it! It is a one off and it isn’t for sale. Although if anyone really wants to buy it I’ll sell it for US$10000. $5000 so I can go back to visit Bletchley Park and $5000 I’d donate to them 🙂