PiTelephone - Raspberry Pi retro dial phone
Posted by praveen kumar at 11:02
We use VOIP a lot (internet telephony). All our outgoing calls use VOIP, and most of the incoming ones too. Mostly SIP phones, or Skype.
The old rotary dial telephones make a great show-piece dont they? Not something I want to use everyday (they still make me jump out of my skin when they ring!). I have seen a few retro VOIP conversions on the net, and thought one day I would like to have a stab at converting one, for fixed or even wireless internet use. Well, here is the start of my little Raspberry Pi Christmas project. The hardware is complete, software needs more work.
The classic GPO 746 was my phone of choice. Just about everybody in the UK during the 1970's had this phone or the swish Trim Phone for the trendy folk, so plenty on ebay. The two main problems to solve, is counting the dial pulses, and oscillating the bell.
The bell runs at around 50v AC. Not very convenient with today’s microelectronics. The Raspberry Pi requires 5v. Thankfully the two coils that operate the bell in the 746 can be centre tapped, and with a quick test I found that 16v DC on either side of the coil was sufficient to get each bell make a 'tingggg' sound. I had an old laptop PSU which was 19v, so just needed a DC-DC converter to get the 5v required for the Raspberry Pi. For this I used a OKI-78SR that I have used on other Raspberry Pi projects. You can drive the Raspberry Pi directly via the 5V GPIO pin using this device, up to over 30v. Nifty.
The ring frequency from the telephone exchange is typically 25hz. So we need to synthesise that by alternating the DC power between the two bell coils. I looked at some circuits to do this, but since I am not in the business of mass producing this project, toggling a relay in software might just do the trick. And it does. Two SPDT relays. One for power, and the second to oscillate between the two coils. I was worried you might be able to hear the relay chatter spoiling the effect, but I forgot how loud these bells are.
Counting the pulses
This turned out to be easier that I had anticipated. Again, using a dedicated counting circuit to do this, is perhaps the 'right thing' to do, but the Raspberry Pi has a fast CPU, and doing this in software was no issue. Switch bounce could have been the enemy here, but it wasn't.
An old USB Headset was used here. Took it apart and used all the components. Replaced the microphone & earpiece in the receiver.
Raspberry Pi GPIO & fitting
I used the original microswitch cut off the original circuit board from inside the phone, and discarded what was left. I stuck it in with Power Putty. This left room for the Raspberry Pi to sit in it's place. I had to use a MicroSD card adaptor, as the case will not go on with a standard SD card installed.
I used a Raspberry Pi GPIO breakout board, and added two ground-triggering inputs (for hook switch & dial), and two SPDT relays on-board (plenty of example circuits online). Voltage regulation as previously mentioned, and some screw connectors. I had to do a bit of chopping of the metal inside the phone with a Dremel cutting wheel, to get a little extra hight clearance.
C# on the Raspberry Pi is well supported with Mono. The raspberry-sharp-io dll works great. It has event driven inputs, so no need to tie up the processor watching the hook switch or dial pulses. It even works down to a resolution of 1hz. I timed each pulse, and outputted it to the console. Here is the output when you dial 9, showing the time in milliseconds between each pulse. After 400ms (configurable), it is assumed a number has been dialled, and a C# event is raised.
++ 92.076 ++ 91.443 ++ 91.647 ++ 91.639 ++ 91.816 ++ 91.603 ++ 91.601 ++ 91.617 ++ 399.484 Number Dialed:9
The Hook switch is also being timed, so that it could be programmed to say put a call on hold when the user gives it a quick press, or for a longer period (i.e the receiver is now on the hook) drop the call.
Skype: I applied for the Skype SDK for this project 5 weeks ago. Still waiting. It's supposed to work on the Raspberry Pi, and has a new .NET interface.
PJSIP: This was my first choice for SIP support. However I ran into compilation problems, particularly with the C# wrapper. If anyone wants to have a go at this, then please do.
FreeSwitch: FreeSwitch is usually used on a server, but while I was researching, I read about how it can be embedded into your apps, and there is a C# module, and a sound interface module. I would like to explore this, when time permits.