End robocaller, solicitation, and hangup calls with Asterisk & Raspberry Pi

Do you have a land-line that is constantly barraged with unwanted robo, solicitation, and “hangup” calls, even though you’re on the do not call registries?   This project uses a Raspberry Pi and an OBi110 voice-bridge to create an Automated Attendant (AA) to screen calls for you!   The annoyance calls on my line have dropped from five or six/day (with many more during political “seasons”) to zero.  This is a low-power, low-cost solution with extreme expansion possibilities, and it’s a fun way to gain experience with the Pi & the Asterisk PBX software.  As an added bonus, my wife “really loves it;  our home is more peaceful”.

Raspberry Pi and OBi110

Raspberry Pi and OBi110

You won’t need to dive deeply into Asterisk to create this project. However, should you find yourself intrigued,  I’ve included references to help you along the way.  Familiarity with text editors (nano, vim), routing, and your local Internet infrastructure (IP assignment) is required for configuring addresses on the Raspberry Pi and OBi110.

Basic Phone with answering machine

Basic Analog Phone with answering machine

Secretly, what we’re doing is turning your old analogue phone into a VoIP phone using the OBi110 (a voice bridge), so that calls can be handled digitally by the Raspberry Pi.   The only external Internet service used is the network time protocol (NTP) since the Pi doesn’t have a real-time-clock  built-in (though one can be added).  A network connection isn’t essential, but it is convenient for configuration.  See the entry on Running RasPBX without an Internet connection. With no Internet connection, a crossover network cable can be used to tie the Pi directly to the OBi110.

Configuration of the OBi110 can be done via the phone hand-set, but it’s (much) easier using the web interface.

Note:  The configuration described in this post assumes that you have only a single phone or base-station on a POTS line.   Once the call has been screened, only the phone physically connected to the OBi110 will ring-through.   The answering machine and base-station pictured above has several wireless phones that ring from the base-station.  The base-station takes messages.   Caller-id on your phone is not assumed or necessary.

This is the call flow:  Asterisk answers an incoming call immediately.   The caller is then informed that they have reached a number that does NOT accept solicitations and they should “please hang up NOW”; “to connect, press 1”.   If no number is pressed within 10 seconds, Asterisk hangs up.  If any number other than “1” is pressed, Asterisk hangs up.  Once “1” is pressed, the caller is informed to please wait, while “music on hold” is played.  As this happens, Asterisk rings the handset.  If the phone isn’t picked up within 45 seconds, Asterisk hangs up.   It’s assumed that the phone’s answering machine will pick-up before then (all that in 8 lines of code).

By changing the Asterisk configuration, your computer and/or other internet (SIP) phones/services can be rung at the same time.   Asterisk can also be configure to record messages and forward them via email or picked up remotely.  White/Black (allow/deny) phone number lists can be created, as-well-as many, many other features (but that’s beyond the scope of this post).

Checking with my local phone company, they wanted $6/month for Caller-id, and another $6.00/month for call screening.   Dropping these two options alone, the pay-back period for this project is about one year.  Drawing less than 20 watts of power, at $0.11/kwh, the electrical burden is about $20.00/year ($1/year/watt).

The basic steps for this project are:

1) Acquire the parts
2) Load the Raspberry Pi Asterisk distribution onto a 4Gb SDCARD
3) Test and perform initial configuration of the Raspberry Pi/Asterisk
4) Test and configure the OBi110
5) Configure Asterisk to recognize the OBi110, and set-up the Attendant program
6) Verify the OBi110 and Asterisk server are working together

Step 1:
You’ll need a Raspberry Pi, power supply, micro-usb cable4Gb SDCARD, OBi110, a couple of Ethernet cables to tie the Pi & OBi110 into your network, an SDCARD reader/writer (very cute, easy to lose, and the “lanyard” broke right-off), 4-conductor telephone cables (one comes with the OBi110), and a power strip to plug the two devices into.  Acquire these from your favourite vendors; I happen to like the folks at Adafruit. You might have to hunt around for the Pi’s, since they tend to sell-out quickly.

If you’re not familiar with the Raspberry Pi, power is provided via a micro-usb connector, and the SDCARD substitutes for a hard-disc (a small SSD drive).  You won’t need video/keybd/mouse if you ssh-login to the Pi (sshd is enabled by default).  If you’re not familiar with SSH, just google “SSH Clients”.   If you want to-go crazy with video, the Pi has HDMI and NTSC video outputs.   Since all I have are VGA monitors, I use a powered converter (very important).  I had intermittent problems with an un-powered HDMI=>VGA adapter; the consensus on the web seems to be that they draw too much power from the Raspberry Pi’s HDMI port.  In the /boot/config.txt file on the Pi, I only had to set sdtv_mode=0 for video to work.

Step 2:
First, download the Raspberry Pi Asterisk distribution from here.  The install it into your 4Gb memory card using the SDCARD writer; instructions for writing can be found here.  You will need 4Gb free on your local system to unzip it.  Copying the image to the memory card could take up to half an hour.   Linux tip:  Use a blocksize of 1M (1 megabyte) when issuing the “dd” command:

