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: Narrowband IoT Machine to Machine Commands Quickstart

I've gathered the hardware - now I need to register my Narrowband SIM

Sign up for a Twilio account and set up the Twilio Narrowband SIM

Before you can connect with Twilio Programmable Wireless, you'll need a Twilio account.

First, visit the Programmable Wireless Console and visit the Register a SIM page in the Programmable Wireless Console.

Remove the Twilio Narrowband SIM from the Developer Kit.

qxu2ADEjgA2TGNQ9CJBcK4jLgS8MBD5fHQgDZPvQB0IBXvWSJSi8OU2mglo5Bl6YSKqF_esi3-BkwlNXBwsuAYW71GlmSvNZE9fK17nUViM5eTzRCv4UW7ogxbCOSyHBlfBM3ftp

Next, register and activate your Narrowband SIM in the Twilio Console. The process for the Narrowband SIM follows the same procedure as the Twilio Programmable Wireless SIM.

NarrowBandSIM-Registration-Code.png

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

NarrowBandSIM-Unique-Name.png

Choose a Rate Plan

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

NarrowBandSIM-Rate-Plan.png

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.

NarrowBandSIM-Activate.png

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

Connecting the pieces

Break out the Nano SIM (smallest size) from the Twilio SIM card.

Remove the development board from the Developer Kit.

l5yiKdfcgWL3ajls_a49uiMq6VIlhoQw5fbA-ahkJnqE101t6TlnO09O_46rmRAn5pOO3sueTDvhX3V_Jr-e4xikqSFXHKo1V2wyHqae1qNG1rE3aHGmOA_MBE1aZtccvJGzVcbi

Insert the Twilio Narrowband SIM into the SIM slot underneath the board.

TVbm4rdGhh_W9WkEuHh9LU-ceeWNwq9WhC-ysepygq9iIgtP_X9iaLbG6tMXhT11xgcXLWxjPkvRmjCyx752sDfjSbmRU34nM2by2-MKqAeJZmYzD1M1o1Ju8HFzLATCteQVrsLs

Next, attach the LTE antenna to the board.

-WB_WEuLQN6amL72jkIy3slW-BgtQmKdf8CYQCzHTCD1bOtXmY1CIwayOSuMX2FG_nRZ-qo0kxDnaKZ_Wz-G2pChq_xxkYBOeNui2wItonhX3HN3pi3gEbfgw0CwCfoOF70PPq3c

Attach the battery lithium battery. The lithium battery is recommended to be plugged in at all times.

encgq8NeouXiFagAB-of7QoatAIlOd3mdUpGOA6sR6m_YhHjNzTz5zLLcXgoagmMKcmO1OL9oe0SNWAbGAw0ZOt_y-rvgYBcoLe1oizDxD1jNaWAGAhmKIwmrlq6jWwg9l9PHwkS

Connect the development board to the computer using the Micro-USB cable provided.

Time to configure the firmware.

Configure the NB-IoT Kit Firmware

Install Homebrew for the Macintosh.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)

Once the installation is complete install the dfu-util package. Version 0.9 or greater is preferred if available.

brew install dfu-util libusb

Instructions for installing dfu-util for Windows and Linux can be found here.

Next, we will setup

Set up the software environment

Download the Breakout_Arduino_Library.zip from GitHub.

rEM2xT-EuzpDWHNRjNFmXBQBFtBowbvzbwkw3fbWHmX1NFWY-cZVqQ39gS-kSTyH4gMdhECCnvWXY8k5wPMl-hSepJ41C7A_r4N5JZcqO8TjGrE0EFyt3A6YhL7CvNo81dihP49l

Open the Arduino IDE and add the .zip to the Arduino IDE Library using Add .ZIP Library.

Go to Sketch > Include Library > Add .ZIP library and select the Breakout_Arduino_Library.zip.

mEBwPI2Aka_d1NCYKEAXkL74xc7c0h5C9PJoosU5PZHKMMPtezH38n-udJxDx6MUYF10y6YWPMOIOok4zjBgMrgGpguTdFjonEZAqHWOnyuGO6g1mPGENqCnbMrEw6lpnSInH7-S

Go to Arduino > Preferences. Copy the following URL into the Additional Boards Manager URLs field:

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

