Emergency Phone Call Alert to an Arduino via an Asterisk PBX

Recently, I created this simple circuit (and corresponding code) which makes an emergency phone call alert to an Arduino via an Asterisk PBX.  This project was for someone who needed to be alerted (silently) if someone made an emergency phone call on their Asterisk PBX. By the way, the free and open source Asterisk PBX is a fantastic phone system which can be easily adapted (via custom scripting) to do amazing things!

For this project, the Asterisk dialing plan for the emergency number is set to invoke an AGI script (which in this case was written in python). The AGI python script reads the SIP configuration and creates an Asterisk call file for each SIP peer which puts them all in a conference room. The scenario for this is something like a condominium where there might not be a dedicated person to answer the emergency call, instead everyone in the building (so to speak) is called. The python script also accesses the WEB page of the server running on an Arduino which will rapidly flash an “emergency” light.

I created this simple relay circuit with an S108T02 solid state relay to control the light (CFL). Here is the Fritzing diagram:

S108T02 Relay Fritzing Diagram

You can download the Fritzing code for the circuit here and modify it for your needs. Here is what the circuit looks like when it is built:

S108T02 Relay CircuitEmergency Phone Call Alert to an Arduino via an Asterisk PBX Circuit


Note that the board is about double the size needed so I can add a second relay if future needs require.  🙄

The Arduino code uses the UIPEthernet library to basically create a WEB server. When it is 1st accessed the light is turned on. Access it again and it is turned off. It is a ‘toggle’ so it can be tested from a browser client.  The circuit is attached to an arduino via the pinToToggle value (and also +5V and GND). Additionally the Arduino is connected to an ENC28J60 module for LAN/Internet access. See my previous posts here and here for connecting an Arduino Leonardo to an ENC28J60.

Here is the Arduino code:

The python AGI script:

If you try this out make sure to change the IP addresses in both scripts to match that of your Arduino. Also note that the python AGI script emails someone that the call was made. Check out the bottom part of the AGI script and change the email address to the correct one. (Or comment out that part if you don’t want it to email anyone.)

Leave a Reply

Your email address will not be published.