Gamma Spectroscopy – Building Your (lead) Castle

One of the challenges of doing any kind of quantitative measurement is achieving the best possible signal to noise ratio.   When performing gamma spectroscopy, especially with very low levels of radiation (signal),  background radiation (noise) can easily mask/hide/swamp the desired signal.   Of course there are many sophisticated noise-filtering algorithms, but following the KISS & GIGO principles,  reducing background radiation (noise floor) is a choice first-step.   Simply put, we wrap the detector and sample in a radiation shield to minimize external influence.    This shielding is commonly referred to as a “castle“.

To build the lead castle, I bought 25 rough 99.9% lead ingots from; these are available for a little over $2/lb, including shipping.  The downside is a fair amount of non-uniformity in the ingots:

Raw Ingots

Raw Ingots

Quite a bit of re-forging (straightening/flattening), cutting, and filing was necessary to get them into useable shape where the sides overlap when placed next to each other with no gaps.

After the ingots were refashioned, I cleaned them with Acetone and spray-coated them with Rust-Oleum epoxy appliance paint.   If you think you might want to eventually melt the lead down for other purposes, you may forgo the painting and simply wrap the ingots in tin-foil so they can be handled without gloves (lead safety).

Reshaped & painted Ingots

Reshaped & painted Ingots

If I had it to-do over again, I would go with well-formed, clean lead bricks.  These cost a bit more, but I now consider the cost well worth-it 😉   Another alternative would be to use fine lead-shot (#12) poured into the void between concentric containers.   Wall thickness would then be easy to experiment with since the shot can be poured in & out to give more or less shielding.

I couldn’t find a source of #12 lead shot, but did investigate making my own; here’s a video of a device to make shot.   The size of the shot is determined by the size of the dripper holes.

To test the effectiveness of the castle at a gross level, I put a GK-B5 Geiger counter, with the data logging shield, into the open castle:

GK-B5 in open castle

GK-B5 with SBM-20 GM tube in open castle

The results were averaged over a couple of hours, with a counts/minute (CPM) of 46.43.  The logging rig was then fully enclosed:

Enclosed Geiger Counter

Enclosed Geiger Counter

Counts were then logged for another two hours, yielding an average of 22.57 CPM.   The results showed the castle cuts down the background radiation by a little more than half.  Admittedly, at my altitude (6500 feet), radiation fluctuations are significant over the course of a day (typically 10-15 CPM).

The real test is using a scintillation detector.   I have a Scionix 38B57 interfaced to a Gamma Spectacular GS-1100-PRO running at 650 volts; without the castle shielding:

Scionix detector

Scionix detector

The Theremino software (running under wine in Ubuntu) showed an average of 71.1 counts/second (CPS), or 4266 CPM.  As can be seen, the scintillation detector is much more sensitive than a Geiger-Mueller tube:

Theremino Software

Theremino Software

Enclosing the detector Yielded an average of 7.5 counts/second or 450 CPM; a reduction in background radiation (noise) by almost an order of magnitude.   I’d call this experiment a success.

This will allow measurements to be taken over a much longer period of time, making low-level measurements more accurate.

Here are some notes for installing Theremino under Linux.

Posted in Radiation | 1 Comment

Get on the map! An “Internet of Things” Geiger counter for $100

Do you live near a nuclear facility?   Are you concerned about contamination from Fukushima?  Would you like to chart fluctuations in cosmic rays, or track the solar winds?

This post covers building and configuring a net-connected Geiger counter that takes advantage of free on-line charting and mapping services like or Xively directly, with no intermediate computer or software required.

The preliminaries;  you must be able to assemble and solder standard through-hole components; no surface mount devices are used in the making of the kits.  Also, familiarity is required with the use of the Arduino development environment for configuring user-specific parameters and compiling/downloading sketches with a TTL (5V) compatible FTDI cable.  Arduino IDE version 1.05 is known to work well at the time of this post.

There are two ATMEL (Arduino) chips in this project; each on a separate board.   One for counting pulses from the GM tube & performing “housekeeping”, with the other driving the Internet interface.  They communicate with each other over the 6-pin FTDI (serial) interface connectors.  The two kits (and display) can be purchased from the DIYGeigerCounter site.  You’ll need a GK-B5 ($49), display ($5.50), and a GKNet kit ($18).   From Ebay (or your favourite source), an SBM-20 GM tube ($20), and either a WIZNet W5100 ($25) or an ENC28J60 Ethernet module ($5).  See the GKNet page for capabilities & limitations of each module.

Here’s a picture of my setup (no enclosure to inhibit radiation 😉 )

Net connected Geiger counter

Net connected Geiger counter

I hacked an old USB cable for the 5Volts.  The kit doesn’t need a display to operate, and I’ve also disabled the speaker (removed the click/tone jumper) since it’s next to my desk.  Pointing your browser to,  if you click on the marker over Colorado Springs, CO, then on the wrbishop link in the popup – daily, weekly, monthly, and quarterly graph displays will be displayed (DIYGeigerCounter headquarters (BroHogan) is the marker over Denver).   This is a “no brainer” way to track radiation levels in your area.  It also lets you know when your ISP fails, and for how long — the radiation data will “flatline”.   Notice I removed the IR sensor; when I configured other boards, the IR spill from the remote tended to effect this one too (oops, I forgot to mention, you’ll want one of these TV remotes too – $14).   John just sent me a keychain remote update as an alternative.

I found John’s (DIYGeigerCounter) instructions very clear with lots of pictures and helpful tips accumulated over the years.   His code is well commented, and easy to understand (assuming a basic grasp of the “C” language).   Don’t worry, you won’t need to learn to program.

First, build the GK-B5, and get it working (this is where the display helps).  Once that is accomplished, build the GKNet interface, and plop-on the network module of your choice. Personally, I find the WIZNet W5100 to be very reliable, having run it 24/7 for months.  I’m currently beginning to experiment with a WIZ550io module; I’ll keep folks updated.

Click the “register” link on to establish your account information (username, password, email, …). Once Dan acknowledges the information, your username & password need to be inserted & compiled into the GKNet code, then downloaded into the board (same with Xively, if you’re sending data to that site as-well).

Now, to program the GKNet card with your credentials, you’ll need to swap the transmit and receive data lines to the board from the FTDI cable.  I put together a “crossover” patch cable that sits between the programming cable and the GKNet FTDI interface:

GKNet Interface

GKNet Interface with a twist

After downloading the GKnet_Radmon_Xively_v3_X.ino sketch (where X is the “current version”),  open it in the IDE or your favourite text editor.    About 50 lines or so down, is an area labelled “User setup #defines”.    This is where you’ll need to make changes.  Select which site(s) to send the data to (SEND_TO_RADMON, SEND_TO_XIVELY) by setting the appropriate define to “true” or “false” (yes or no).    If sending to, change the “????” in the UserName[] and PassWord[] variables to reflect your values.  If sending to, set the FEED_ID and KEY[] values.   Then set the POST_PERIOD as mentioned (how often to send counts).  Finally, if you need to statically set the IP address (DHCP is the default), set STATIC_IP to “true”, and set “ip” and “mydns” (more detailed information is contained in the GKnetBuildInstructions).

At this point, save the sketch, compile and download it into the GKNet board.  An easy way to test the network interface is to open the console in the Arduino IDE (9600 baud), and pretend you’re a GK-B5 by sending lines of the form “counts, dose, voltage” (22,3,5.2).  The yellow LED should flash each time you send a line.  At the next POST_PERIOD interval, the data should be sent over the Internet (green LED lights up), and you can observe it in your browser.

Finally, power-off, unplug the programming cable from the GKNet board,  plug the GKNet board into the GK-B5, plug an Ethernet cable into the GKNet board, power-on, and start charting!

Posted in Radiation | Leave a comment

DIY Geiger Counter Compact GK-B5 Packaging

You’ve built the kit, you have your GM tube, now how do you get your Geiger counter into the field and have some fun?   Obviously, you have to package it.   From the infinity of possibilities, where do you turn?  Do you want the GM tube (detector) in the enclosure, or remotely located?  How much battery life do you think you’ll need.  What features of the kit do you want to be front-panel configurable?   The possibilities can be overwhelming.

This post covers a simple, yet compact packaging of the GK-B5 kit by DIYGeigerCounters.  The display and electronics are mounted on the front-panel with the only relocated component being the speaker (also mounted on the front panel).   There is room in the 5″ x 2.5″ x 1.5″ project box for an SBM-20 GM tube, but I’ve opted for interchangeable remote sensors attached via BNC connection.

There are a couple of modifications I performed during the build that may be interesting.   The first, is the replacement of the 78L05 regular with Pololu up/down voltage regulator (also available on the DIYGeigerCounter website).   This allows the kit to run from a single-cell (3.7V) LiPo.   Instead of mounting the Pololu regulator on the bottom of the board, I mounted it on the top, vertically:


Boost VREG

The regulator is to the right of the green input power screw terminals, and is mounted using a 3-pin 90-degree header.   A notch in the green power connector had to be made, but the screw terminals could be omitted all-together by soldering the power wires directly to the board.  Also notice the two-pin female header the LED is plugged into.   This allows the electronics to be unplugged from the display, which is hot-glued to the front panel (more later).   On the lower left is a JST charging connector for the LiPo cell, which I salvaged from an aircraft “accident”.   NOTE:  When using LiPo’s, it’s best to get one that has under-voltage protection circuitry built-in.   This will keep the cell from being permanently damaged if discharge is attempted below 3.2 volts or so.

Looking at the back side of the front panel, the display cut-out was made with a nibbling tool, and filed into final shape. The LED, speaker, and IR sensor are glued to the panel, with the power switch on the right:

Rear of front panel

Rear of front panel

Now, the display is hot-glued to the front panel:

display mounted

Display mounted

The electronics are then plugged into the display board, with the LED & IR sensor pins plugging into their respective sockets on the board.    A couple of wires are run from the electronics board to the speaker.  The power & detector wiring is shown installed.  There is still room on the front panel for more switches to control operational parameters of the GK-B5.  I didn’t quite get the display in the correct position (too far left), so I had to trim a bit off the circuit board near the power switch  (measure 2x, cut 1x):

Electronics on the back of the display

Electronics on the back of the display

The LiPo is affixed to the bottom of the project box with double-sided adhesive, and a piece of DU-BRO 1/2″ foam is sandwiched between the electronics and the battery to keep the electronics firmly pressed against the display.    Adding a little contact paper to the aluminium front gives a nicer finish.

And that, as they say, is that.  If I had it to-do over again, I’d put the contact paper on BEFORE mounting all the components.   The completed detector & electronics fits together thusly with a piece of RG-59U (75 ohm) coaxial cable and BNC connectors:

Electronics & detector

Electronics & detector

John has several good links to articles on his website.

Posted in Radiation | Leave a comment

LND 7317 – Alpha, Beta, and Gamma Radiation Detector

This post describes how to build a versatile A/B/G ionizing radiation detector for about $200 using the LND 7317 detector tube.

Most Geiger counters are able to detect Beta & Gamma radiation, and perhaps X-rays; these are the more energetic types of ionizing radiation.  However, Alpha radiation is the most frequent source of health problems, usually by inhalation in the form of radon gas, and is not easily detected.   There are other sources of alpha particles that are more exotic, but still hazardous when ingested or inhaled.   Uranium & polonium in granite counter-tops is a common environmental source of Alpha radiation.  Detection of radiation in the environment and food-chain is of increasing importance to health and safety.

The key element to detecting Alpha particles is the sensor, or GM Tube.  Only sensors with a radiation transparent “window” that allows the Alpha particles to pass-through can be used.   This window is usually made of mica.   The LND corporation LND-7317 is one such GM tube, and costs about $130.    The tube is very sensitive, and also detects Beta & Gamma radiation.


LND-7317 in box

I used “Atomic Dave’smounting bracket & installation kit for attaching the LND-7317 ($12.)   Read the information in his auction post to acquaint yourself with the issues in dealing with this GM tube.

LM-7317 Enclosure bottom

LM-7317 Enclosure bottom

To cut the hole in the case, I used a Harbor Freight #69063 circle cutter.   Be sure to have the enclosure well secured before cutting.

Circle Cutter

Circle Cutter

I’m using a Pelican case model 1040 to transport the sensor in a pressure-stabilized fashion.   A couple of pieces of DU-BRO 513 1/4″ R/C foam cradles the completed detector snugly:

Pelican Case

Pelican Case

The rapid change in pressure from the careless slam of a car door could rupture the thin mica membrane (it’s almost 1.5″ in diameter).  LND mails the sensors in a small sealed “coffee can”.  This isn’t an issue for GM tubes with a small or no mica window.  Be careful if you live at a high altitude (see Atomic Dave’s blurb).

LND Packaging

LND-7317 A/B/G sensor packaging

The sensor must then be coupled to a high-voltage power supply and detector hardware.  DIYGeigerCounter makes “Arduino“-based kits that can be directly wired to the LND-7317 for about $55 (plus enclosure, battery).  These kits support many other GM tubes as-well (the SBM-20 is one of my favourites).  I’ve built several of the kits of different versions & options.  One of them runs 24/7 “internet of things” connected to (Colorado Springs, Colorado, USA) using the GKNet module.

Be aware, there are no “safe” limits to ionizing radiation; merely exposures, below which the effects are uncertain.   Governments set “safe” limits, but recently have begun to raise these limits arbitrarily in response to environmental disasters.  Do your own research and become informed.

Both David @ Atomic Dave’s, and John @ DIYGeigerCounter are great guys, and very helpful.   I don’t hesitate for a moment to recommend doing business with either of them.

Posted in Radiation | 1 Comment

Stopping train wrecks for only $100

In the last few months many people have been killed, and many more permanently scarred in easily preventable train wrecks.  These wrecks were the direct result of inattention, loss of focus, or the driver “nodding off”.

For about $100 in hardware, and some software, an early warning alert system
could be created to notify drivers that their speed is excessive.

Using a $30 GPS sensor, a $40 Raspberry Pi computer, simple waypoint tracking
software, along with an amplifier, speaker, and recorded voice warnings,
(at least) these two wrecks could have been prevented:

New York train crash driver “lost focus” before crash

Driver in Spain train crash charged with negligent homicide

The algorithm could be something as simple as:

Waypoints are stored in the Pi at positions along the path of the train.  Each waypoint contains the GPS coordinates, the (max) speed at which the train should be travelling, and the time at which the waypoint was reached. Waypoints are placed such that subtracting the coordinates of successive waypoints yields distance; divided by time difference gives velocity. This velocity is then compared to the stored max speed, and an alert triggered if the train is going too fast.   Of course, the full application is more complicated, but you get the idea.

Waypoints can be updated by simply swapping out the Pi’s SD card to accommodate for path changes and maintenance issues (among other ways).

In an era where parents are putting GPS trackers on their children, why do we stand-by and allow people to be slaughtered in easily preventable accidents?   Has the price on life fallen so low?   Or is it that we are simply not thinking that rail transportation is a mission-critical application?

Of course, then there are other human factors that play into this. The driver can start to trust more on the technology, and “nap” even more, believing they can get away with it; not recognizing that technology is fallible.

I’m not advocating replacement of the “human in the loop”, but simply making their position more reliable.    After all, they want to get home to their families as much as anyone.

We can solve these problems.   Let’s do it!

Posted in Information Technology | Leave a comment

Supercomputing 2013

As a CUDA developer, Nvidia was nice enough to provide an exhibit pass at Supercomputing 2013 for attending a session at their booth last week. Their new K40 GPU accelerator is quite the chunk of silicon with almost 3000 GPU cores and 12GB of on-board GDDR5 memory.

With ~400 exhibitors, it took over 6 hours just to walk the floor (wearing a new pair hushpuppies, which turned out to be quite comfortable).   Fortunately many vendors had supplies of refreshing beverages (and the usual swag).   Vendors were from all points of the world with many universities showing off their research work and tools (many open-source).  As far as the computing technologies were concerned, things seemed mostly incremental.  Many vendors were showing off FPGA accelerators, and software to help manage algorithms development.   There was also a lot of focus on networking/networks and being able to manage & report on them.

A couple of amusing/entertaining exhibits were the (empty) NSA booth:

Supercomputing 2013 NSA Booth

Supercomputing 2013 NSA Booth

Were they watching me while I watched them??

And the Lego Turing machine (RUBens):

Supercomputing 2013 Lego Turing Machine

Supercomputing 2013 Lego Turing Machine

Open-Source had prominent positions around the floor; FreeNAS (ZFS), OpenSHMEM, OpenMP, OpenACC, even a booth for LinuxFest Northwest 2014.

This year was the silver anniversary of Supercomputing, and there were special exhibits covering the last 25+ years of computing.

Posted in Technology | Leave a comment

Transmitting Magnetic Fields – That’s Amazing!

Physicists have figured out how to transmit magnetic fields via a “hose”.  Of course, it’s not your garden-variety hose, but none-the-less it’s a conduit; one that carries magnetic, not electrical charge (though it might do that too).  It’s a bit leaky,  it only works with superconducting materials (very cold), and it isn’t very long (7cm); but it’s a start.
It begs many questions, can magnetic fields be circulated indefinitely like electrical current?  Can multiple magnetic hoses be combined to increase field strength?    Can the magnetic fields be focussed and sensed to detect material defects?   Could an MRI/PET scan “helmet” be created instead of putting someone inside a huge machine.

Could magnetic fields be directed to produce ultra-efficient motors?  What types of directed energy devices will become possible?  What advances in material science will be enabled when we can easily manipulate molecular alignments?

Will we be able to create malleable fields to contain and direct plasmas for fusion energy and creating new, pure materials?   A possible application could be plasma separation of elements;  vaporize sea water, and use the directed magnetic fields to extract precious metals (without messy screens), and in the process create purified water.  How many frogs can we levitate with magnetic hoses?

It seems to me to be a technological advance similar to the LASER of the 60’s.   A fundamental new way to harness energies we are familiar with, but allowing us to apply them in new ways.   We can now only begin to think of ways to use this tool.

Posted in Science | 1 Comment

Install your own open source private cloud with ownCloud

I'm somewhere in that cloud!

I live somewhere in that cloud!

Do you need cloud storage under your control?   Concerned about cloud providers breaking promises, selling you out, losing your data, closing up shop, cancelling your account, or the feds taking their computers along with your data? Try ownCloud; it provides simple (single machine+) private cloud storage and access with minimal hassle.   OwnCloud runs on your computers, under Windows, Mac, or Linux.  It supports several services, including Calendar, Contacts, mobile & desktop sync, version control, and much more.   Commercial support is also available.

To give it a spin and see if it’s to your taste, just go-to the ownCloud site, and press “Try it!” in the upper right hand of the page.  If you like it, just press “Install“, and the site will lead you through installing both server & client.   Alternately, you can use one of many companies providing hosted currently hosts free accounts.  Best of all, it’s open-source, and under your control.

I’ve found documentation a little tricky to locate on their site (there’s more than what meets the eye), but google has it well indexed.  I also posted several questions to their chat room (#owncloud-dev on, but never received a response.  The support forum is probably a better way to communicate.   Check-out and; there’s complementary information on both.

Once you have the server up, and have logged-in, administrative functions can be accessed via the pulldown menu “under” your user-name (upper right).  This lets you verify & administer your ownCloud server.   The next step is to install a “sync” client on the same, or other machine.    Many users can be supported on a single server.

When the sync-client is first run, it will ask how to access your ownCloud account (host name, user name, and password).    If you want encrypted transfers, be sure your ownCloud host allows connection with SSL (https://….) for best security.    Moving files into the sync directory on your desktop computer will cause them to appear in the sync directory on your ownCloud server.   Likewise, if you remove a file in the server directory, it will be removed from your desktop directory (bi-directional sync).   The underlying program doing all this is “csync“; another open-source application.  Anyway, be sure to read the user documentation which also discusses mobile sync applications.

There are many applications and features, so take your time and get to know them (or create your own).   Hit the forum for general information, answers, and FAQ.

If you’ve installed ownCloud on your home computer, and would like to be able to access it from the great-out-of-doors (or just the cafe across town), you’ll need a DNS service that
tracks changes to your home IP address (which are usually dynamic) from your ISP.

There are several providers, of which is one, providing dynamic DNS support by having you install a program on your computer that tells them when your IP address changes.  The new IP address is then propagated across the Internet DNS servers, so others can know “where” to find your computer.  This service is free for a single sub-domain, which you can create from a limited pool of domains.   I used their free service for whole week before they sent me a service-upgrade coupon for $5 off their $15/year service.  This allowed a much more generous selection of domains, up to 25 names, MX (mail) records, and more.   The names look something like, where “xxx” is the part you specify, and is the domain (many to choose from).   The free service requires you to acknowledge you’re still using it, every 30 days.

If you are behind a firewall, port 80 (the web, or HTTP port), or port 443 (secure HTTP, HTTPS) will have to be opened to allow outside computers to connect.   Then you can access your cloud from any browser.  It’s probably a good idea to close these ports on your firewall when you don’t need outside access, to keep the hackers at-bay.  If your router/firewall uses NAT, then you’ll have a bit more configuring to-do.

Of course, there are many other Cl0ud software providers, but I think openCloud has done a great job of making the personal cloud accessible, and in your control.

Posted in Information Technology | Leave a comment

MFJ-492X How-To Reset on Fail

The other day when I tried to power-up my MFJ-492X memory keyer, all I got was a short, low frequency “bzzz”.    The lights down the left side of the front panel cycled as normal, but it wouldn’t generate any tones.

In the process of tracking down any power issues (including the internal 9V battery), I discovered the 3V Lithium battery (CR2430) had gone flat (0.0V).  After replacing it (I had stuck a spare to the top inside of the box), at power-up, the unit would only give a long (4-5 second) “bzzzt”.   Trying the (factory) reset procedure in the manual (holding the menu button down while powering-up) made no difference.

Going through the “usual” suspects, re-seating all the chips & connectors, didn’t work either.  So I fired off a quick email to MFJ, and within hours, the answer appeared:

Hold down all 6 buttons while turning the power on (a bit tricky).

At this point the sweet “dash-dash-dash dash-dot” (ON) enunciated clearly, and things have been fine ever since.

Kudos to MFJ for their customer support; the unit is only 20+ years old 😉

Posted in Amateur Radio | 3 Comments

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: “”, 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:, 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 (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 (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.

Posted in Telecom | 55 Comments