Bidirectional SMS Delivery With Twilio Programmable Wireless

Use Twilio's Programmable SMS to send a Command by Programmable Wireless to an Ardunio device asking for it's current location then receive the location back by SMS.

Looking access to Twilio Programmable Wireless? Fill out the developer preview early access form.

What is the Command resource?

The Command resource enables you to exchange simple machine-to-machine messages with SMS-capable Devices. For example, you could use a Command to tell an idle Device to enable its data capabilities and establish an IP session.

SMS is used as the transport but the Device does not require an addressable phone number to receive a Command. This is a major distinction from the Messages resource.

Any SMS message sent from the Device to a predetermined phone number is interpreted as an incoming Command and sent to the Commands Callback Url of the Device.

Commands can be sent and received using the SMS text mode or binary (PDU) mode. Text mode Commands have a maximum length of 100 single-byte characters. Binary mode Commands have a maximum length of 140 bytes. To process a Command when it reaches your Device, you will interface with the modem directly. From the perspective of the Device, a Command is delivered as a regular SMS message.

What is the difference between a Command and a Programmable SMS?

Twilio’s Programmable SMS is used to send a text message to a device such as a smartphone. This is one of the most common tasks performed on the Twilio Platform. Twilio’s Programmable Wireless Command resource uses SMS as a transport layer to send mobile-to-mobile messages. This means you cannot use the Command resource to send a text message to a smartphone.

Requirements

Setup Instructions

Server

  1. Clone or download this repository
  2. Open config.js with your favorite text editor
  3. Update all values with the {{ YOUR_X_HERE }} convention
  4. See table below
  5. Upload code to server

Values To Update In config.js

Key Description
accountSid Consider this your account username. It’s used to authenticate - get it here.
authToken Consider this your account password. It’s used to authenticate - get it here.
devicePhoneNumber Used for bidirectional communication with device over SMS - get one here.
device This is your unique identifier to your IoT device - register your device here.

Twilio Console

  1. Navigate to the Programmable Wireless Devices page
  2. Select your newly created device
  3. Enter the Callback URL that points to the code you uploaded to your server.
  4. Click Save

Device

  1. Open Arduino IDE
  2. Go to File > Open in the Menu
  3. Navigate to your local copy of this repository
  4. Select Twilio_Wireless_SMS_Template.ino
  5. Select your Arduino board under Tools in the Menu
  6. Select the correct Port under Tools in the Menu
  7. Press the Right Arrow Button in Arduino IDE to upload the code
  8. Select Serial Monitor under Tools in the Menu
  9. Send a SMS with the text: Where are you?
  10. Wait for response

That’s it! Now you can send and receive SMS messages with.

Resources

Share this project:

Updates