Building a Private Branch Exchange (PBX) for Analog Phones Using Raspberry Pi and VoIP
Where This Started
This project didn’t begin as a technical experiment—it started as a conversation.
While talking with the director at the Stone Branch Center for the Arts, we were tossing around ideas for interactive exhibits. One of the simplest ideas she mentioned was:
“What if dialing a number just played an audio file?”
That was it. No complex system—just a phone, a number, and a sound.
But that idea stuck.
See It In Action
Before getting into the details, here’s a quick look at the system in action—from dialing a rotary phone to playing audio and handling voicemail.
The Earlier Roadblock
I had looked into this before and hit a wall pretty quickly.
Analog phones aren’t simple devices:
- They use DC voltage for signaling
- AC voltage for ringing
- Both over the same two wires
- At levels that made me hesitant to experiment directly
At the time, I wasn’t comfortable enough with electronics to safely build something from scratch. The project stalled.
A New Direction: VoIP with Analog Phones
With renewed interest—and now a real place to potentially install this as an exhibit—I approached the problem differently.
Instead of generating voltages myself, I looked for hardware that already handled it.
That led me to VoIP adapters.
The Grandstream HT802 stood out because it could:
- power analog phones safely
- translate signaling into SIP
- potentially allow phones to call each other
I couldn’t get the phones to work on their own to call each other using just the Grandstream device, but after introducing a Raspberry Pi and configuring everything, I was able to get the phones to call each other through the Raspberry Pi.
The Breakthrough

