Raspberry Pi Telephone Number Blocker

Do you get annoying calls from unwanted telephone numbers (i.e. Telemarketers, debt collector agencies, scammers, etc.)?  Do you wish there was a cheap solution which could be easily tailored to block any telephone number?  Do you like raspberry pies?  We will be looking at an implementation on how to successfully block unwanted calls, and even take our telephone number off of telemarketer’s calling lists.

The Problem: After we moved and got a new telephone number, my wife and I were getting so annoyed of unwanted telephone calls from telemarketers, scammers, and debt collectors (trying to collect debt from various individuals who do not live at our house).  It got so bad, that we were getting at least 5 phone calls from various numbers each night that we didn’t know, nor answered (not to mention the various voicemails asking for someone we do not know).  So I began to think of ways to at least decrease the amount of unwanted phone calls, since obviously the “Do Not Call List” doesn’t work with every call.

The Goal: Create a cheap, dynamic, and easily modifiable solution that automatically disconnects calls based on a blacklist (a list of phone numbers for which to block).

The Solution: Utilize a small credit-card sized embedded computer, with a telephone modem connected to it, install a Linux operating system, and tailor software (slightly modified) to successfully block a list of phone numbers or caller ID names from ringing.

Background Info: Embedded devices are everywhere these days.  You are most likely carrying around one right now.  So what is an embedded device?  It is a computer system that is created to perform specific tasks (often with realtime constraints).  Examples of embedded devices are: smartphones (or old-school cell phones), cable set-top-boxes, answering machines, home theatre systems, some refrigerators, and so much more.  Believe it or not, even the vehicle you drive contains embedded devices (sometimes dozens to control everything from starting your vehicle, controlling the A/C, to the braking system).  For years, embedded devices were so specialized that consumers didn’t have access to their own customizable embedded devices.  In recent years though, customizable embedded devices such as the Raspberry Pi (no, its not food) and the Arduino have made great strides to allow just about anyone to tinker and create their own customized embedded device.  They are cheap to buy, and (especially the Raspberry Pi) utilize very little electricity to run.  This is one of the main reasons why I chose the Raspberry Pi to fix our phone calls issue.

Needed Hardware

  • Raspberry Pi (Model B – 512 MB) – This is a credit-card sized programmable embedded device which costs $35 (for just the Raspberry Pi).  It has the following specs:
    • 700 MHz processor (ARM 1176JZF-S) – over-clocking capability for up to 1 GHz
    • 512 MB of internal memory
    • Broadcom BCM2835 SoC (System on a Chip)
    • HDMI 1080p video/audio output
    • Composite RC video output
    • 3.5 mm audio output jack
    • SD/MMC/SDIO card slot (this is where the board loads Linux from)
    • 10/100 Ethernet port (for network access–I use this to SSH into the device to perform maintenance or upgrade)
    • 5 volt power via MicroUSB cable
  • Transcend 8 GB SD card (or more memory)
  • Zoom 3095 USB Mini External Modem (this is specific, as Linux kernel drivers are already created for it, and has ability to look at caller ID and answer calls)

Needed Software

  • Raspbian Operating System (Debian-based Linux operating system, specifically created for Raspberry Pi devices)
  • NCID (Network Caller ID) Source Code – I’ve made modifications, but you could easily just install via package manager if you don’t want to make software changes: sudo apt-get install ncid

Setup / Installation

First, we need to install the Raspbian Operating System image onto the SD card.

Installing Raspbian OS

The easiest way to install the Raspbian OS onto a blank SD card, is the utilize the New Out Of Box Software (NOOBS) provided by the Raspberry Pi website. Follow instructions on there to install onto your SD Card.

Once you have setup the SD card, you will then need to connect the Raspberry Pi device up to a TV via HDMI, keyboard, mouse, and power (see image/PDF below).


At this point, you’ll want to go through the on-screen prompts, and make sure you install the Raspbian OS.  Once that is complete, you have successfully booted onto a Linux operating system via a embedded device!  Congratulations!

NCID Setup / Installation