suB30PXdikg0__Ve2ELah9Cy_2Xeh1oKNqZDJj2EuL-VNwpwF63656Yvd-cqjZHdlvsIIzhDhtnehGHwxqYrT5t8p2_9NscuIZDXVomsYy33IM7Oa5J8siLLzAvzggf4M14xttU1

Click OK.

Open the Boards Manager to install the STM32F4 board cores.

7pQuh0IxuzscJ8otGW6uP26U2PqQJL7x-kktX0oi555YygEC8WA6X8QvZIVb3boBHXEwIF6Una1K2qq3AU3t2tK_eAE-C1kPY7icVaYLm0TTfVAzXoz7XWsrhjZKT8AbDu8Wpdht

In the Boards Manager search for “Seeed”. Find and select the “Seeed STM32F4 Boards” version “1.2.3+” and click install.

Yl8co5N2AGQarf1cXeOJKJNMD--qAQuORNP3PDf9kadhIRHaWxSvh7KqxVw4xyvamkai9WpYKKPF-vfe2VG0p2fevKhfbkPCkPRO_lwtnOeZ2M5AcStWWYghFfZIxq43wIF51bne

Restart the Arduino IDE and select the Wio Tracker LTE board.

mVr43mlc6Pcb9MzyATrw9cAuJehztXClErkzDMVzKde7tArRhlSgpMraFkryLQUrTCLvxEDWkRM9_Lh7XhkD-opGH0XOodUEZh78fvzagOarLfJFRENbrTq1tVZQ-L7G-7Q_bEgQ

Select the board's port in the Tools menu.

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

CpD7vq0Dm4Lg0Y-jeg-LrYVDI2Qvzo9hQo7YnPImLtgBQCCPRJL5WTfesO8IzmmJ8LRq274AinRLl0fHLK6vDlv_jAWrQc77mGv2Xz23Usmqp_b9KQ-yYXiAyn03olk4IfeY_I1w

Configure the HelloWorld.ino file

Open the Hello World example provided by the Breakout SDK in the Arduino IDE.

  • Click File > Examples > Breakout Arduino Library > HelloWorld

linkMuwBWe915Y8hwg3pa8G6vrDD3P_hsi3UnmRK09gUyvPH9F5B_XKiZJcIsbf5xhHn2RBF7PboKyggWxs8ieKvbqnOgd_DBtPuiTgoIdZ8bRW1U18C1EVi6xqN2T9ObjSuT6D-

In the HelloWorld.ino find the psk_key in the “HelloWorld.ino” file.

A2M4K_1ER5APoAqp1d6ZL3Jx3VFvaRnR64iRtcjj7nmwszdG5LnjhRKxIQ9IEdWU3649ncDg9QR-Th-JWMD8LwklJIQgmmgH9MBvIepvf-vAMXDJZ8IHcxHD-PnQUUTvh8bPIAwS

Each development board has a unique SIM ICCID and Pre-Shared Key (psk). Copy the psk for the board into the HelloWorld.ino sketch. This key is required to connect to the T-Mobile Narrowband network.

  • Navigate to Programmable Wireless in the Twilio Console
  • Click SIMs
  • Find the Narrowband SIM that was previously registered
  • Under the tab Breakout SDK find Credentials
  • Where it says Pre-Shared Key (psk) click the eye logo to reveal the key
  • Copy the psk
  • Paste your psk into the HelloWorld.ino file in the code above

X4rhn9CnVankxRlj97YbjL9tLrDjyzMhxc2T4W8WJsBuY25WYHa8aP6myJ0MqMYccaxcDYUwPjSFbpkK5yC2_WnqdiYKUxRFbQeIur3h8Un3jH61STzL81nn0MgdImlqsLZSzuj3

Ready to upload?

Enter Bootloader Mode

The unit needs to be in Bootloader mode to upload code to the development board.

Press and hold the BOOT0 button.

pKBfBLRxI72Ylj_eSvUjjDgCSlkDPeeXAK6yE-48qEqnaPzEKls_F0Gfas4wcMF6TMG3vQq-bCGvAiKsSDWEJAoGYirWNJs1x4-kGSGjImF59GvSNdTd28kxreO3PBruXPEIXUoY

