Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

How to Make and Take IoT VoIP Calls via Super SIM


Super SIM provides any modem-equipped device with worldwide data connectivity. Once in place, this data channel can be used to send and receive any kind of information — and that includes voice calls.

But while voice apps are ten a penny in mobile operating system app stores, making it easy to try out Super SIM mediated voice-over-data on a phone, how might voice functionality be enabled on an IoT device?

The Raspberry Pi 4 with a cellular modem attached.

Twilio's Programmable Voice product supports the Session Initiation Protocol (SIP) for starting, maintaining, and ending interactive sessions over IP networks, in particular voice communications sessions. Programmable Voice lets you set up a SIP Domain, which is a unique point of presence that SIP clients — say, a VoIP softphone running on a Super SIM-enabled IoT device — can connect to and call other SIP clients, and phone numbers on public switched telephone networks (PSTNs).

The result: any cellular IoT device fitted with Super SIM and suitable audio IO can participate in voice calls with similar devices and even landlines and mobiles via Twilio and the Internet. Calling is two-way: calls can be made by an IoT device and received by it too.

By way of demonstration, this guide shows you how to set up a Programmable Voice SIP Domain, set up an IoT client device, and connect them. You'll need a Twilio phone number as an entry point for inbound calls and as an outgoing Caller ID. We also make use of another Twilio product, Functions, to provide a basic admin dashboard and allow incoming calls to be routed to specific devices. A Raspberry Pi single-board computer(link takes you to an external page) stands in as the IoT device.


1. Prepare the Pi

1-prepare-the-pi page anchor

First, you'll need a Raspberry Pi that has been set up and is ready to use. The Raspberry Pi Foundation has a great guide to help you(link takes you to an external page) if you've just unboxed your first Pi.

You'll also need a cellular module board — we'll use the same Waveshare SIM7600X 4G Hat(link takes you to an external page) that's used in our main Super SIM tutorial. It will need to be fitted with a configured Super SIM.

We have a detailed guide to bringing the Pi and the modem together. You should jump to it now and come back here when you've completed it. It will show you how to put in place the services you need to connect to the Internet using Super SIM. If you wish, you can skip Step 3, "Attach to a cellular network", to save a little time.

The Waveshare SIM7600X 4G Hat.

Finally, you'll need a USB audio adapter. The Raspberry Pi has a 3.5mm AV jack which can output to headphones, but it has no audio in. To remedy that, fit a USB audio IO adapter like this one(link takes you to an external page) and plug a headset into it. This is just one USB audio adapter — there are many, many similar ones available.


2. Install and configure the Twilio CLI tool

2-install-and-configure-the-twilio-cli-tool page anchor

We'll interact with Twilio using the twilio command line tool. Unfortunately, support for twilio and the Serverless Toolkit plugin you'll use alongside it is not optimal on the Pi, so steps 2 through 4 need to be done on your primary computer. You may already have the Twilio CLI installed — if so, you can jump straight to Step 3.

LinuxmacOSWindows

Install twilio on distributions such as Debian, Ubuntu, Linux Mint, and more with apt:


_10
wget -qO- https://twilio-cli-prod.s3.amazonaws.com/twilio_pub.asc \
_10
| sudo apt-key add -
_10
sudo touch /etc/apt/sources.list.d/twilio.list
_10
echo 'deb https://twilio-cli-prod.s3.amazonaws.com/apt/ /' \
_10
| sudo tee /etc/apt/sources.list.d/twilio.list
_10
sudo apt update && sudo apt install -y twilio

Now you're ready to set twilio up with:


_10
twilio login

You'll be asked to name a profile — make sure you note the name and then run:


_10
twilio profiles:use PROFILE_ID


3. Install the Serverless Toolkit

3-install-the-serverless-toolkit page anchor

Twilio's Serverless Toolkit is a twilio plugin that considerably simplifies the process of initializing, uploading, and starting a Twilio Functions environment. It uses the core Functions API as exposed by twilio and adds convenient bulk-upload functionality that will save you a lot of set up time.

Install the plugin with:


_10
twilio plugins:install @twilio-labs/plugin-serverless


4. Set up Twilio Functions

4-set-up-twilio-functions page anchor

Now grab the source code files that underpin the Twilio-mediated SIP service that your IoT device will use to host calls. We have a GitHub repo that contains all the files you need(link takes you to an external page) and which the twilio tool will use to set up your service.

First, clone the repo:


_10
git clone https://github.com/korewireless/super-sim-raspberry-pi-voip-demo.git
_10
cd super-sim-raspberry-pi-voip-demo

Optionally, you can edit the repo's .env file, which contains your application's admin and SIP client passwords. If you'd rather not use the default passwords, change these now.

Now upload and deploy the code:


_10
twilio serverless:deploy


5. Initialize the SIP service