NCID (stands for Network Caller ID) is open source software which not only has the capability to hang-up calls provided to by a blacklist, but also can send out the caller ID to computers/devices that are connected (future article about this later).  What we will be doing though, is making a slight modification to NCID so that we do not just hang-up on calls, but actually send out a “fax” signal and then hang-up.  This fax signal tells the computer which is calling you (a computer actually initiates calls for telemarketers and even debt collectors) that this phone number is for a fax machine.  In most cases, this means the business will take your phone number off their list to call, since they think it is a fax machine!  This is great, since the number of calls will soon die down after repeated fax replies.

Here are the steps we need to perform:

  1. Download the source code for NCID from SourceForge.  To do this on the Raspberry Pi:
    1. Open up a Terminal session
    2. Create a source folder directory:
      mkdir ~/Documents/source/
    3. Change to that directory:
      cd ~/Documents/source
    4. Download the source via wget
      wget http://downloads.sourceforge.net/ncid/ncid-0.86.1-src.tar.gz
  2. Edit the source so that a “fax signal” is sent to those on the blacklist and then call is disconnected.
    1. Un-tar compressed file: 
      tar -zxvf ncid-0.86.1-src.tar.gz
    2. Change directories into the new NCID directory: 
      cd ncid/server
    3. Install an editor like gedit if you don’t already have one: 
      sudo apt-get install gedit
    4. Open the nciddhangup.c file via gedit
      gedit nciddhangup.c
    5. In the hangupCall() function, edit the following lines (should be around line 213):
      /*Send AT to get modem OK after switch to raw mode*/
      (void) initModem("AT", HANGUPTRY);
      /* Pick up the call */
      ret = initModem(PICKUP, HANGUPTRY);

      To look like:

      /*Send AT to get modem OK after switch to raw mode*/
      (void) initModem("AT+FCLASS=1.0", HANGUPTRY);
      /* Pick up the call */
      ret = initModem("AT A", HANGUPTRY);
    6. Save file, and exit gedit
  3. Compile and install the source code.
    1. Install necessary packages to be able to compile NCID
      sudo apt-get install libpcap0.8*
    2. Build NCID
      sudo make ubuntu-install
  4. Edit NCID configurations to work properly with your USB modem, and enable hangup.
    1. Configure NCID for the Raspberry Pi (make sure you have the USB modem connected to Raspberry Pi):
      gedit /etc/ncid/ncidd.conf
    2. Make the following changes to the configuration file: 
        set ignore1 = 1
        set hangup = 1
        set ttyport = /dev/ttyACM0
        set lockfile = /var/lock/LCK..ttyACM0
    3. Open ncidd.alias in gedit
      gedit /etc/ncid/ncidd.alias
    4. Comment out the alias for our POTS line by putting a # pound sign next to it (POTS stands for Plain Old Telephone Service): 
      #alias LINE - = POTS
    5. Save and close gedit
  5. Set the Raspbian OS to automatically startup NCID daemon.
    1. Setup NCID to autostart on boot-up of Raspberry Pi: 
      sudo update-rc.d ncidd defaults
    2. Restart NCID by running: 
      sudo invoke-rc.d ncidd restart
  6. To edit the blacklist to add phone numbers for which you want to block, gedit the following:
    gedit /etc/ncid/ncidd.blacklist
    1. To add a full phone number, do something like this (this adds the anonymous phone number):
    2. To add a caller ID display name, simply do something like this: 
    3. Save and quit gedit
    4. Further documentation on adding numbers/caller IDs to blacklist is located at the top of the blacklist file


After completing the above, you should be able to successfully block any (or all) phone numbers you choose (a whitelist is also possible, if you only want to allow certain numbers).  I have personally had this setup for about 4 months now, and am happy to report a dramatic decrease in the number of unwanted calls (most days we don’t even receive any unwanted callers).

The Raspberry Pi device is a very versatile piece of hardware.  A great way to learn both hardware and software (specifically, embedded software development), and better understand the integration between the two.  It opens up so many opportunities for many other projects (like adding a camera to the Raspberry Pi and performing time lapse photography; connecting it to a garage door opener to allow your smartphone to remotely open a garage door; home automation tasks; and many other fun projects).  Check out Raspberry Pi’s Google+ page for lots of other projects.

This entry was posted in Hardware, Software and tagged , , , , . Bookmark the permalink.