sudo dd bs=1M if=raspbx-19-01-2013.img of=/dev/sdc (your file names will vary)

Then plug the SDCARD into your Raspberry Pi (underside of circuit board).

Step 3:
Now, connect the Pi to your network with an Ethernet cable.   Then plug the usb-A end of the cable into the 5V 1A (or more) power supply, and plug the micro-usb end into the connector on the top of the Pi circuit board, located above the SDCARD.  After a couple of minutes,  “ssh in-to” the Pi (ssh root@raspbx).  The root password is “raspberry”.  At this point, if you have familiarity with Ubuntu or Debian Linux distributions, you should feel pretty comfortable.  Next, configure a static IP address for your Pi; you will do the same for the OBi110 later so they can talk to each other, and you can talk to them.  Next, set your timezone by running the command:

dpkg-reconfigure tzdata

Update to the latest version of Asterisk (and apply OS upgrades) by running:


This could take an hour or so (don’t forget to type “y” when you are asked to continue).  Towards the end of the upgrade you’ll be asked to keep or upgrade a couple of files.  I opted for the upgrade (“Y”).   If the web server (apache2) fails to start after the upgrade, run the commands (as user root):

chown www-data /var/lock/apache2
echo ServerName $HOSTNAME > /etc/apache2/conf.d/fqdn
service apache2 start

Now, lets add a couple of programs that will allow sound files to be created & modified:

sudo apt-get install mpg123 sox
and because I prefer vi as my editor:
sudo apt-get install vim

Reboot your Pi to verify it’s IP and connectivity.

Step 4:
Plug in your OBi110 to power and the network.  Initially, the OBi110 assumes a DHCP server is running, so find its assigned IP. The OBi110 admin guide covers how to get the current IP address using the phone.  Then enter the address into your browser: “http://xxx.xxx.xxx.xxx”, where the X’s are the OBi110’s IP address.  The default user name and password is “admin”.

NOTE:  As changes are made on each page to the OBi110, they must be saved by pressing the “submit” button on the bottom of each page BEFORE navigating to another page.  Once all the pages have been configured, press the “Reboot” button in the upper right corner to activate the changes.    Any-time changes are made, the OBi110 must be “Rebooted” to put them into effect.

Now (as a debug measure), plug your phone and POTS line into the OBi110.  You should be able to make and receive calls as-if the OBi110 wasn’t present.   If this is not true, then do-not proceed.  Check the OBi110 FAQ or the Administration Guide.

A couple of good sites on the OBi110 are the quick-start guide, and configuring an OBi110 as an FXO gateway (FreePBX guide).    Follow step 1 in “configuring an IBi110” (go ahead and set your local time zone on the same page).  Then as you start into step 2, “YOURPBXIPADDRESS” is the static IP assigned to your Pi (the PBX);  then change the AuthPassword to be something else besides “FXOPASSWORD“;  set the URI to: OBITRUNK1@xxx.xxx.xxx.xxx, where “xxx…” is the IP address of the Pi.  Be sure to press “Submit” before moving to the Line Interfaces page.