5-initialize-the-sip-service page anchor

The last command you ran will upload and deploy your Twilio Functions environment's functions and assets, and activate the environment. Look at the command's output in the terminal: there will be an /admin/index.html URL listed under Assets:. Copy the full URL and paste into into a browser window:

Initialize the SIP service with Twilio Functions.

When the page loads, you'll first be asked to log in — use the password from the repo's .env file — and then be invited to initialize the environment:

Initialize the backend app on the admin page.

Click the Initialize... button to do so. The underlying code will set up your SIP Domain and an associated Credential List, which you can take a look at later in the Twilio Console under Voice > Credential lists(link takes you to an external page). It will also configure the voice and fax functionality of your Twilio phone number: it will be set to accept voice calls and to route them to devices via the uploaded functions. When the service is configured, the admin page will look something like this:

Initialize the backend app on the admin page.
(warning)

Warning

If you have multiple Twilio phone numbers available, the admin page will inform you of this and provide a list of numbers from which you can select the one you want to use for incoming calls.

Scroll up the admin page and click the View your running application link to jump to the list of available SIP clients. These are mock users and they're defined in the repo file assets/extensions.private.js. It also includes the extension numbers at which they can be reached. Feel free to make changes, but make sure you re-run twilio serverless:deploy every time you do so.

View SIP clients on the main page.

Pick one of the users as your Raspberry Pi SIP account and make a note of the SIP Registration Domain. Alternatively, note the page's address, enter that into the browser on the Pi when you jump across to it in the next step, and then copy the domain directly.


6. Install a SIP softphone on the Pi

6-install-a-sip-softphone-on-the-pi page anchor

A real IoT application would have to incorporate its own code for communicating via SIP and handling the audio IO. For this demo, however, we're using a softphone called Jami(link takes you to an external page). It's open source, free, and runs on the Raspberry Pi.

  1. Switch over to the Raspberry Pi. If it hasn't already booted to the desktop, just enter startx at the command line.
  2. Select the Raspberry > Accessories > Terminal menu entry.
  3. Enter the following lines:


    _10
    sudo apt install gnupg dirmngr \
    _10
    ca-certificates curl --no-install-recommends
    _10
    curl -s https://dl.jami.net/public-key.gpg \
    _10
    | sudo tee /usr/share/keyrings/jami-archive-keyring.gpg \
    _10
    > /dev/null
    _10
    sudo sh -c "echo 'deb [signed-by=/usr/share/keyrings/jami-archive-keyring.gpg] \
    _10
    https://dl.jami.net/nightly/debian_11/ jami main' > \
    _10
    /etc/apt/sources.list.d/jami.list"
    _10
    sudo apt-get update && sudo apt-get install -y jami

  4. Launch Jami by selecting the Raspberry > Internet > Jami menu entry.
  5. On the Welcome to Jami page that appears, click on Advanced features at the bottom:

    Super SIM IoT VoIP — Jami setup — new account.
  6. Click the Add a SIP account button:

    Super SIM IoT VoIP — Jami setup — advanced features.
  7. Enter the account name you selected earlier, in Step 5 — or pick one of the names from your IoT VoIP Demo browser window — into the Jami Username field.
  8. Enter the SIP Registered Domain from Step 5 into the Jami Server field.
  9. Enter ThisIs1Password! — or your own password if you changed it earlier — into the Jami Password field:

    Super SIM IoT VoIP — Jami setup — sip account setup.
  10. Click the Create SIP Account button.
  11. Back at the main Jami UI, click the gearwheel icon to the left of your SIP account name, then click the Media button.
  12. Set your Ringtone, Output and Input Device to your USB audio adapter. This may not be listed as it appears in the screenshot below, so just make sure you don't select Default , HDMI or AV Jack :

    Super SIM IoT VoIP — Jami use — set up audio.
  13. Click the < to the left of your SIP account name to go back to the main screen.

  1. In Jami, enter your own cellphone number into the Find or start a conversation field in the left-hand column:

    In Jami, enter a phone number in the find field.
  2. Click on the phone handset icon at the top right to call the number:

    Click on the phone handset icon at the top right to call the number.
  3. Take the call on your phone!

  1. On your cellphone, dial the number back.
  2. You'll hear a request for the extension of the party you're trying to reach. Key in 100 on your phone keypad.
  3. Talk!

You've built yourself a working demo IoT VoIP system that connects a softphone running on a Raspberry Pi computer, via a Twilio Programmable Voice SIP Domain and a cloud-side application constructed with Twilio Functions, to a cellphone for the purpose of making and taking voice calls.

The crucial point to recall, however, is that it is a demo, not a full application. But it neatly shows how you might architect such an application — imagine an industrial IoT unit in the field capable of hosting back-to-base support calls — and of what it would be capable.

Now it's over to you. We can't wait to see what you build.


Rate this page: