Homemade Intercom (PBX) With GPIO

Introduction: Homemade Intercom (PBX) With GPIO

I was always interested in electronics/electricals, and when I was quite young I once came across an article in an electronics magazine about building an intercom out of two telephone instruments. I had been very interested in the project and had tried to build it, however, at the time I had not been very successful.

Recently as I had some old telephone instruments lying around, the idea came back to me. I have since gained more knowledge in electronics and came to know microcontrollers, which made the whole project seem more realistic. I started experimenting and finally came up with something functional. Please note that the device presented in this instructable is not perfect, it does not support newer features such as tone dialing, does not implement any dial tones, does not follow the telephone line standard to the letter (I cannot guarantee that all phone instruments will work well), and was designed in a perhaps not most efficient manner (as the design was adapted to many components I already had). Nevertheless, up to 4 telephones can be connected and used for internal communication (no connection to a public phone line for external calls is possible), 1 simultaneous call can take place, pulse dialing is supported, and has 5-6 unused pins on the microcontroller which could potentially integrate with other home automation devices. I have for the time being connected a couple of relays controlling garden lights, so that I can switch them on and off from any location where there is a phone (by dialing a number associated with that relay). I plan to, in the long run, implement I2C or a similar bus using these free pins so that the PBX can integrate with more devices than just the garden light.

NOTE: PBX stands for Private Branch eXchange

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: The Theory Behind Phone Line Operation

First of all, an understanding of the basics of how a POTS (Plain Old Telephone Service, yes, that's its official name!) telephone line works is needed. I will briefly skimp over the parts that we will need to know for this project.

Telephone instruments already contain within themselves the necessary audio processing circuits to transmit and receive voice over simple wires. This means, you could connect two telephones in series to a power source (12-24 V DC), and have a very basic working intercom (albeit very limited, lacking even a way of making a phone ring, and thus not very usable).

A phone's on-hook/off-hook switch disconnects the phone's circuitry from the phone line, seen from the PBX as an open circuit when the receiver is placed down (on-hook), and a closed circuit (with the load of the phone's circuitry) when the receiver is lifted (off-hook).

When operating in pulse dialing mode (many phones have a switch on the side, or back, which can be set to either "T", tone, or "P", pulse), a phone will simulate the event of on-hook/off-hook switch being pressed and released X number of times, where X is a digit dialed, followed by a pause, and then repeating for the next dialed digit.

To make a telephone ring, the PBX sends an AC voltage of up to around 90 V at 20 Hz (all the phones I tested were able to ring also with 24 V AC at 50 Hz).

Many more features are supported by modern phone lines, whose method of operation is not described above, however in the PBX implementation described in this instructable (as well as the very early telephone switchboards from the 19th century, in all likelihood) only the above are going to be used.

Step 2: Theory Behind the Design

All our PBX needs to do, effectively, is to coordinate who wants to speak with whom at what time, interfacing to the actual instruments using the protocol described in the previous step. I'll start going through each of the points mentioned in the previous step and explaining the solution I used for each, before going into how everything integrates together.

As mentioned, phone instruments already have audio encoding/decoding circuitry inbuilt, we do not need to implement any audio circuits in our PBX. We simply provide around 12 V DC to each phone through a resistor, and connect together the circuits powering two phones that wish to communicate by means of a relay (i.e. circuit, meaning, after the resistor).

To detect when a phone's receiver is lifted, we connect a relay in series to each phone. Since we want to provide around 12 V DC to the phone, we use a relay with a 12 V coil, and power the combo from a 24 V DC power source. When the receiver is lifted, the relay coil is activated, when the receiver is replaced, the relay coil is deactivated, allowing a controller unit to be aware of the state of the phone by sensing the relay's contacts.

Likewise, the controller unit can also count on/off pulses of the relay contacts to detect a number dialed on the phone.

To make a phone ring, the controller unit activates a relay that disconnects the phone in question from the DC circuit, and connects it to a 24 V AC power source.

Yes, this does add up to quite a few relays :)

Finally, an Atmel ATtiny2313 microcontroller is used as "controller unit".

To simplify construction, future troubleshooting, and understanding of the circuit, I have separated the design into the following parts, which will be each addressed in a separate step, thus making the design more modular:

- Main board

- Relay driver boards

- Controller board

- Power supply

Step 3: What You Will Need

The components required to build this project are commonly available, I either already had or sourced from scrap sources most of them, thus the project turned out very cheap. If you would have to buy all the components, they might add up a bit (especially the phone instruments), but I would imagine that they will still be relatively cheap if compared to a commercial PBX solution.

To complete this project these are the parts I used:


-Prototyping board or other PCB

-Diodes IN4007 x18

-Relay 12 V DC coil, SPDT (two-way) x14

-Transistor 2N2222A x10

-Resistor 4.7k x10

-Resistor 470 ohm x11

-Resistor 220 ohm x4

-LED green x8

-LED yellow x2

-LED red x1

-Headers and mating wires with connector 2-pin x21

-Headers and mating wires with connector 3-pin x9

-Headers and mating wires with connector 4-pin x1

-Headers and mating wires with connector 8-pin x3

-Headers and mating wires with connector 10-pin x2

-Capacitors ceramic 4uF x4

-MCP1702 or LM7805 voltage regulator x1

-Capacitors 2200uF 63V x2

-Capacitors 1000uF 25V x2

-Resistor 10Kohms x1

-20 pin IC socket x1

-ATtiny2313 microcontroller x1

-Capacitor ceramic 100nF x1

-Transformer 230 V AC primary, 12-0-12 V AC secondary x1

-Transformer 230 V AC primary, 24 V AC secondary x1

-230 V AC fuse holder and connector block x1

-230 V AC power cord with plug x1

-Cat5 cable, approx 20 cm

-Telephone krone module (phone line connector)

-Enclosure of some sort

-Heatshrink, have always plenty in stock of all sizes :)