Go ahead and set InboundCallRoute (your phone #) as show, and RingDelay.  If you don’t have caller-id, set RingDelay to 0 (zero).   You don’t set any more parameters on the Line Port (setting the DialDigit[On/Off] times lower caused my phone to mis-dial).

NOTE:  I added “ph,” in front of the “SP2(xxxxxxxxxx)” (don’t include the quotes, but the comma is important) so that both the phone and the PBX are “rung” at the same time; so in case the PBX doesn’t answer, a call won’t be missed (trusting, eh?).   Don’t forget to “Submit” each page before going to the next one.

Next, we need to configure “Side A” of the OBi110;  we’re not going to be using it to communicate with Google Talk, etc, like many other blog posts describe, instead we’re going to let the Pi “call out” to the telephone.

Under Service Providers => ITSP Profile A => SIP,  set ProxyServer to the Pi’s IP address, check X_UseRefer, enter the Pi’s IP address into X_AccessList, and press “Submit”.

Under Voice Services => SP1 Service, set AuthUserName to PHONE, and enter a password you’ll remember in AuthPassword.  In URI, enter PHONE@xxx.xxx.xxx.xxx (xxx.. is the Pi’s IP address), set MaxSessions to 5, check MWIEnable and X_VMWIEnable, then uncheck MessageWaiting, but don’t put anything in the field (don’t forget to “Submit”).  At this point, you can “Reboot” the OBi110.

Step 5:
Grab the no-solicitors sound file (or use your own), create a custom sounds directory on the Pi, copy the file into the custom sound directory, and set the proper permissions (on the Pi):

mkdir /var/lib/asterisk/sounds/en/custom/
(from an outside shell) scp no-solicitors.wav root@xxx.xxx.xxx.xxx: (IP address of your Pi – and enter the root password – “raspberry”)
mv /root/no-solicitors.wav /var/lib/asterisk/sounds/en/custom/
chown -R asterisk.asterisk /var/lib/asterisk/sounds/en/custom/

Note: The “scp” program copies the .wav file to “/root” on the Pi from another computer where the file is located.

We’re almost there!   Now we just have to update a couple of Asterisk configuration files located in the directory /etc/asterisk.

At the end of the file “/etc/asterisk/sip.conf“, add:

type=friend                ; Friends place calls and receive calls
secret=  (The AuthPassword used for SP1 Service in the OBi110)
host=dynamic               ; This peer register with us
dtmfmode=rfc2833           ; Choices are inband, rfc2833, or info
defaultuser=Home           ; Username to use in INVITE until peer registers
allow=ulaw                 ; dtmfmode=inband only works with ulaw or alaw!

[PHONE](OBi110)                ; Create an extension

secret= (The AuthPassword used for SP2 Service in the OBi110)


(Where “xxxxxxxxxx” is your phone number used for the InboundCallRoute parameter in the Physical Interfaces => LINE Port of the OBi110)

At the end of the file: “/etc/asterisk/extensions.conf“, add the actual working code:

; Answer and wait a second (1000ms) before continuing.
exten => xxxxxxxxxx,1,Answer( 1000 )
;    Zap robo callers - uncomment the following line if desired.
;    same => n,Zapateller()   ; Send "number no longer in service" tones

; Play "no-solicitors" audio file & get a single digit touch-tone input
same => n,Read(digit,custom/no-solicitors,1) ; Get a digit
;    same => n,SayDigits(${digit})           ; debug
;    same => n,Goto(bye)                     ; debug
same => n,GotoIf($["${digit}" != "1"]?bye)   ; verify digit
same => n,Playback(one-moment-please)

; Forward call to handset with music while waiting for pick-up (up to 45s)
same => n,Dial(SIP/PHONE, 45, m)

; If we time-out or the wrong digit is pressed, politely exit.
same => n(bye),Playback(vm-goodbye)
; Wait a second so that the text can finish getting out, then hang-up
same => n,Wait(1)
same => n,Hangup()

(Again, where “xxxxxxxxxx” is your phone number used for the InboundCallRoute parameter in the Physical Interfaces => LINE Port of the OBi110)

Then restart asterisk using the command:

service freepbx restart

Step 6:
Be sure the phone-line from the telephone company is plugged-into the OBi110, as-well-as your phone handset.  While logged-into the Pi, run the command:

asterisk -rvvvvv

This will bring up the command-line interface, in verbose mode (level 5).  When a call is made to your number, it should appear as lines in the command-line interface.  Type “help” to see possible commands, and “quit” to exit.   When a call is made, the asterisk command line-output should look something like:

== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
-- Executing [xxxxxxxxxx@from-trunk:1] Answer("SIP/OBITRUNK1-00000009", " 1000 ") in new stack
-- Executing [xxxxxxxxxx@from-trunk:2] Read("SIP/OBITRUNK1-00000009", "digit,custom/no-solicitors,1") in new stack
-- Accepting a maximum of 1 digits.
-- <SIP/OBITRUNK1-00000009> Playing 'custom/no-solicitors.slin' (language 'en')

(and so on).   If you get nothing, and the phone just rings through, then chances are very good that the OBi110 has not been configured properly.    Note: other messages will indicate improper password, etc., so pay close attention to the diagnostic output.   Go back and check the OBi110 configurations, be sure that they were all saved properly, then reboot the OBi110, and try again.  Also, be sure you can “ping” each device from another computer on the network.

Last, but not least, is the issue of security.   I haven’t touched on this before, as I assume that your system is behind a firewall and no “bad-guys” have access to it.   VoIP Info has a page addressing issues, Digium has a page also.  The biggest vulnerability is someone accessing your PBX from the Internet and making “expensive” calls.

Tons of documentation about the hardware & software is available just by “googling”.  Since the Raspberry Pi is open-source hardware, the schematics can be found here.

Digium created and maintains the source code (available here), and the best references are the books create by the Authors of the code themselves:  “Asterisk: The definitive guide (3rd edition)“, and a pre-release of the 4th edition.

Asterisk includes a wonderful collection of voice snippets from Allison Smith, the IVR Voice.  They reside in the directory /var/lib/asterisk/sounds.    Asterisk for the Raspberry Pi is also bundled with FreePBX; feel free to explore this web-based interface for Asterisk.

This project barely touches the capabilities of Asterisk.  Look around the web.  See what kinds of projects Asterisk (and FreePBX) are being used for.   I think you’ll be amazed.

UPDATE:  Be sure to power-down your Pi before removing power (“halt -p”) and wait for a single red LED indication.  I did some shifting of power cables, and caused unrecoverable (EXT-4) file-system damage (good thing I had a back-up SDCARD).   Putting it on a UPS is probably a good idea.

This entry was posted in Telecom. Bookmark the permalink.

55 Responses to End robocaller, solicitation, and hangup calls with Asterisk & Raspberry Pi

  1. Alice says:

    Thank you for the great documentation. I’m new to asterisk and I used your information to get up and running, quickly. Now I’m reading the documentation to find out how I can forward incoming calls to my goggle voice number rather than let them ring through (I really like the email voice mail transcripts from GV). You’ve helped quite a bit to get me up and running. Thanks!

    • Ace says:

      I currently have been using google voice with obi and i just got the pbx but i am having difficulty with getting everything working. It would be great if somebody can remote into my pc and help set it up, i am happy to offer a donation via paypal for your time.

  2. Jess says:

    I love your guide. I’d like to implement it but instead of all call being challenged to press 1, I’d like to set it up to where I have a whitelist of calls I want to ring through based on the callerid number, and all calls outside the whitelist get challenged. I’ve looked around on Asterisk’s community but it’s all pretty technical. Any chance you could point me in the right direction or add steps if someone wants to do that? Thanks!

    • Bill says:

      Hi, and thanks for the feedback. I suggest you dig into the “Asterisk The definitive Guide” ; the third edition is on-line (free), but the 4th edition covers Asterisk 11 (what you are using?). To operate a whitelist, you’ll want to get a database interface working; AstDB is probably the easiest (chapter 10, pp 253-254, or on-line). The dialplan code will then have to be changed to-do database lookups in the /etc/extensions.conf file. In [from-trunk], an easy way to-do this would be to use the BLACKLIST() function, but in reverse. Put the numbers you want to white-list into the AstDB as black-listed, then follow the example code at: http://www.voip-info.org/wiki/view/Asterisk+func+BLACKLIST and reverse the two lines under the GotoIf() line. This will cause the call to be put through if the number is black-listed (your whitelist), otherwise it hangs up.

  3. Sarduchi says:

    I’m stuck trying to follow this guide… everything LOOKS to be setup correctly, but I get the message Registration from '' failed for 'yyy.yyy.yyy.yyy:5060' - Wrong password where xxx.xxx.xxx.xxx is the RasPBX box and yyy.yyy.yyy.yyy is the OBi110.

    Passwords in sip.conf and SP1 Service match, so no idea what the issue is…

    • Bill says:

      Hi Sarduchi,

      If you look at your error message, “Registration from ” failed ..” The OBi110 isn’t registering with the Asterisk server properly. I don’t think it’s a password problem, but one of identification. Lets recap the OBi110 settings: Under the “System Management” menu, all the submenu options are set to default except for the “Network Settings”=>”Internet Settings” and “Local Time Zone” (sounds like you have those set ok). All other settings in all menus & submenus are “defaulted” except as noted below:

      Under “Service Providers”=>”ITSP Profile A”, the only parameters not “default” are under “SIP”, with “Proxy Server” set to the IP address of your Asterisk Server, X_UseRefer “checked”, and X_AccessList set to a comma-separated list of IP addresses allowed to access the OBi110 (your Asterisk server should be one of them). Be sure to click “Submit” before moving off the page if you’ve made changes.

      Under “Service Providers”=>”ITSP Profile B”, the only parameters not “default” are under “SIP”, with “Proxy Server” set to the IP address of your Asterisk Server, X_SpoofCallerID “checked” (NOT X_UserRefer), and X_AccessList set to a comma-separated list of IP addresses allowed to access the OBi110 (your Asterisk server should be one of them). Be sure to click “Submit” before moving off the page if you’ve made changes.

      Under “Voice Services”=>”SP1 Service”: AuthUserName is set to “PHONE”, AuthPassword is your password, and URI is “PHONE@xxx.xxx.xxx.xxx” where “xxx..” is the IP address of your Asterisk Server. I also set “MaxSessions” to 5, and clicked “MWIEnable”, and “X_VMWIEnable”.

      Under “Voice Services”=>SP2 Service”: “X_ServProvProfile” is set to “B”, “X_InboundCallRoute” is set to “li”, “AuthUserName” is set to “OBITRUNK1”, “AuthPassword” is your password, and “URI” is “OBITRUNK1@xxx.xxx.xxx.xxx” where “xxx..” is the IP address of your Asterisk Server. I also clicked “CallForwardUnconditionalEnable”, and “AnonymousCallEnable”.

      Moving on to “Physical Interfaces”=>”LINE Port”: “InboundCallRoute” is set to “ph, SP2(xxxxxxxxxx)” Where xxxxxxxxxx is your 10 digit phone number (same as above). I set “RingDelay” to 0 since I have no caller-ID on this line. I also set “SilenceTimeThreshold” to 600 seconds, so that the OBi110 will hang up if there’s no activity.

      Everything else is default. Go ahead and power-cycle the OBi110 after this, and verify the settings. I hope this helps!

      If you check under “Setup Wizard”, “ITSP SIPProxyServer” should be set to the IP of your Asterisk server, “ITSP AuthUserName” should be “9”, “ITSP URI” should be “9@xxx.xxx.xxx.xxx” where xxx.xxx.xxx.xxx is the IP of your Asterisk server, and “POTS-line InboundCallRoute” should be “ph, SP2(xxxxxxxxxx)” where xxxxxxxxxx is your 10-digit phone number.


      • Sarduchi says:

        Thanks for the prompt response.

        Everything is setup as you describe, but I am still getting the “Registration from ” failed for ‘yyy.yyy.yyy.yyy:5060’ – Wrong password” message where xxx.xxx.xxx.xxx is the RasPBX system and yyy.yyy.yyy.yyy is the OBi110.

        One question, you say to use “user password” for the PSTN AuthUserID, but where is that user defined? Likewise in the sip.conf we have defaultuser=Home but no clear definition of that user.

        Is there anything I can provide that could help you help me?

        • Bill says:

          Hi Sarduchi,

          The placeholder use of “Home” is only until your Obi110 registers successfully, so don’t worry about it (see the comment). Under “Voice Services”=>”Gateways and Trunk Groups”: Under “Gateway1″, the field “AuthUserID” is set to “PSTN”, and “AuthPassword” is your password (“secret” in /etc/asterisk/sip.conf). Set both “secret” values to the same password, and use that password for the fields in the OBi110. I’m still concerned that the error message has “registration from ”” which would indicate there is no name from the OBi110.

          Log into the raspberry pi (or Asterisk server) as root and issue the command “asterisk -rvvvvv” to see if you can get more error information.


          • Sarduchi says:

            Ignore the registration From “” in my first post, it looks like data got lost (< and > got treated as tags). Message is…

            “Registration from ‘<sip:9@>’ failed for ‘yyy.yyy.yyy.yyy:5060′ – Wrong password” message where xxx.xxx.xxx.xxx is the RasPBX system and yyy.yyy.yyy.yyy is the OBi110.

            I have two secrets in my sip.conf, one for [OBi110] and one for [OBITRUNK1], both are set the same and used in the OBi110 configurations for AuthUserName “9”, AuthUserName “OBITRUNK1” and AuthUserID “PSTN”. What I don’t see is a definition of PSTN on the RasPBX side, but that may not be needed?

          • Bill says:

            Hi Sarduchi,

            My bad, under “Voice Service”=>”Gateways and Trunk Groups”, everything should be set to default (I’ve amended my earlier comment). No need for PSTN, .. Just reset those fields, press submit, and reboot the OBi110. That shouldn’t effect your issue though. So is the IP for your Asterisk server, or the OBi110? Could you give me the IP’s for both? You’re behind a NAT firewall, so they’re not accessible by anyone outside. If you haven’t rebooted since making changes, you may try again to see if things work.

            Do you get the registration error when you first power-up the OBi110, and you’re doing an “asterisk -rvvvvv” from the server? Any other messages?



          • Sarduchi says:

            [2014-05-24 15:04:45] NOTICE[2927]: chan_sip.c:28144 handle_request_register: Registration from ‘<sip:9@>’ failed for ‘’ – Wrong password

            Above is the full message I see when running “asterisk -rvvvvv”. It is the only message until an incoming call is accepted.

   is the RasPBX system and is the OBi110. This error happens every 30 seconds as the OBi110 retries to authenticate.

            On the OBi110 status page I see “Register Failed: 403 Forbidden (server=; retry in 21s)” for SP1 Service Status while SP2 Service Status shows “Registered (server=; expire in 56s)”.

            If I call into the system, the call is correctly routed to RasPBX and the automated attendant answers. The issue of course is that I have no way to reroute the call back out to the phone.

          • Bill says:

            Hi Sarduchi,

            Go ahead and send copies of your /etc/asterisk/sip.conf and /etc/asterisk/extensions.conf file (reply to the email I sent you). Then make sure the URI variable in “SP1 Service” is “9@”, and in “SP2 Service” it’s “OBITRUNK1@”. Go ahead and retype-in the password in the two places (be sure to press “submit” before changing pages), then reboot — just to be sure.


          • Bill says:

            Hi Sarduchi,

            I’ve examined the files you sent, and they all seem fine. Uptime on my Pi is over 400 days w/o a reboot or upgrade, so I’m upgrading to the latest version with “raspbx-upgrade”. It may be an issue with the base software(?) .. Just trying to rule things out.


          • Sarduchi says:

            I have done so, thanks.

  4. Ryan says:

    Thanks for the how-to. I just set this up, and it works great.

    I am interested in removing the system’s dependency on being connected to the Internet and setting the Raspberry Pi’s system clock from incoming caller ID information. Do you have any idea how I might go about that?

    • Bill says:

      Hi Ryan,

      Excellent, glad to hear you got yours going. You can hook the OBi110 and Pi together with an Ethernet “crossover” cable (or just use a small hub). The time issue is more interesting. Here in the USA, time/date information is not sent with the caller-id, so I have no way to test things. Also, Asterisk won’t be running as “root”, so setting the time from Asterisk could be a problem. A couple of things you might do:

      1) Run your own time-server, so the Pi doesn’t have to go onto the Internet.
      2) Add a real-time clock (RTC) to your raspberry pi:
      3) Set up an ssh script to run from one of your other computers (that presumably is time-slaved) to set the time on the pi (as root) when it
      boots from your /etc/rc.local, or set by cron daemon, etc.)
      4) Set it manually when you notice it’s getting off by too-much. At one point, I didn’t check my Pi for over 400 days, though 😉

      Hope that helps!


  5. Ryan says:


    Thanks for your insight. I ordered an RTC module the other day and will probably just rely on it instead of trying to keep the clock synched with the phone company’s date and time.

    In case you or anyone else is interested, here’s what I’ve discovered about how someone might make use the date and time provided by the phone company:

    My phone company (AT&T) sends the date and time with the caller ID information. In fact, that’s the only way the date and time get set on my standalone caller ID units.

    I don’t know if there is an easier way, but it is possible to get semi-raw caller ID data (including the date and time from the phone company) from the OBi110 using its network logging feature. The OBi110 can be configured to send log information over the network as shown . I tried Obihai’s logging server, and saw that Caller ID name and number information is included in the log information preceded by the date and time in a “MMDDhhmm” format. The phone company does not send the year.

    So, it should be possible to run a script on the Pi to monitor the log information from the OBi110 and dig the date and time out of it. I might give this a try if I get around to it, but I’ll just use the RTC module and set the date and time manually for now.

    • Bill says:

      Hi Ryan,

      Thanks for the feedback and your discovery. Good input; I haven’t tried the RTC module myself, but I’ve used a lot of stuff from Adafruit.


  6. Bruce Ferjulian says:

    I too setup this something close to this but instead used a BeagleBone Black board. After I set it up and was reading through the administration guide for the Obi110 I came upon the section about “Auto Attendant”. I figured out how to enable the menu in the Obi110 with my pre-recorded message stating up-front, which calls I would not take and required the caller to press “1” to continue. It has kept the robocallers at bay and did not require maintaing Asterisk in the equation. Either solution would work and the Asterisk based solution has endless possibilities.

    I just kept is simple after figuring out all of this could be one in the Obi110 itself. Seeing if I could keep it in the Obi110 exclusively proved that there was a solution for grandparents which are not tech savy keeping things small and simple.

    You did a great job documenting, it was an enjoyable read.

    • Bill says:

      Hi Bruce,

      Thanks for the feedback and tip on how-to use the Obi110 stand-alone. Like you, we get a LOT less calls!

    • James says:


      As the OBi110 is no longer available, do you know if any of the newer models can can do the same thing as the OBi110 and make a stand alone call screener?

      My father’s new house phone is the same as a popular local bakery with the last 2 numbers transposed, he gets an endless stream of calls for the bakery.

  7. Stephen says:

    Hi Bill,

    After 1 day of tinkering with wireless adapters and settings all set up and working. I have the pi and obi connected via crossover but can still access pi using ssh wireless as there is no ethernet by the phone.

    Remember anyone following the instructions read the output of CLI because it tells you if you have a wrong password etc, helped me when I messed up.

    I couldn’t have done it without you so thanks a lot!

  8. Phil S says:

    Awesome project — thanks for a very clear and detailed description of how to set this up. I was able to build and program the blocker with very few difficulties (mostly my own makings).

    However, I was concerned about one problem with the way this works: What to do with what could be called “benign” robocalls, i.e. ones from a doctor’s office concerning appointments, or from a pharmacy about prescription refills. To deal with this I made some modification to implement a “whitelist” to allow such calls to go through. Here is how I did it:

    First create a whitelist. To do that get the Asterisk Command Line prompt. See Step 6 above to see how. Then enter the following command:

    raspbx*CLI> database put

    is whitelist, is CallerID number, is associated name, in quotes. For example:

    raspbx*CLI> database put whitelist 3125551212 “Dr Pheelgud”

    Repeat this command for all the numbers you want in the whitelist.

    Next, to get asterisk to use the whitelist insert the following line between the first line [answer( 1000 )] and the second line [n,Zapateller()]:

    same => n, GotoIf(${DB_EXISTS(whitelist/${CALLERID(NUM)})}?fwd)

    And then add the fwd tag to the n,Dial(SIP/PHONE, 45, m) line, so that it reads:

    same => n(fwd),Dial(SIP/PHONE, 45, m)

    With this change an incoming call will be checked to see if the CID is in the whitelist. If it is it will be forward to your phone; if not it will go through the Turing test as before, connecting only if a human is calling.

    • Bill says:

      Hi Phil,

      Great update, thank you! Unfortunately, I don’t subscribe to caller-id (sigh).


      • Phil S says:

        Glad I was able to add to your project.

        Also, glad to be able to access your blog again. For the last month or two I kept getting a “404” error whenever I tried to go to your blog.

        I noticed that the part of my comment regarding creating a whitelist did not quite come out the way I wrote it. Specifically, the placeholder arguments for the “database put” command got deleted — probably because they were enclosed by angle brackets. (I wrote it that way since that was the way it was done on the voip-info-org page that I referred to.)

        To clarify this here is a re-post of that part of my previous comment, but with square brackets replacing the angle brackets:

        First create a whitelist. To do that get the Asterisk Command Line prompt. See Step 6 above to see how. Then enter the following command:

        raspbx*CLI> database put [family] [key] [value]

        [family] is whitelist, [key] is CallerID number, [value] is associated name, in quotes. For example:

        raspbx*CLI> database put whitelist 3125551212 “Dr Pheelgud”

        Repeat this command for all the numbers you want in the whitelist.

  9. Garry says:

    Hi Bill,
    This looks like a great project and you’ve done a really good job of detailing the setup, but I had a question about the system in use. If there is a power outage, do all outside calls go to the phone, or do none at all make it in (and similarly, for placing calls)?

    • Bill says:

      Hi Garry,

      I run the rpi, obi, and phone on a UPS to carry them during power losses. If you don’t, then no calls would get to the phone since Asterisk and the voice router would be down. I did recently lose a voice router due to a couple of lightning strikes! The first strike took out the suppressor/protector, the second then (not so neatly) took out the obi110. The replacement obi I got had to have it’s firmware reflashed before it started working reliably (not sure what that was about).

      Best regards,


  10. Alex T says:

    Hi, just wanted to say that this is a great tutorial. I used it with a generic Raspberry Pi and the Asterisk package instead of the special Asterisk image. The only thing I had to do differently is change the path to the sound files. Telephone is fun!

  11. Alex T says:

    I just have one question. Everything is working except the caller ID. On my phone it always shows as OBITRUNK1 for calls that get through (the caller presses 1). Is there a way to see the original caller ID?


    • Bill says:

      Hi Alex,

      Since I don’t have caller ID, I’m not sure what to modify (no way to test).


      • Alex T says:

        I figured it out. You have to check the X_SpoofCallerID box on the ITSP Profile A –> SIP page. I was poking around the OBI site and ran across this. Works like a charm!

  12. Alex T says:

    Ok Bill here’s one for you. I’m not sure how intimate you are with the OBI110 and SIP but I’m trying to get a SIP phone to dial out through Asterisk and my OBI110. The idea is that the phone will dial out through the POTS line on the LINE connection to the OBI110. I have the phone working and I can get it to dial my regular home phone “extension” with the entry:
    exten => 5,1,Dial(SIP/PHONE)
    Dial “5” on the SIP phone and my home phone rings.

    However, I can’t get it to connect to the proper Trunk or whatever on the OBI110 to get to the outside line. I’ve tried lots of stuff like:
    exten => _9X.,1,Dial(SIP/${EXTEN}) _9X.,1,Dial(SIP/OBITRUNK1/${EXTEN}) <– this also dials the home phone
    The idea is you dial 9 and then that used the exten to route the call to the outside line. I just can't figure out what to use to tell the OBI110 that I want to access the outside POTS port. If you have any ideas I would be grateful!

    • J. Mirman says:

      I figured this out with a little work. The “dialing-out plan” for dialing via the Obitrunk1 over the OBi110 isn’t covered in the above article (or I completely missed it). Here’s a simple starting point for developing your plan:
      exten => _XXXXXXXXXXX,1,Dial(SIP/Obitrunk1/${EXTEN})
      The above line supports dialing out long distance 1 + 10 digits (US 1 + 10)
      You used the 9 prefex as many businesses do on their PBXs:
      exten => _9XXXXXXXXXXX,1,Dial(SIP/Obitrunk1/${EXTEN:1:11})
      Note the key differences adding the 9 prefix but using string manipulation to skip the 9 for dialing out (your analog line will complain).
      exten => _97XXXXXXXXX,1,Dial(SIP/Obitrunk1/${EXTEN:1:10})
      In my case I have local 10-digit dialing (no preceeding 1 required) . You will note that I shortened the initial pattern and decremented the length of the string so I’m still skipping the 9.
      I tested this under Fedora 23 which [currently] comes with asterisk-13.7.1-1.fc23.x86_64

      • J. Mirman says:

        Important Note: This was just for test purposes! The “dial out plan” for allowing access to local, long-distance, toll, and international calling (and 911, etc., etc.) is somthing PBX admins pull their hair out over and spend lots of time combing over to add sophistication, improve ease-of-use (user-friendliness), and security–just as a start. The test cases above provide wide-open access and you *must* understand your exposure before you implement them for production. Think rm -rf * #omg

  13. J. Mirman says:

    I’m having the exact same problem as Alex T.

    • Bill says:

      Hi J.,

      Alex mentioned:

      “I figured it out. You have to check the X_SpoofCallerID box on the ITSP Profile A –> SIP page. I was poking around the OBI site and ran across this. Works like a charm!”

      This might work for you.


  14. J. Mirman says:

    Bill, Your time and effort saved me a lot of the same with regards to understanding my OBi110. Thank you very much for this post!

  15. You should get an IP phone and use Asterisk’s voicemail facilities. Your call setup times would improve greatly. Plus you could also receive voicemails via email when they are left.

    • Bill says:

      Hi Salvatore,

      Great suggestions, thank you. I have an answering machine that I wanted to use, so that’s why it’s set-up that way.

      Best regards,


  16. Harvey Lewis says:

    Problem. I had same problem yesterday. I assumed I got it because I declined some optional updates so I reloaded the SD card and started again, but I got the same error. Here is what it says to do:

    If the web server (apache2) fails to start after the upgrade, run the commands (as user root):
    chown www-data /var/lock/apache2 ( no error from thi cmd )

    echo ServerName $HOSTNAME > /etc/apache2/conf.d/fqdn

    I put spaces before and after the >

    Here is what I got:

    root@raspbx:~# echo ServerName $HOSTNAME > /etc/apache2/conf.d/fqdn
    -bash: /etc/apache2/conf.d/fqdn: No such file or directory

    Is there some mistake obvious to you ?

    • Bill says:

      Hi Harvey,

      I don’t use a webserver with my Asterisk configuration. The directory path “/etc/apache2/conf.d” must exist in order for the fqdn file to be created. Perhaps the apache web server is not be installed, since the command appears correct.


  17. Dear Bill,

    Just wanted to drop a note to let you know the work you did here years ago is still (hopefully) making a difference in the world. My 91 year old dad has been getting scammer calls for the last few years, continuing even through when we lost my mother earlier this year.

    The scammers who claim to be from Microsoft (or even claim to be from “Windows”) saying the caller’s PC is infected and they need them to visit a site and click/install a link. Once into the person’s PC they lock the owner out and explain they need $250 to clean up the system. This has happened to my dad at least twice (yes, at least $500 payed out so far). I’ve locked down his PC so theirs no way anyone else can get on, but they still persist to call him up to 7 times a day.

    He doesn’t want to change his phone number, and his naps and peace of mind are being interrupted. I’ve also been in close contact with dad’s ISP/phone service whose been very cooperative in trying to help (they however are unable to block non-numeric caller-id’s like “ravi”).

    So this bring me to you and the work you’ve done.

    Yesterday I’ve completed step 1. And the parts should be here tomorrow.

    I’ve also read through your very details post. Thank you for such an awesome set of instructions!

    I’ve been an electrical engineer and software developer for 20+ years, am somewhat familiar with Raspberry Pi and VOIP, so I’m anticipating that I should be able to complete the project without too much trouble in spite of 4 years worth of software updates and using one of the newer PI’s….just want you to know that this (your project) could be a huge help to my dad and that makes a world of difference to his family and others who love him (I should have looked for this 2 years ago!).

    So thank you in advance, Bill.

    Sincerest wishes of happiness and success to you!


    • Bill says:

      Hi Robert,

      I’m glad it’s improving your dads quality of life; I know it sure has here.
      Good luck and thanks for the kind words!


  18. Arthur says:

    Dear Bill,

    Your fantastic instructions have kept my parents happy and unbothered for two years! However, their OBI110 seemed to go bad and they unplugged the raspberry pi to fix it, which seemed to corrupt the card.

    I’ve purchased a new one and am trying to replicate the instructions, but even though I’ve gone through the steps twice, I have the following errors:

    [2018-01-02 20:25:18] NOTICE[1182]: res_pjsip/pjsip_distributor.c:649 log_failed_request: Request ‘REGISTER’ from ” failed for ‘’ (callid: 2684647e@ – No matching endpoint found
    [2018-01-02 20:25:18] NOTICE[1182]: res_pjsip/pjsip_distributor.c:649 log_failed_request: Request ‘REGISTER’ from ” failed for ‘’ (callid: 2684647e@ – Failed to authenticate
    [2018-01-02 20:25:18] NOTICE[1182]: res_pjsip/pjsip_distributor.c:649 log_failed_request: Request ‘REGISTER’ from ” failed for ‘’ (callid: c666dafd@ – No matching endpoint found
    [2018-01-02 20:25:18] NOTICE[1182]: res_pjsip/pjsip_distributor.c:649 log_failed_request: Request ‘REGISTER’ from ” failed for ‘’ (callid: c666dafd@ – Failed to authenticate

    Do you recognize these errors at all?

    Many thanks,

    • Bill says:

      Hi Arthur,
      I had lightning take out my OBI110 and had some problems getting back up again until I flashed the unit with the “current” firmware. From the looks of things, it would appear that the password(s) are not correctly set, but that’s just a quick guess.

      I’ve had issues with power-cycling corrupting the memory cards too. Running the Pi from a UPS or small battery+charger (DIY UPS) will keep it clean. You may also consider moving to an industrial 4G card like: https://www.mouser.com/new/panasonic/panasonic-industrial-sd-cards/ (P Series) to help minimize corruption and extend operational life.

      Let me know if updating the firmware helped.


  19. Hampton says:

    Apparently, the RasPBX distribution is no longer communicating with the Obi110 (I just bought one). After spending considerable time trying to configure it, but running into problem similar to Arthur’s (ie. register or authenticate failures) I grabbed the Incredible PBX distribution and it’s now communicating with the Obi.

    Would you know how/where to implement your no-solicitors code in Incredible PBX?

    Thanks for exactly the prod I needed to get this project going.

    • Bill says:

      Hello Hampton,

      I’m sorry, but I have no experience with “Incredible PBX”. As you can see, it’s been several years since I did this project and since it works so well, I’ve just “forgotten” about it (no upgrading).. I’ll see what I can learn..

      Best regards,


  20. Hampton says:

    I was able to look back through the RasPBX images on my own. raspbx-28-01-2017.zip is now up and running.

    Thanks so much for posting your experience. You made this possible for me, a guy without experience in the world of office telephony.

    Thanks, and watch out for those nasty updates! 😉

  21. Moes says:

    Why does this “block” callers from indian microsoft suppport go away? They can easyli press 1 like a human?

    Did i miss something?

    • Bill says:

      Hi Moes,

      This project was meant to block “robo-callers”, and doesn’t require any caller-id information. As such, anyone who wants to by-pass your recorded warning about not accepting solicitations, can do so. You could automatically create a math problem, and have them enter the answer, but that may discourage your friends too 😉


Leave a Reply

Your email address will not be published. Required fields are marked *