Level up your Twilio API skills in TwilioQuest, an educational game for Mac, Windows, and Linux. Download Now

Menu

Expand
Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

Programmable Wireless: Seeed Studio Wio LTE Machine-to-Machine Commands Quickstart

Using these instructions and the Wio LTE from Seeed Studio, you'll quickly connect to the internet using Twilio's Programmable Wireless.

We'll use the Arduino IDE in this quickstart. Although we recommend the Arduino IDE, code and instructions should work (at least partially) in other C/C++ workflows.

In this quickstart, you'll learn how to:

  1. Sign up for a Twilio account
  2. Purchase a Twilio Programmable Wireless Starter Pack which comes with 3 SIM cards
  3. Insert a SIM card into the Wio LTE
  4. Connect the included LTE antenna and Lithium Ion Battery to the Wio LTE
  5. Power and flash the Wio LTE
  6. Send and receive Machine-to-Machine Commands using Programmable Wireless

Hardware Prerequisites

  • Wio LTE
  • Micro-USB cable
  • LTE cellular antenna
  • 3.7v Lithium Ion Battery with JST SH 1.0mm 2-pin connector
    • Alternatively, you can adapt another lithium battery as we did. We used these adapters on Amazon. Carefully note the polarity of the jack when building the harness.

Setup & Software Requirements

Not the quickstart you were looking to complete? See our other Programmable Wireless quickstarts or see all Wireless resources.

I'm got everything ready - let's do this!

Already have a Twilio account and SIM card? Skip ahead to the register and activate step.

Before you can connect with Twilio Programmable Wireless you'll need a Twilio account. Once you've signed up, continue with this quickstart.

First, visit the Programmable Wireless Console. On the Orders page, purchase a set of 3 starter SIMs by selecting the SIM Starter Pack... or make a larger custom order by entering a quantity under the Multi-Size SIM Card product.

Order SIM Cards from Twilio

Note: Orders of 10 SIMs or more will be delivered with the SIM cards already tied to your account.

I've got my SIM! What's next?

Register, assign a Rate Plan, and activate your SIM

Once you receive your SIM shipment, visit the Register a SIM page in the Programmable Wireless Console.

SIM Card Registration Code

Follow that up by picking a Unique Name for the SIM.

Choose a Rate Plan

Next, select a Rate Plan from the options provided by Twilio.

By default, there are Rate Plans added which approximate the usage Twilio sees in the field. Rate Plans let you control every aspect of what your device can do its maximum monthly data usage. We've added some reasonable defaults, but feel free to explore options later.

Activate a SIM card

When you're happy with the Rate Plan, 'Activate' the SIM card.

Note: You'll need to activate your SIM for real-world workflows although you can use small amounts of data without activating.

I'm active! Let's plug things in and get ready to connect!

Attach the Cellular Antenna to the Wio LTE

With the Wio LTE still disconnected from power, remove the LTE antenna from the packaging. Connect the LTE antenna to the connector labeled 'LTE' on the Wio. Your setup should look like this:

Attaching a LTE Antenna to Seeed Studio Wio LTE for Twilio Machine-to-Machine quickstart using the Arduino IDE

Insert the SIM Card

Punch out your Twilio SIM card and insert it into the slot closest to the PCB on the Wio.

The slot is on the modem side and has an orientation diagram. You want to put it in the 'bottom' slot; the upper slot is for an optional MicroSD card.

Insert IoT SIM into the Seeed Studio Wio LTE for Twilio Machine-to-Machine quickstart using the Arduino IDE

Prepare to Connect the Battery

Locate the JST connector and plug the Lipoly Battery into the board. The battery must be plugged in at all times for connectivity to work.

Attaching lithium battery to the Seeed Studio Wio LTE for Twilio Machine-to-Machine quickstart using the Arduino IDE

The finished setup will look similar to the image below.

Complete Seeed Studio Wio LTE setup for Twilio Machine-to-Machine quickstart using the Arduino IDE

Plug-in and configure the Wio LTE.

Install the USB-Drivers

Next connect the Wio LTE to the computer using a Micro-USB cable.

The Wio LTE does not need a USB-Driver for the Macintosh. Instructions for installing the Wio LTE USB-Drivers for Windows and Linux can be found here.

Setup the Arduino IDE to work with the Wio LTE.

Install the Wio LTE Arduino Library

In the Arduino IDE, go to Sketch > Include Library > Manage Libraries.

Including the Seeed Studio Wio LTE library in the Arduino IDE for Twilio Machine-to-Machine quickstart

Using the Library Manager search for and install the Wio LTE Arduino Library

Install the Seeed Studio Wio LTE library in the Arduino IDE for Twilio Machine-to-Machine quickstart

Install the Seeed STM32F4 Boards

Go to Arduino > Preferences.

Arduino IDE preferences for the Seeed Studio Wio LTE  Twilio Machine-to-Machine quickstart

Find Additional Boards Manager URLs and paste the following JSON URL.

  • https://raw.githubusercontent.com/Seeed-Studio/Seeed_Platform/master/package_seeeduino_boards_index.json

Add an additional Seeed Studio board manager URL in the Arduino IDE for the Twilio Wio LTE Machine-to-Machine quickstart

Press OK.

Go to Tools > Board > Board Manager.

Open board manager in the Arduino IDE for the Twilio Wio LTE Machine-to-Machine quickstart

Search for and install the Seeed STM32F4 Boards package.