Press and hold the RST on the top of the Developer Board.

BsDNvUrPuG9__SN2Q6ljKNkJq_zmqHmD7n3Qdo2f70cYnhc-WXGAs_gxlmJRMNTxG2CBiM-qOyLKMTBrYnVWIA-BNpVkvUIX9295LE4DZGvJ1jVGYWDkAuakUmjcf68O714CMKk0

Release the RST on the top of the Developer Board.

Release the BOOT0 button to enable Bootloader mode.

pKBfBLRxI72Ylj_eSvUjjDgCSlkDPeeXAK6yE-48qEqnaPzEKls_F0Gfas4wcMF6TMG3vQq-bCGvAiKsSDWEJAoGYirWNJs1x4-kGSGjImF59GvSNdTd28kxreO3PBruXPEIXUoY

Press Upload in the Arduino IDE.

rWCDjfTI0avbhzoqhQt605b_kXdG3a2CwItq4Q4lKyvL9rNGVMFWNno5aDfmLK59je3fKUBgDhWpAca943BxWCEaf7YqBGV5FSWoad97PXO4TBItXftwjFISPz_DvhNytV-Th-0g

7yv0QJkXUAbfAva9IuTcEkVNLYCQh_uSVigMG_JzpwjbaEtnnEGN1fhJdYwRiQGERc8OCHSYZvjdfvMMZUORSFLDj8JXzWwfqHewY-Qr-g_41WyZlhOIFYDD5ZHrHClY612XP-kE

Press the RST button to start the new program and the NB-IoT network registration process will begin. During the registration process, the Network Connectivity LED will glow orange.

Open the Serial Monitor. When the registration process is complete, the board will connect to the Breakout SDK and the onboard LED will glow blue.

SAWtCdoZ09gXhhAptXZMzzUW3jhhcTJXF8_s3nmtJ6zf1LWvcnUHNDx5CTkUgs45AaJStalRIBQvXQ9vMNqF-z2AGAi8oj7M8oz3fyoMVV4lHPPq52CT65tJWGVTKywaC6v7-AOi

Sending your first Command.

Send a Machine to Machine Command from the development board

Using the Breakout SDK, we can send M2M commands to the development board over the NB-IoT network. When the program starts, a Command will be automatically sent over the network.

        
        
        
        
        Send and receive machine to machine commands (M2M) with Narrowband and the Breakout SDK

        Programmable Wireless Narrowband Machine to Machine commands

        Send and receive machine to machine commands (M2M) with Narrowband and the Breakout SDK
        How do you receive a Command?

        Receive a Machine to Machine Command with the Breakout SDK

        Sending (or in this case, manually responding to) a Machine to Machine command is very straightforward from your development machine and to the development board.

        Send a command to the SIM

        The fastest way to send a command (under 160 ASCII characters) back to the SIM is using cURL:

        curl -X POST https://wireless.twilio.com/v1/Commands -d 'Sim=DEXXXXXXXXXXXXXXXXXXXXXXXXXXXX' -d 'Command=Testing return' -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXX:YOUR_API_KEY'
        

        Otherwise, commands can be sent from our helper library:

              
              
              
              

              Again, we've included code to help you receive the M2M command using the development board.

                    
                    
                    
                    
                    Send and receive machine to machine commands (M2M) with Narrowband and the Breakout SDK

                    Programmable Wireless Narrowband Machine to Machine commands

                    Send and receive machine to machine commands (M2M) with Narrowband and the Breakout SDK
                    What is the Commands status?

                    Verify the Machine to Machine Commands were 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.

                    breakout-twilioreceive.png
                    As you might guess, we will implement the reverse - you'll receive an inbound SMS from the Breakout SDK triggered by an API call using the SIM's Sid. Let's look at that next.

                    Polling for the Command

                    The Breakout SDK polls for a new Command every ten minutes. When it is received by the development board ...

                    nb-curlcommand.png

                    ... magic!

                    And that's all there is to Machine to Machine commands.

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

                    What's next?

                    Now that you have seen how to send and receive Machine to Machine commands on both your Arduino MKR GSM 1400 and development machine, you're ready for your custom application. 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.