-Soldering iron (and solder and paste)

-Wire strippers


-Hot glue gun

-Atmel ATtiny2313 microcontroller programming device (and computer with compiler and flashing software)

-Krone module punch tool


-Basics of electronics (e.g. being able to use a transistor and/or relay)

-Basic familiarity with Atmel microcontroller (i.e. you need to be able to download the source code compile it and flash it on the device.)

-Basic confidence/experience/knowledge in working with 230 V AC mains electricity.


Please only attempt to build this project if you know what you are doing. A very brief reminder that electricity can be dangerous, different countries have different laws regarding its use and implementation, and phone companies may or may not be too happy if trouble arises on their phone lines due to a customer mis-wiring their phone. I cannot be responsible if any injury, damage, legal issues, or other arise during the attempt of following this instructable.

Step 4: Main Board

This board does the majority of the work. For each phone, it feeds 24 V DC through a resistor (R1-R4), through the coil of relay REL1-REL4, through the NC (normally closed) contacts of relay JP2,JP5,JP8,JP11 (relay not physically located on the board as I did not have any more PCB mount relays, this is only a header to which the relay's contacts are connected) and finally through the phone (connected to headers JP3,JP6,JP9,JP12) back to ground. Relays' JP2,JP5,JP8,JP11 normally open contacts are connected to the 24 V AC supply for the ringer. REL1-REL4 normally open contacts connect to headers JP15-JP16 which connect to the controller board. Finally the circuits of all the phones are interconnected through a capacitor (C1-C4) and normally open contacts of a relay (JP1,JP4,JP7,JP10) for voice to travel between the phones that are member of a call. Normally whenever multiple phones are picked up at the same time, they are isolated sound-wise from each other, preventing a third party from listening in on an existing phone conversation, (to my understanding, because of the resistors R1-R4, who also serve the purpose of limiting current through the phone instruments), and thus the corresponding relays of JP1,JP4,JP7,JP10 need to be activated in order for two phones to be able to talk to each other.

Step 5: Relay Driver Boards

In this project we are using a total of twelve relays. Four of them (shown in the previous step on the main board) are used for input to the controller, i.e. their coils are driven by the phones and their output contacts signal the controller. The remaining eight are used as output from the controller, i.e. their coils are driven by the controller, and their output contacts are used to manipulate the phone circuitry (to make a phone ring, or connect a call). The controller outputs a 5 V signal which cannot withstand the amount of current a relay coil needs (and on top of it the relays used require 12 V), thus the relay driver boards' job is simply to amplify the signal. Their circuit is of a very common design, a transistor is used to drive the higher voltage/current load from the low voltage/current signal, an LED is used to show the state of each output. One of the boards has a 12 V input header, and a 12 V output/logic input header which connects to the second board. The second board has in turn another 12 V output/logic input header which connects to the controller board. The controller board is powered from this header. On the first board there is also a power LED.

NOTE: Here I am using two separate PCBs and separated the driver boards into two only for space reasons, and because I had them ready since a previous project. There is no other reason preventing them from being unified into one.

Step 6: Controller Board

The controller board consists of the actual microcontroller (ATtiny2313) and a voltage regulator (and related capacitors) to convert the input 12 V DC to the required 5 V DC by the microcontroller. The microcontroller pins are connected directly to headers that connect to:

- JP1 and JP2 to the main board (logic input from the phones)

- JP4 to the second relay driver board (logic output to drive the relays, and 12 V DC power input)

- JP3 GPIO. Not necessarily connected anywhere. There were 5 pins unused on the microcontroller, thus they were connected to this header to interface with possible "addon" devices, along with 12 V DC power and the reset pin of the microcontroller. An example "addon" device is described in step 10.

You also need to flash the program (attached file pbx.c) onto the microcontroller. I strongly recommend that you don't solder the microcontroller directly onto the PCB, but use an IC socket instead, so that it is easy to remove the microcontroller and place it back, if ever it needs to be re-programmed.


Step 7: Power Supply

As seen in the previous steps, we have different parts of circuitry that run at different voltages, precisely:

24 V DC (phones themselves, in series with relays on main board.)

12 V DC (relays attached to the relay driver boards, controller board, etc.)

24 V AC (ringing voltage)

I have used two transformers, one with a 24 V AC output which is directly and independently connected to the header on the main board, the other with a 12-0-12 output connected to a PCB with a bridge rectifier and capacitors. This board in turn outputs 24 V DC (obtained from the output of the rectifier connected to the outer wires of the transformer) on one header, and 12 V DC (obtained from the center tap of the transformer and the GND output of the rectifier) on a second header.

Step 8: Preparing the Relays

As eight of the relays used are not PCB mountable, we now attach wires onto them to connect to the appropriate boards' headers. On all relays a set of wires with a 2-pin connector needs to be attached to the coil, as well as a surge protection diode. Then, on four of the relays a set of wires with a 2-pin connector needs to be attached to the normally open contacts of the relay. On the remaining four a set of wires with a 3-pin connector needs to be attached to the normally open and normally closed contacts (refer to the schematic of the main board, the normally open contacts need to be between pins 1 and 2 of the main board's JP2,JP5,JP8,JP11 headers, and the normally closed need to be between pins 2 and 3 of the same headers).