Add the Seeed Studio boards to Arduino IDE for the Twilio Wio LTE Machine-to-Machine quickstart

Restart the Arduino IDE.

With the STM32F4 cores installed the Wio LTE is now ready to be programmed. Next select the board and the board port.

  • Click Tools > Boards > Wio Tracker LTE

Choosing the Wio Tracker LTE in the Arduino IDE for the Twilio Wio LTE Machine-to-Machine quickstart

Click Tools > Port > {Your Modem Port Here}

  • Macintosh: /dev/{cu|tty}.usbmodem{XXXX}
  • Linux: /dev/ttyACM{X}
  • Windows: COM{X}

Choosing the Wio LTE port in the Arduino IDE for the Twilio Machine-to-Machine quickstart

Change the mode before we can flash the Wio LTE.

Enter Bootloader Mode

To upload code to the Wio LTE the unit needs to be put into Bootloader mode.

Press and hold the BOOT0 button underneath the Developer Board.

Boot0 button on Seeed Studio Wio LTE for the Twilio Machine-to-Machine quickstart

Press the RST button once while holding the BOOT0 button.

Reset button on the Seeed Studio Wio LTE for the Twilio Machine-to-Machine quickstart

Now, release the BOOT0 button to enter Bootloader mode.

Let's flash the Wio LTE with some code.

Flash the Wio LTE

You can download the code directly from this directory on Github.

  • Open the file m2m_command_wiolte.ino. Alternately, you can copy/paste the code into a new Arduino sketch using File> New Sketch.

Press the "Upload" button.

Upload code for the Twilio Seeed Studio Wio LTE Machine-to-Machine quickstart

The progress of the upload can be viewed in the pane underneath the code.

Arduino IDE upload progress for the Twilio Seeed Studio Wio LTE quickstart

Time to connect!

Exit Bootloader Mode

Once the upload is complete exit Bootloader mode by pressing the RST button once. This will start the new program that was uploaded to the Wio LTE.

Reset button on the Seeed Studio Wio LTE for the Twilio Machine-to-Machine quickstart

After restarting the Wio LTE open the Serial Monitor in the Arduino IDE.

  • Tools > Serial Monitor

The output of the Serial Monitor will look something like this:

Serial monitor in the Arduino IDE for the Twilio Seeed Studio Wio LTE Machine-to-Machine quickstart

How do you send a M2M command with the Wio LTE?

Send a Machine to Machine Command from the Wio LTE

Here's the method to send a machine to machine command:

        
        
        
        
        Send and receive machine to machine commands (M2M) with an Seeed Studio Wio LTE

        Send a Machine-to-Machine Command from the Wio LTE

        Send and receive machine to machine commands (M2M) with an Seeed Studio Wio LTE

        Behind the scenes, the SIM sends an SMS message to the reserved phone number '2936', a Command resource will be created and your Commands Callback URL will be invoked. This shortcode uses the SMS transport to send a Command which can be seen in an App or inside the Wireless console.

        A message will appear in the Serial Monitor when the Command is sent successfully:

        Sending a Twilio Machine to Machine command using the Seeed Studio Wio LTE

        Verify the Machine to Machine Command was sent

        The easiest way to check the command was successful is through the Programmable Wireless Console.

        1. From the Console, select SIMs from the Programmable Wireless menu.
        2. Click the SIM you are using for this project, then navigate to the Commands tab.
        3. Copy the SIM Sid.

        Verifying commands for the Twilio Seeed Studio Wio LTE Machine-to-Machine quickstart

        As you might guess, we will implement the reverse - you'll receive an inbound SMS from 2936 on the Wio LTE triggered by an API call using the SIM's Sid. Let's look at that next.

        Cool, show me how to receive a M2M Command.

        Receive a Machine to Machine Command with the Wio LTE

        Again, we've included code to help you receive the M2M command easily.

              
              
              
              
              Send and receive machine to machine commands (M2M) with an Seeed Studio Wio LTE

              Receive a Machine-to-Machine Command with the Wio LTE

              Send and receive machine to machine commands (M2M) with an Seeed Studio Wio LTE

              To test this out, return to the Arduino IDE and make sure the Serial Monitor is still connected. The fastest way to respond to a command is to use cURL if available.

              If you can, send a command (under 160 ASCII characters) back to the SIM using cURL:

              curl -X POST https://wireless.twilio.com/v1/Commands -d 'Sim=DEXXXXXXXXXXXXXXXXXXXXXXXXXXXX' -d 'Command=Hello from cURL!' -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXX:YOUR_API_KEY'
              

              Otherwise, commands can be sent from our helper library:

                    
                    
                    
                    

                    If all goes well the Wio LTE will receive the Command and you should see a successful run:

                    Receive a Machine-to-Machine Twilio Command using the Arduino IDE with a Seeed Studio Wio LTE

                    ... magic!

                    And that's all there is to Machine to Machine commands with the Wio LTE. You now know how to send Machine to Machine Commands and check their status in the console. You can also return a Command from your machine and have seen how to receive it with the Wio LTE.

                    With those basic building blocks you're ready to build the next big IoT Thing!

                    I'm connected! What should I do next?!

                    Where to next?

                    Now that you have seen how to send and receive Machine to Machine commands with the Wio LTE and your development machine, you're ready to build your first TwilioIoT project. Here are some possible ideas to take it to the next level:

                    Rate this page:

                    Need some help?

                    We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.