Rotary Phone & Pi

I wanted Max to use our old rotary phone, and with a little downtime during COVID and wanting to learn Python anyway, it was a great project to make the phone work on it’s own and to call another phone. Basically, I’m making my own little phone interchange, with the raspberry pi being the brains behind it all.

Challenges:

  1. Analog/rotary phones work on a 80V signal that is hard to make with 3V electronics on the Rasperry Pi board.
  2. Streaming audio from one phone to another without lags

Goals:

  1. Detect dialed numbers and do something depending on what number was dialed
  2. Play a dialtone when the phone is offhook
  3. Ring the phone, of course!
  4. Play audio, songs, etc. from memory card.
  5. Record audio and then have the pi call the phone back after a delay to play the audio back, potentially with modified higher or lower pitch
  6. Call another phone, making typical phone interchange sounds like dial tone, busy tone, ring tone, etc.

I started this project trying to use an Arduino with a Wave Shield, but after some work and sample code, it was nearly impossible to record audio with this setup. Since I also wanted to stream audio to another phone, I opted to explore the Raspberry Pi. Overall, I don’t think I’d go back to Arduino after playing around with the Pi boards. Why? because for the same price as an Arduino, you can get them with built-in wifi and connect through SSH to do bug fixes, backups, and log checks without having to unplug the system. Then there’s also the builtin USB, ETH, and HDMI ports which make setup and connecting peripherals really easy.

Code: Python Code is available on GitHub.

Resources:

  1. Rotary phone(s) with a working ringer.
  2. Raspberry pi 4 (Pi zero won’t work for streaming audio in both directions since it only has one processor)
  3. AG1170-S3 Subscriber Line Interface Circuit + supporting circuitry from Digikey. (I bought the -S5 version, which works with 5V logic instead of the 3V required by raspberry pi, so I needed to use a Sparkfun level shifter to interface the two)
  4. 2 USB-audio adapters
  5. Box (all this just barely fits in the box I selected). I epoxied the phone jacks and such into the box after cutting the holes and filing them to the correct size.
  6. Power wiring
  7. Phone jacks & adapters (optional, but helpful)
The final box, with 2 phone jacks, USB-c power, dual Ag1170 boards, and raspberry pi 4 on the bottom.
This shows the dual ag1170 boards and supporting circuits. The 4 coaxial wires are for the microphones and speakers. I used an Arduino shield board. The pi board is underneath.
The schematic is directly from the Ag1170 data sheet. I bought the parts on Digikey, and just ignored the T1 & R1 since I left it on all the time. In hindsight, it would probably be good to add that transistor and some code to shut down the Ag1170 when not in use because it does get hot after being on for a while!
The USB-audio adapters had audio jacks that I de-soldered to make it a little more compact, and then soldered wires to the Ag1170-S3 connections. I also cut the USB wires and soldered them to the bottom of the pi board where the usb pins are, just to save space.