IMPORTANT: The surge protection diode needs to be soldered as close as possible to the relay, in this case meaning on the relay itself, not on the relay driver board.

Step 9: Putting It All Together

Now that all parts are ready, it's time to connect them together and place them into an enclosure of some sort. I was lucky to have a metal enclosure lying around that I obtained from someone who was throwing it out. Apparently used to host a burglar alarm system, but was a perfect fit for this project, it looked like it had been cut to size almost, and even had a 220 V input screw terminal, with fuse. I found a nice spot for each of the boards and fixed them in place with a hot glue gun. I did not directly glue the back of the boards to the metal for ease of maintenance (and for fear of a short circuit taking place despite the layer of glue), I instead added some long pieces of plastic (poor quality drill wall plugs in this case) in between to create a space. Then connected all the boards to each other, the schematic of how my boards interconnect is shown in the picture diagram. I connected a 3-core power cord (with 3-pin plug on the other end) to the input screw terminal, and all telephone outputs from the main board, through a 2-pin connector soldered to a piece of Cat5 cable to a standard krone module (telephone line connectors).

Step 10: Relay Module for GPIO (optional)

While building the controller board, we connected 6 free pins of the microcontroller to a spare header, for generic purpose usage with any "addon" devices, meaning devices that are not required for the basic functionality of a PBX, but that can provide extended functionality that can integrate into the PBX. In the example I am showing here, I have built a relay module that will allow control of power to electrical devices based on events in the PBX.
I have then programmed the PBX to control these outputs based on numbers dialed from a phone. This board once again, consists of a very simple 'transistor driving relay coil' circuit, has a four pin header which has to connect to the first four pins of the eight pin header on the controller board, through which it sources power for the relays and two digital logic signals. It has two relays.

Step 11: Usage

That's it. Connect a telephone instrument to each of the phone outputs, ensure they are set to pulse dialing mode, optionally connect the "addon" relay board to the appropriate header on the controller board and connect a lamp or other electrical device through the relay, and insert the plug into a wall outlet.

Lift up one phone, dial the number of another phone. The second phone should ring. Lift up the second phone and speak. When done, replace both phones before attempting to make a new call. To activate/deactivate a relay of the "addon" board lift any phone's receiver as if making a call, dial the number associated with the relay, wait for the phone to complete dialing and replace the receiver. The programmed phone numbers are as follows:

1 - call phone 1

2 - call phone 2

3 - call phone 3

4 - call phone 4

51 - switch on GPIO output at PD5 pin of microcontroller (first relay on the "addon" board)

50 - switch off GPIO output at PD5 pin of microcontroller (first relay on the "addon" board)

