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
- Programmable Wireless SIM Card
- Programmable Phone Number
- Arduino board with GPS and cellular module
- Arduino IDE
- Server running Node.js
Setup Instructions
Server
- Clone or download this repository
- Open
config.jswith your favorite text editor - Update all values with the
{{ YOUR_X_HERE }}convention - See table below
- 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
- Navigate to the Programmable Wireless Devices page
- Select your newly created device
- Enter the Callback URL that points to the code you uploaded to your server.
- Heroku Example: https://YOUR-APP-NAME-HERE.com/api/v1/callback
- Click Save
Device
- Open Arduino IDE
- Go to File > Open in the Menu
- Navigate to your local copy of this repository
- Select
Twilio_Wireless_SMS_Template.ino - Select your Arduino board under Tools in the Menu
- Select the correct Port under Tools in the Menu
- Press the Right Arrow Button in Arduino IDE to upload the code
- Select Serial Monitor under Tools in the Menu
- Send a SMS with the text:
Where are you? - Wait for response
That’s it! Now you can send and receive SMS messages with.
Log in or sign up for Devpost to join the conversation.