With a few pieces of hardware, these instructions, and Twilio Programmable Wireless you can disconnect your devices from their wired perches and deploy them into the field where they'll be more useful.

In this quickstart, we'll use a Raspberry Pi running the Raspbian operating system, a USB to UART bridge, a Huawei E397 (Cricket) USB Modem and some packaged scripts and finish with a Raspberry Pi on the internet using cellular connectivity. This particular quickstart will leave you with a headless Raspberry Pi, one that you manage via serial or SSH and not a monitor, keyboard, or mouse.

In this Quickstart, you'll learn how to:

Sign up for Twilio and purchase your first SIM cards for Twilio Programmable Wireless

Install Raspbian on a Raspberry Pi and configure it for a serial connection

Configure Raspbian to turn off power to video displays and increase maximum power to USB devices

By default, Twilio has entered rate plans which are close to what are used in the field. Although beyond the scope of this quickstart, Rate Plans let you control every aspect of what your device can do in the field... and how much data it can use.

Note: This image will not always be up to date with the most recent Raspbian release - be sure to update the image if you choose to install it. Always check the Raspbian download page for the latest image.

Depending on whether you already have the driver installed for your USB serial adapter or not, first install your serial driver before attempting these steps. Driver details should be included with the cable or adapter you purchased, or found online with a search.

Once the serial adapter is working, there are two paths to setting up your Pi. You can either edit the boot configuration of the Raspberry Pi on the machine you use to flash Raspbian or on the Pi itself. Depending on your preference, select one path to enable the onboard serial connection and increase the maximum current available to USB devices.

It's time to physically wire the USB to Serial adapter to the Raspberry Pi. First, familiarize yourself with the pinout on the Pi (if you are not using a Raspberry Pi A+ or B+ see here for pinout diagram):

If you are using a different adapter, we're going to use three pins to connect:

6 - GND

8 - Rx

10 - Tx

First, connect GND on your serial adapter to pin 6 on the Pi (the pin on the adapter may instead look like ⏚ with a pointed bottom). Ensure a snug fit, GND is the reference voltage for the other signals and communication will be unreliable if the connection is loose.

Next, very carefully connect pin 8, Tx, on the Pi to Rx on the Adapter. Note: this is not a typo - pins are labeled from the perspective of the device, so where the Pi receives you want to transmit.

Similarly, connect pin 10, Rx, to Tx on the adapter.

When complete (and depending on the model of Pi and Adapter you purchased) your setup should look similar to the following:

It's time to fire up your Raspberry Pi. Double check and make sure your SD card, SIM card, UART cables, and now that the power adapter is plugged in. You should see the red and green lights on your Raspberry Pi start flashing.

Next, on your development machine, connect the USB-Serial adapter and open a serial terminal to connect to it at 115,200 baud. On Mac OS X (and some flavors of *NIX), you can use the screen serial terminal in a manner similar to:

Your Raspberry Pi model may or may not have provisions to connect to the internet onboard (the A+, for example, doesn't).

If it doesn't include connectivity, the default installation of Raspbian includes drivers for many USB WiFi and USB Ethernet adapters. While you will end this guide with cellular internet connectivity, temporarily attach a USB WiFi or Ethernet adapter. If you are using ethernet, connect a cable between the Pi and a modem, router, or switch to give it connectivity.

It's now the moment of truth. First, plug in the USB Modem to the Pi. Then, power on your Pi using the MicroUSB cable and watch your serial terminal.

When presented with a login prompt, log in using the username pi and the password raspberry by simply typing in your serial terminal. If necessary (usually for WiFi), connect the board to the internet via your network.

And... actually, that's it! Bring down your current temporary internet connection with one of the following commands. (If it doesn't work, you can use the ifconfig command on the Pi to see the name of your connection).

For WiFi:

sudo ifconfig wlan0 down

For Ethernet:

sudo ifconfig eth0 down

Finally, you can connect to Twilio Programmable Wireless! Run the ppp script to connect the USB Modem:

sudo pon twilio

Ready for the magic? Verify you have a connection by pinging – what else? – Twilio's API:

ping -c 3 www.twilio.com

And there you have it - cellular connectivity!

Now that it works, let's set up the Pi to connect to Twilio at startup.

Whenever the Pi power cycles, we want it to automatically connect using Twilio. However, if the USB modem isn't inserted, that's a waste of time - we won't be able to make the connection. If the modem is connected we can also save some power by powering down the HDMI and RCA connection (it is going to run headless, after all).

Open up the file /etc/rc.local in your favorite text editor: sudo nano /etc/rc.local