61 - switch on GPIO output at PD4 pin of microcontroller (second relay on the "addon" board)

60 - switch off GPIO output at PD4 pin of microcontroller (second relay on the "addon" board)

71 - switch on GPIO output at PD6 pin of microcontroller (not used on the "addon" board as shown, as I only made it with two relays)
70 - switch off GPIO output at PD6 pin of microcontroller (not used on the "addon" board as shown, as I only made it with two relays)

81 - switch on GPIO output at PA0 pin of microcontroller (not used on the "addon" board as shown, as I only made it with two relays)
80 - switch off GPIO output at PA0 pin of microcontroller (not used on the "addon" board as shown, as I only made it with two relays)

91 - switch on GPIO output at PA1 pin of microcontroller (not used on the "addon" board as shown, as I only made it with two relays)
90 - switch off GPIO output at PA1 pin of microcontroller (not used on the "addon" board as shown, as I only made it with two relays)

That's it! Please feel free to leave any comments, improvement suggestions, etc.

Automation Contest 2016

Participated in the
Automation Contest 2016

Be the First to Share


    • Backyard Contest

      Backyard Contest
    • Silly Hats Speed Challenge

      Silly Hats Speed Challenge
    • Arduino Contest 2020

      Arduino Contest 2020

    7 Discussions


    5 months ago

    Hi there! Well done to work this out with a PIC controller chip and source code. It becomes complicated when you want to read dial pulses going into a microprocessor, that's why I avoided that approach. DTMF tone dialling may be an upgrade you might want to consider for the future, seeing you've nutted out the coding for all the basic features.

    My approach to telephone intercoms was much simpler. My first attempt was an A to B link circuit using two relays and a 555 timer chip. I also used 9 volt DC buzzers for each handset to avoid the use of high/dangerous ring voltages. This unit ran quite happily on 12 to 15 volts DC and you could combine old rotary phones with more modern push button models by using a 220 ohm resistor in one leg of the rotary phone line, to provide for 'current sharing' between the two phones. A version of this intercom is here on Instructables if you want to check it out.There's also a solid state version elsewhere online, that replaces the relays with optocouplers. Just Google "Link Intercom A to B" and it should pop up.

    My second attempt used a CD4017B decade counter IC to count dial pulses using optocouplers to square up the dial pulses and interface each phone handset, and a NE 556 dual timer chip to generate dial tone and ring tone for each handset. The phones were wired in parallel (party line) and you could only have one call at a time, but it was great for around the house or small workshop, warehouse, scout den etc. It was called "The Link Telephone Intercom" and can still be found on websites that stole the design and denied me any credit... This unit also used DC buzzers instead of bell current.

    My third attempt used tone dialling, a simple relay matrix for switching calls, the familiar NE556 dual timer IC for service tones and a true 'ring trip' circuit that detected when a phone was picked up 'off hook' to answer a call. Ring voltage was around 30 volts AC and the handsets used were much more modern TF 200 phones by Telstra. This design was called "The Link P - Privacy Link' and although you could still have only one call at a time, that call was private. The other two phones excluded from the call received a busy tone signal. Last party release reset the Link circuit ready for the next call. This design still used hard wired logic with no processing chip involved.

    I think you've done really well, but with all such projects, while they have their attributes, they also have their limitations. Try adding service tones and DTMF tone dialling as a possible upgrade in the future - you'll probably enjoy the challenge and the achievement will please your readers. Has anyone indicated that they've built a copy of your design yet? That's always a good encouraging sing.

    Well done dr research... :)


    Question 9 months ago

    I want to understand how you detect off-hook when you detach the 24V DC to apply the 24V AC ringing voltage. Surely the off-hook relay has not path to ground once the ringing voltage relay is activated. Please advise. Best regards.


    2 years ago

    I have a full fledged mini PBX plan with one external and 3 extensions available. The DTMF decoding uses Geortzel Algorithm. I'd like to share it with someone who have spare time to code with Arduino. I'm reachable by gmail with account of yubingnz. Cheers.


    Reply 1 year ago

    It is available in youtube uploaded by Make:


    1 year ago

    Would love to see and hear a video of this operating.


    3 years ago

    nice; but a bit too complicated for my skill set. Any easy Way to just connect 2 phones eg one in kitchen and one in the garage to avoid trekking between the two places? ?
    thanks for your detailed setup.


    Reply 3 years ago

    Yes, it is possible, with a limitation. You can connect two phones in series or parallel to a 12 V DC power source (better use a resistor in series between the power source and the phones, a 220 ohm like the one I used should work). If you lift up both phones you should be able to talk, but you will not have any way to make the phone on the other end ring when you want to call.