A Retro Rotary Phone Powered by AIY Projects and the Raspberry Pi
Machine Learning inside a classic 1970’s GPO telephone
If you like this build I’ve also written other posts on building a simple voice controlled Magic Mirror with the Raspberry Pi and the AIY Projects Voice Kit, and a face-tracking cyborg dinosaur called “Do-you-think-he-saurs” with the Raspberry Pi and the AIY Projects Vision Kit.
At the tail end of last month, just ahead of the announcement of the pre-order availability of the new Google AIY Project Voice Kit, I finally decided to take the kit I’d managed to pick up with issue 57 of the MagPi out of its box, and put it together.
However inspired by the 1986 Google Pi Intercom build put together Martin Mander, ever since I’ve been thinking about venturing beyond the cardboard box and building my own retro-computing enclosure around the Voice Kit. I was initially thinking about using an old radio until I came across the GPO 746 Rotary Telephone. This is a modern day replica of what must be the most iconic rotary dial phone in the United Kingdom. This is the phone that sat on everybody’s desk, and in their front halls, throughout the 1970’s. It was the standard rental phone, right up until British Telecom was privatised in the middle of the 1980's.
While the GPO 746 is available in the United States it’s half the price, and there are a lot more colours to choose from, if you’re buying the phone in the United Kingdom. A definite business opportunity for someone there because it turns out that, on the inside, it’s a rather interesting bit of hardware.
Gathering your Tools
For this project you’ll need is a small Philips “00” watch maker’s screwdriver, a craft knife, scissors, a set of small wire snips, a drill and a 2 to 4mm bit, a soldering iron, solder, some jumper wires, female header blocks, a couple of LEDs, some electrical tape, a cable tie, and possibly some Sugru and heat shrink tubing, depending how neat you want to be about things.
While I did end up soldering a few things during the build, it is was mostly restricted to joining wires together and should definitely be approachable for beginners.
Opening the Box
Ahead of the new Voice Kit hitting the shelves next month I managed to get my hands on a few pre-production kits, which fortunately meant that I didn’t have to take my cardboard box apart to put together a new build.
The new AIY Voice Kit comes comes in a box very similar to the original kit distributed with the Mag Pi magazine. The box might be a bit thinner, but otherwise things look much the same.
Missing from my pre-production kits the two little plastic spacers that keep the Voice HAT from bending down and hitting the top of the Raspberry Pi. I’m presuming they’ll include them in the production kits, without them the underside of the HAT tends to push downwards and the solder tails of the speaker screw terminal shorts out against the Raspberry Pi’s HDMI connector. I fixed this by adding some electrical tape to separate the two boards, but the spacers would have worked a lot better and added more stability.
The only component swap was the arcade button, gone was the separate lamp, holder, microswitch and button—all four components have been replaced by a single button with everything integrated. Since it was somewhat fiddly to get that assembled last time, this is a definite improvement.
While my pre-production kits didn’t include it, I’m told the retail version will have a copy of the MagPi Essentials AIY Projects book written by Lucy Hattersley on how to “Create a Voice Kit with your Raspberry Pi.”
Other than that, things went together much as before. At which point I quickly put together the Voice Kit, this time however, I didn’t bother with the cardboard box.
Opening the Phone
Pulling the replica GPO 746 out of its box you’ll find it comes in two parts, the main phone with the dial, and a separate handset which plugs in underneath the base.
The first thing I needed to do was take the base unit of the phone apart and figure out how it worked. Until I knew what I had to work with, it was going to be impossible to figure out a sensible plan to integrate the Voice Kit.
The main PCB is mounted on the base along with a steel weight to give the impression of “heft” to the replica phone. There’s also a large bell, which makes that distinctive ringing noise familiar to anyone that owned or used a GPO 746 back in the 1970's.
To the left of the PCB is the jack socket where the telephone line is connected (two wires, red and green). To the top, two switches. One is for handset, and the other for ringer, volume. At the bottom another jack switch (four wires, red, black, yellow, and green) where the handset is attached.
The only thing of real interest on the PCB is the Hualon Microelectronics HM9102D which is a switchable tone/pulse dialer chip, which we’re actually not going to use.
In fact, since the line voltage in the UK is +50V, pretty much none of it was going to be any use to me. So after measuring the voltage on the cable connecting the dialer to the PCB, I snipped the wires to the switches and the jacks—leaving them in place with as much trailing wire as possible in case they were going to come in useful,—and then removed both the PCB and the bell. After that, I filed down the plastic moulding that held everything in place leaving me with a large flat area which was perfectly sized for the Raspberry Pi and the Voice HAT.
The moulded top of the phone has two assemblies, a simple microswitch toggled using a hinged and sprung plastic plate when the phone handset is taken on and off the hook, and the dialer assembly which is connected to the base and the PCB using a ribbon cable.
How the Dialer Works
It was time to break out the logic analyser. While I’ve got a Saleae Logic Pro 16 on my desk, if you’re thinking about picking one up for the first time I’d really recommend the much cheaper Logic 8, or even the lower specification Logic 4, rather than splashing out on the higher end model. Either will take you a long way before you get the itch that you have to upgrade.
Stripping the connector from the cable that connected the dialer to the PCB and powering it up with a bench power supply to +5V—which is more-or-less what I’d measured on the cable and was something I could reasonably expect to get from the Raspberry Pi—I connected the rest of the cables to my logic analyser and started turning the dial confidently expecting to see something interesting going on. I found nothing, I had flat lines, there was no signal going down the wires at all.
After playing around with the voltage for a few minutes, with no results, I stripped the dialer assembly out of the case for a closer look.
The back of the dialer assembly has two LEDs, which I thought was rather odd since there dial isn’t illuminated in any way, at least not from the outside. Interestingly these two LEDs flash briefly when the dial is turned all the way around to hit the stop.
Cracking the case brings us to something else interesting, it’s a light box. Designed to keep the light from the LEDs inside, it has a hole which rotates around as you dial a number.
The hole exposes one of twelve photoresistors to the light from the LEDs and the number (or symbol) you’re dialing determines which of the resistors will be under the hole when the dial stop is reached.
It was all passive circuitry. No wonder I hadn’t seen anything on the logic analyser, there wasn’t any logic to analyse. It was all analogue.
Unfortunately for me, the Raspberry Pi has no built in analogue inputs. That means I’d have to pull a Microchip MCP3008, or something similar, from the shelf and build some circuitry. I’d also have to figure out how the resistance for twelve photoresistors ended up travelling down just eight wires, which sort of had me puzzled at this point.
That all sounded like a lot of effort. Since I really only wanted to dial a single digit to activate the Voice Kit, and I didn’t care what that was, I decided to ignore the photoresistors and concentrate on the dial stop.
Unlike the original GPO 746, the dial stop on this replica moves. It drops when you hit it with the side of your finger when dialling a number. It turned out that it was connected to a microswitch, and when the microswitch was activated, this was the thing that briefly flashed the LEDs and exposed the appropriate photoresistor. It was actually all rather clever. A really neat way to minimise the build of materials costs for the phone. Startups thinking about building hardware could learn a lesson or two in economy from this phone.
Just to be sure I had this right, I dialled down the bench power supply to a Raspberry Pi friendly +3.3V and wired up the microswitch to the logic analyser.
Dialling a number on the dialer assembly worked as expected. We could ignore the dial itself, and those photoresistors that would be a pain to use with the Raspberry Pi and just make use of the microswitch. In fact we could more-or-less just replace the arcade button with this switch.
Integrating the AIY Project Kit
Moving on, I really wanted to reuse both the speaker and the microphone already in the handset instead of the ones the came with the Voice Kit.
Taking apart the handset—the end caps holding the speaker and microphone just screw off—showed that there were four wires inside the curled cable. Two for the speaker, and two for the electret condenser microphone.
The Voice Kit makes use of two InvenSense ICS-43434 MEMS microphones which use I2S to communicate. They’re a solid replacement for traditional 2-wire analog microphones like the one we in the handset of the GPO 746.
Looking at the Voice HAT microphone daughter board, it has been designed so that you can break the two microphones away from the board at the perforations and then you can solder the wiring harness directly to the pads. So long as you keep the signals consistent you should be able to place the mics pretty much anywhere, and with a clock rate of ~3MHz, a longer cable should be fine.
Unfortunately I2S uses more wires than I had available. Unless I wanted to replace the curled cable, and I didn’t really want to have to do that, I was in trouble.
Putting that aside for a moment I decided to start with the dialer assembly. Refitting it to the case, I snipped the wires leading to the microswitch and, grabbing the wiring harness for the arcade button, I soldered the microswitch to the relevant wires in the harness.
I then grabbed a ultra-bright LED and a 220Ω resistor from the shelves and soldered the resistor in-line with the LED. I then attached my new LED assembly to the other two wires in the arcade button wiring harness. At this point I had a replacement for the arcade button that came with the Voice Kit.
Giving up on putting microphones into the handset I pulled out a drill and measuring the spacing between the two microphones I drilled a couple of holes in the external shell of the phone.
These weren’t going to be visible from the outside as there is a void between the top of the phone, where the handset rests. This is a carrying handle where you can tuck your hand in, and pick up the phone. In the old days this let you pick up the phone and wander around the room—well, so long as the cable tying you to the wall was long enough.
I then went ahead and tucked the microphone board behind the spring which operated the hook mechanism. There was just enough room to secure it there with a cable tie, and some Sugru.
After that I plugged the handset into the jack on the base and connected the two wires from the handset jack that were attached to the speaker to the screw terminals on the Voice HAT.
Stripping the jack out where the phone line originally ran left two upright pillars that used to go on either side of the jack. I threaded the end of a 2.5A micro-USB charger through the hole and tied it around the pillars for strain relief.
Which completed the re-wiring. The arcade button had been replaced with the dial stop microswitch and an LED which I was going to tuck just ahead of the microphone board in a convenient clip-like part of the body moulding. The speaker had been swapped out directly with the one in the handset—fortunately the impedance match wasn’t too far off—and the microphone had been mounted somewhere convenient inside the main body of the phone.
A Working Phone
Screwing everything back together we have once again something that looks like a phone.
I booted the Raspberry Pi, logged in via SSH and went ahead and ran the src/assistant_library_with_button_demo.py
script from the dev console.
Success. Picking up the handset and dialling a number, any number, let you talk to the Voice Assistant. But it wasn’t quite there yet. While it worked, it didn’t feel like a phone.
Adding a Dial Tone
What the phone needed was a dial tone. It needed to play when the handset was lifted and shut off when the phone was dialled, or the handset replaced.
The phone hook works the opposite way that you might expect, when the handset is in the cradle the microswitch that simulates the hook is open as the bar below it is pushed down by the hook. When the handset is off the hook, then the microswitch is closed as the bar moves upwards.
Conveniently the Voice HAT breaks out most of the unused GPIO pins from the Raspberry Pi, so at least in theory wiring the the microswitch attached to the the hook mechanism to one to the Voice HAT should be fairly simple.
Thinking about how to approach this in software however left us with a bit of a quandary. While the underlying Python GPIO library allows us to detect both the rising and falling edge events when a switch is toggled, the AIY wrapper code doesn’t in the Voice Kit doesn’t. While I could have gone in and modified the wrapper code to add that functionality, I decided I didn’t want to mess around with that—perhaps I’ll get around to it later and send them a pull request—instead I decided to fix it in hardware and wire the hook switch into both GPIO4
and GPIO17
. That way I could use one pin to monitor for GPIO.RISING
, and the other for GPIO.FALLING
.
It’s easy enough to do that using the aiy._drivers._button.Button
class, and two callback methods. One called with the handset is taken off the hook, and the other called with it is replaced.
We can then use the pygame
library to play a WAV file in the background when the handset is lifted, and stop when it is replaced. We also have to add a stop command inside the _on_button_pressed()
method so that the dial tone stops when the phone is dialled, and a call to stop_conversation()
to stop the Voice Assistant talking if the handset is returned on hook while Google is answering our question.
Adding a Greeting and a Hang Up Noise
We’re not quite there yet, we can also use aiy.audio.play_wave()
to add that distinctive disconnect noise when Google finishes talking and “hangs up” before returning to our dial tone. We can also use aiy.audio.say(‘…’)
call to add a greeting when Google “picks up” the phone to talk to us.
It’s surprising how much atmosphere just adding these simple sounds ended up making to the build, and how much the user experience was improved. It now doesn’t just look like a rotary phone, it sort of feels, and perhaps more importantly, sounds like one too.
The Script
The final version of the script has amazingly small number of modifications away from the original version distributed byGoogle. Which sort of shows how simple it is to build something that looks and feels very different from the original cardboard box with not a lot of effort, at least on the software
If you want to replicate the build you can grab the two mono WAV files I used for the build from Dropbox. Although, if you’re outside the the United Kingdom, you might want to replace the standard British dial tone of 350Hz and 450Hz—which you hear any time you lift a phone off the hook—with something more appropriate.
Available to Preorder
The new kits are being produced by Google, and are available to pre-order at Micro Center and through their resellers like Adafruit, and SeeedStudio. The AIY Voice Kit is priced at $25 on its own, but you can pick one up for free if you order a Raspberry Pi 3 at $35 for in-store pickup from Micro Center.
The kit will be available in the United Kingdom through Pimoroni, and cost £25, and you can expect shipping dates for kits ordered in through them to be similar to those ordered from Micro Center.
The new kits should hit shelves in October.
This post was sponsored by Google.