Introduction: Call My Arduino

How to enable phone calls to your Arduino, using Twilio and

Twilio is a Web service that turns everything into a phone. It's a REST API for telephony, hosted in the cloud. In this case, Twilio asks the Arduino for a new voice.xml file whenever someone calls the Arduino's predefined phone number. The content of the response is read out to the caller by Alice, a voice of Twilio's text to speech engine. enables Web access to embedded devices behind a firewall, NAT or a mobile network router. Here it enables Twilio to access the voice.xml file on the Arduino, which is located in a local network and therefore does not have its own public IP address (disclosure: I'm a founder of Yaler).

This demo uses a temperature sensor, but any other sensor would do as well. A real world product example would be the Canary (now Birdi) smoke detector that lets concerned home owners call it to ask wether the battery is still fine.

On a more abstract level, this Instructable tries to show how, in an open Internet of Things, modular cloud services can be freely combined to build novel, simple and reliable solutions. HTTP and Webhooks FTW! But let's get started...

(Here's a video explaining this project from IoTLive, part of IoTDay 2014)


- Arduino Uno (e.g.
- USB Cable Standard A-B (e.g.
- Arduino Ethernet Shield (e.g.
- Ethernet cable (e.g.
- Analog temperature sensor (e.g.
- Breadboarding wire bundle (e.g.
- Breadboard (e.g.

Step 1: Wiring the Sensor

(Image by, licensed under CC BY-SA)

Add the Ethernet shield to the Arduino and connect the temperature sensor as shown. For details about temperature sensing with the TMP36 sensor, see e.g.

In case you want to add other (digital) sensors keep in mind that some pins are used by the Ethernet shield.

Step 2: Installing the Yaler Library

Follow the three steps for Installing the library at

If you have not already done so, sign up at for a free trial account and write down the relay domain (the secret key is not needed).

Step 3: Programming the Arduino

Download the TwilioYalerWebService Arduino source code

Open the Arduino code

The program implements a very simple Web server that listens for incoming HTTP requests. Once a request comes in, the program responds with an XML document. The server does not care wether the URL path is / or /voice.xml.

Change the MAC address

Make sure the MAC address in the Arduino code is unique. This is especially important if there are several Arduinos in the same local network. A simple way to get a (hopefully) unique address is to look up your computer's MAC and then add 1 to the last digit.

Enter your relay domain

Instead of creating a local server with EthernetServer server(80); we create one that is accessible via the Yaler relay, in the following line:

YalerEthernetServer server("", 80, "RELAY_DOMAIN");

Replace RELAY_DOMAIN with your relay domain, e.g. for gsiot-ffmq-ttd5 type:

YalerEthernetServer server("", 80, "gsiot-ffmq-ttd5");

Note that you can as well use the local server, if you know how to configure port forwarding to open a hole for incoming HTTP requests in your local firewall. The important thing is that Twilio can access the Arduino from the cloud.

Save changes and upload

Save all changes and upload the program to your Arduino. Keep the USB cable connected to your development computer for now, and open the serial console to see debugging output.

Step 4: Accessing the Arduino

Access your Arduino from any browser

The Yaler library makes your Arduino (and with it the XML document) accessible from the public Internet at, e.g. for the relay domain gsiot-ffmq-ttd5 the URL is

Or, to make it look nicer for Twilio:

Check the XML document

The content of the XML document tells Twilio what to reply to an incoming phone call. You can even choose the text-to-speech voice. Here it's Alice. Twilio's XML format is called TwiML. See for details.

Note that the reply text contains the actual temperature. Heat up your sensor and refresh the document in your Web browser with F5 to see it change.


In case you get an empty page or an error, make sure your Ethernet cable is plugged in and check for browser specific debugging.

Step 5: Setting Up a Twilio Number

Sign up

First, to get a Twilio account, you'll have to sign up at

Buy a phone number

In order to receive calls you'll need a number, which comes at a (small) cost.

Log in, navigate to Numbers and select the Twilio Numbers sub menu, to see the Manage Numbers tab. Click the Buy a number button, select the Voice checkbox and click Search, then chose a number and click Buy to buy it.

Configure the voice.xml Webhook URL

In the Manage Numbers tab, click on the number you just bought.

Set the Response URL to and ensure that POST is selected, e.g. for the Yaler relay domain gsiot-ffmq-ttd5 set the Response URL to

Step 6: Placing a Test Call

(Phone picture by user William Gantz, licensed under CC BY-ND)

Once the Arduino is set up, you can call it from any phone - even your grandpa's.

That's it, thanks for reading.