Once the Raspberry Pi was added:
- phones registered as SIP endpoints
- dialing between them worked
- routing and behavior became programmable
Instead of fighting hardware, I now had a software-controlled phone system sitting between real analog devices.
Hardware Used
- Raspberry Pi 4 (2GB RAM)
- 64GB microSD card
- Grandstream HT802 (2-port FXS ATA)
- Analog phones (rotary + touch-tone)
- Netgear GS605v5 5-port Gigabit switch (overkill—any small hub would work just as well)
The switch simply creates a private network between the Pi and the ATA.
Step 1: Install Raspberry Pi OS
Flash Raspberry Pi OS Lite using Raspberry Pi Imager:
- Set hostname (example:
ring-ring) - Enable SSH
- Create a user (example:
operator)
Boot and connect via SSH.
Step 2: Installing Asterisk (Unexpected Roadblock)
The obvious step was:
sudo apt install asterisk
That failed.
There was no installation candidate available.
I then tried installing a legacy version of Raspberry Pi OS using Raspberry Pi Imager, hoping older repositories would include Asterisk.
That also failed.
Even older versions available through the imager did not provide the package, and there was no straightforward path to install a working version through apt.
I avoided compiling from source at first because it usually leads to dependency issues and long build times—but ultimately, it had to be done.
Install dependencies:
sudo apt updatesudo apt install -y build-essential git wget curl \libxml2-dev libncurses5-dev libsqlite3-dev uuid-dev \libjansson-dev libssl-dev libedit-dev
Download and compile:
cd /usr/srcsudo wget \https://downloads.asterisk.org/pub/telephony/asterisk/asterisk-20-current.tar.gzsudo tar xvf asterisk-20-current.tar.gzcd asterisk-20*/sudo ./configuresudo make -j4sudo make installsudo make samplessudo make config
Along the way, I ran into dependency issues (notably with libssl and zlib) that required aligning versions and, in some cases, downgrading packages.
Additional Notes: Library Downgrades (libssl & zlib)
Check available versions:
apt list -a libssl-devapt list -a zlib1g-dev
Install specific versions (example versions shown — yours may differ):
sudo apt install libssl-dev=1.1.1n-0+deb11u5sudo apt install zlib1g-dev=1:1.2.11.dfsg-2+deb11u2
If needed:
sudo apt install --allow-downgrades \libssl-dev=VERSION \zlib1g-dev=VERSION
Prevent upgrades:
sudo apt-mark hold libssl-dev zlib1g-dev
This was one of the more frustrating parts of the process, but it ultimately allowed the build to complete.
Start Asterisk:
sudo systemctl start asterisksudo asterisk -rvv
Step 3: Network Setup
The Raspberry Pi connects to two networks:
- Wi-Fi (for management)
- Ethernet (private phone network)
Configure a static IP:
sudo nano /etc/network/interfaces
auto eth0iface eth0 inet static address 192.168.50.1 netmask 255.255.255.0
Reboot:
sudo reboot
Step 4: Configuring the HT802
This part depends heavily on the device version.
The instructions I initially followed were for newer models and did not work.
I had to download an older PDF manual to correctly configure the HT802 using the phone keypad.
Key differences:
- IP addresses must be entered as 12-digit numbers
- Example:
192168050100
- Example:
- Newer devices may use
*between octets - Menu navigation varies significantly between firmware versions
Step 5: Accessing the HT802 via SSH Tunnel
Because the HT802 is on a private network, my laptop could not access it directly.
I used SSH tunneling through the Raspberry Pi:
ssh -L 8080:192.168.50.100:80 operator@192.168.20.177
Then opened:
Step 6: Configure SIP
HT802 configuration:
- SIP Server:
192.168.50.1 - Port 1: extension
100 - Port 2: extension
101
Step 7: Dialplan
Edit:
sudo nano /etc/asterisk/extensions.conf
[from-phones]exten => 100,1,Dial(PJSIP/100,20) same => n,Voicemail(100@default,u) same => n,Hangup()exten => 101,1,Dial(PJSIP/101,20) same => n,Voicemail(101@default,u) same => n,Hangup()exten => 200,1,Answer() same => n,Playback(demo-congrats) same => n,Hangup()
Reload:
dialplan reload
Step 8: Audio Files
Transfer files:
scp yourfile.wav operator@192.168.20.177:~
Move:
sudo mv ~/yourfile.wav /var/lib/asterisk/sounds/custom/
Convert (requires sudo):
sudo apt install ffmpeg -ysudo ffmpeg -i old.wav -ar 8000 -ac 1 -c:a pcm_s16le new.wav
Required format:
- WAV
- 8 kHz
- mono
- signed 16-bit PCM
ffmpeg does not replace the original file—it creates a second file. You will have both the original and converted versions unless you remove one manually.
Analog phones have limited audio fidelity due to shared signaling on the same wire, so using proper telephony format is important.
Step 9: Rotary Phone Challenges
Enable pulse dialing in the HT802.
Use logging to debug:
pjsip set logger onpjsip set logger off
Watch for lines like:
INVITE sip:200@192.168.50.1
This shows what digits Asterisk actually received.
One practical discovery:
Holding the phone steady with one hand while dialing significantly improved pulse accuracy.
Step 10: Dynamic Playback
exten => _697XXXX,1,Answer() same => n,Playback(custom/${EXTEN}) same => n,Hangup()
Example:
Dial 6971038 → plays custom/6971038.wav
What It Took to Get Here
I seemed to run into problems at nearly every step.
Using AI (ChatGPT), I was able to:
- test solutions quickly
- troubleshoot in real time
- avoid hours of manual research
By pasting logs, commands, and observations, I could iterate rapidly.
Progress was slow—but it was still progress.
By the end of the day, I had a fully working, customizable PBX.
Future Ideas
- Record messages directly from phones without accessing the Pi
- Interactive directory systems (e.g., 100-word stories menu)
- Randomized playback pools
- Time-based audio behavior
- Shared voicemail systems for artists
- Recording contests and rotating exhibits
- Cellular integration via SIM for remote access
- Automatic publishing pipelines to websites
Hardware Expansion Idea
Next steps include designing a physical enclosure:
- Measure the crank phone battery compartment
- Create a laser-cut box that slides into place
- Mount the Raspberry Pi and ATA internally
- Possibly hinge the structure for easy access
- Add a rotary dial on the front panel
The rotary dial would allow:
- the crank phone to handle audio (handset and bells)
- dialing to be done externally
- easier interaction for users in an exhibit setting
The rotary dial could connect to a microcontroller or GPIO and translate pulses into digits for Asterisk.
Final Thoughts
What started as a simple idea turned into a flexible platform.
A rotary phone dialing into a programmable system creates a unique blend of physical interaction and digital experience.
And now that the foundation is in place, the real creative work begins.
