TI CC3200

How to connect a TI CC3200 to Xively

The Texas Instruments SimpleLink™ Wi-Fi® CC3200 LaunchPad™ development kit is an easy and cost effective way to get started with connected devices.

Scan this tutorial to get familiar with it. Then complete each step in a sequential manner. Each step builds upon the previous one.

This tutorial supports Windows and macOS. For Linux, follow the macOS instructions.

What you will learn

This tutorial will teach you how to build, link, and deploy a Xively C Client Application onto the CC3200 using Code Composer Studio™. Then you will learn how to connect your device to Xively.

Hardware you will need

Texas Instruments SimpleLink™ Wi-Fi® CC3200 LaunchPad™ development kit

SimpleLink Wi-Fi CC3200 LaunchPad

SimpleLink Wi-Fi CC3200 LaunchPad

Software you will install during the tutorial

  • Code Composer Studio™ version 7.0
  • CC3200 Simplelink™ Wi-Fi SDK
  • Xively C Client library
  • CC3200 Uniflash (optional)

Step 1 of 7: Install Code Composer Studio™

Code Composer Studio™ includes the toolchain (compiler) you will need to build for the CC3200 and a java-based IDE.

  1. Download the Code Composer Studio™ version 7.0 appropriate for your operating system (Windows, Linux or macOS): Code Composer Studio (CCS) Integrated Development Environment (IDE).
  2. Complete the free registration.
  3. Validate your email address.
  4. Complete the brief export approval form and click Submit.
  5. Upon approval, click Download to proceed. Monitor the download process to completion.
  6. Once download is complete, start the installation.
  7. Accept the license agreement and click Next >.
  8. Choose the default install folder and click Next >. Or, if you install into a custom directory, then note its path as you will need to refer to it later. By default the path should be c:\ti on Windows and /Applications/ti on macOS.
  9. Enable SimpleLink CC3X Wireless MCUs.
    Note: If you use a CCS version older than 7.0, select SimpleLink Wireless MCUs and its two child options: CC32xx Device Support and TI ARM Compiler.
  10. Click Next > twice more, and click Finish when the button becomes enabled.
  11. Once installation completes, click Finish to leave the installer.

Step 2 of 7: Install the CC3200 Simplelink™ Wi-Fi SDK

This SDK contains the platform libraries that you will need to compile and link against when writing software for the CC3200.

  1. Launch Code Composer Studio™.
  2. If prompted to Select a Workspace, click OK to select the default path.
  3. Select View>Resource Explorer from the top bar menu.
  4. Select CC3200 Simplelink Wi-Fi from the list of available development tools.
  5. On the right side of the screen, click the Install on Desktop down-arrow icon and select Make Available Offline. Confirm Yes on the popup window.
  6. A Dependencies popup may appear. Click OK to download any software dependencies.

Note: Windows users may download the CC3200 Simplelink™ Wi-Fi SDK directly outside of the Code Composer Studio™ if you wish. Once downloaded, install using the default settings.

Step 3 of 7: Download the Xively C Client library

Download the library source code from xively-client-c. Git clone the repository or download the source archive from the right side of the github page.

Step 4 of 7: Build the Xively C Client library

Configure the Xively C Client build environment by setting paths to CSS and SDK, and build the library:

  1. Open the make/mt-os/mt-cc3200 make target file in your favorite friendly text editor.
  2. Scroll to the HOSTS section devoted to your host platform: MAC HOST OS, WINDOWS HOST OS, or LINUX HOST OS.
  3. In the HOST section appropriate for your platform, set the XI_CC3200_PATH_CCS_TOOLS and XI_CC3200_PATH_SDK variables to your Code Composer Studio™ and SDK install paths, respectively.
    Note: If you chose the default installation paths for these installations then these values should alrea valid and you shouldn't need to change anything.
  4. The toolchain that Code Composer Studio™ downloaded might differ from the default that's configured in this mt-cc3200.mk file. Verify the compiler paths:
    a. Browse to the path which you set XI_CC3200_PATH_CCS_TOOLS.
    b. Open up the compiler/ directory and note the name of the toolchain.
    c. Compare this to the toolchain name stored in the COMPILER variable near the top of the file in mt-cc3200.mk. Update the COMPILER variable as necessary.
  5. Execute the following commands from the xively-client-c root folder:

Windows:

Set paths for gmake and mkdir:

PATH=%PATH%;<path-to-ccs>\utils\bin
PATH=%PATH%;<path-to-ccs>\utils\cygwin

where <path-to-ccs> is the path to your Code Composer Studio, for example C:\ti\ccsv6.

Clean and build the library:

gmake PRESET=CC3200_TLS_SOCKET clean
gmake PRESET=CC3200_TLS_SOCKET

macOS and Linux:

Clean and build the library:

make PRESET=CC3200_TLS_SOCKET clean
make PRESET=CC3200_TLS_SOCKET

Step 5 of 7: Create your Xively digital device

You should have a Xively account already created, but if you do not, register one for free at Xively.com.

Before connecting a physical device to Xively, create its digital representation in the system. Log into the Xively management app to complete the following steps.

Create a CC3200 device template using the Product Launcher

This operation will create a device template and a device instance in Xively to represent your CC3200 board.

  1. Click on Product Launcher > Add another device.
  1. From the pop-up window select Choose from our template library and click Next.
  1. From the sections tabs at the top of the window go to Quickstart Kits, select TI CC3200, and click Next.

Get credentials for this device

In order for your device to securely talk to Xively it needs credentials that it will use to authenticate itself as a valid device within your account.

  1. Go to Devices > All devices and look for your sample CC3200 device. Click on its name.
  2. Click on Get password.
  1. When the modal window pops-up, click the Download button.

    A file named MQTTCredentials.txt gets downloaded. It contains the device credentials that will be used in the next step. The file contains two data items:

    • The first line is the Xively Device Secret.
    • The second line is the Xively Device Id.

You now have a provisioned device in Xively that your CC3200 will be able to connect as.

Get account ID

To allow your device to publish and subscribe to MQTT topics you will need your account ID.

  1. Click on your name in the top right-hand corner of the page and click the turquoise rectangle with your account id.
    Your account id has been copied to the clipboard.
  2. Save your account id for later. It will be needed for xively_demo application configuration in the next step.

Now you are ready to build and run Xively Demo application.

Step 6 of 7: Build your client application

We've prepared a CC3200 demo application that uses the Xively C Library to connect to the Xively Service. It will allow you to control the on-board LEDs remotely from the Xively Product Launcher, and send temperature and button state data from the device to the Xively Service.

We will import the example into Code Composer Studio™, configure your IoT Client parameters, and build the demo application to connect to the Xively service.

Import xively_demo

  1. In Code Composer Studio™, select File>Import.
  2. Select Code Composer Studio™>CCS Projects and click Next >.
  3. To the right of Select search-directory click Browse.
  4. From this directory, browse to PATH_TO_XIVELY_LIBRARY/xively-client-c/examples/cc3200 and highlight the xively_demo folder. Click Open.
  5. Click Finish.

Configure Code Composer Studio project

To adapt the imported project to your environment, modify project variables that describe SDK and library locations on your hard drive.

  1. In Code Composer Studio™, make sure the xively_demo project is highlighted.
  2. Select Project>Properties.
  3. HighlightResource>Linked Resources.
  4. Double click on CC3200_SDK_ROOT variable name and using the Folder button navigate to where your CC3200_SDK is installed, mark the subfolder cc3200-sdk in SDK's main directory and hit OK twice.
  5. Double click on XIVELY_LIBRARY_C_ROOT variable name and again using the Folder make the variable to point to the xively-client-c folder.

Configure xively_demo

Before you build your application, set your Wi-Fi credentials and Xively device credentials.

  1. Set your Wi-Fi credentials in 'main.c':
    a. Update AP name and password defines according to your Wi-Fi settings:
            #define ENT_NAME    "AccessPointName"
            #define PASSWORD    "Password"

b. Select a security type in the MainLogic() function according to your Wi-Fi settings. For example, in the case of WPA2 set, the line looks as follows:

            g_SecParams.Type = SL_SEC_TYPE_WPA_WPA2;

c. For other WLAN security setting flags, refer to CC3200_SDK_ROOT/simplelink/include/wlan.h or TI Simplelink documentation.

  1. Set your Xively Credentials in 'main.c'.
    Locate and update the following three values using information you got from Step 5 Create your Xively (digital) device.
            #define XIVELY_DEVICE_ID "PASTE_YOUR_XIVELY_DEVICE_ID"
            #define XIVELY_DEVICE_SECRET "PASTE_YOUR_XIVELY_DEVICE_SECRET"
            #define XIVELY_ACCOUNT_ID "PASTE_YOUR_XIVELY_ACCOUNT_ID"

Build and run the example

  1. Select Project> Build Project.
    When complete, you should see the following in the Console:
            <Linking>
            Finished building target: xively_demo.out
            ...
            **** Build Finished ****
  1. Execute the example on the CC3200 device:
    a. Connect the device to your PC or Mac with USB cable.
    b. Press and release the RESET switch SW1.
    c. In Code Composer Studio™, hit the green bug button on the top or select Run >Debug.
    d. In Code Composer Studio™, hit the green right-arrow button on the top or select Run >Resume.
Host Driver Version: 1.0.0.10
Build Version 2.6.0.5.31.1.4.0.1.1.0.3.34
[WLAN EVENT] STA Connected to the AP: LMI-GUEST , BSSID: c:d9:96:82:c2:c2
[NETAPP EVENT] IP Acquired: IP=10.229.211.31 ,Gateway=10.229.208.1
[WLAN EVENT]Device disconnected from the AP: LMI-GUEST, BSSID: c:d9:96:82:c2:c2 on application's request 
Device is configured in default state 
Device started as STATION 
[WLAN EVENT] STA Connected to the AP: LMI-GUEST , BSSID: 54:78:1a:42:f4:c2
[NETAPP EVENT] IP Acquired: IP=10.229.211.31 ,Gateway=10.229.208.1
SNTP_G: 1484067770, pool.ntp.org->0x726F4F2D
SNTP_L: 1484067770, UT 0
close the user file: /cert/xively_cert_globalsign_rootca.der
connected to broker.xively.com:8883
topic:xi/blue/v1/56c70c5d-984e-46ff-a615-7458d6b8a237/d/2bf108c9-e326-4a10-be11-eab4557b1dce/Green LED. Subscription granted 0.
topic:xi/blue/v1/56c70c5d-984e-46ff-a615-7458d6b8a237/d/2bf108c9-e326-4a10-be11-eab4557b1dce/Orange LED. Subscription granted 0.
topic:xi/blue/v1/56c70c5d-984e-46ff-a615-7458d6b8a237/d/2bf108c9-e326-4a10-be11-eab4557b1dce/Red LED. Subscription granted 0.

In the Console pane, you should see messages showing:

  • Your device connecting to your Wi-Fi network.
  • Acquiring the current time from an NTP server.
  • Connecting to the Xively MQTT broker.
  • Subscribing to three topics.

Reaching this point means you are able to produce and execute CC3200 compatible binary on the device itself. Congratulations!

NOTE: As per Texas Instruments instructions, keep the J15 Jumper set to ON and push Reset button on the board before each debug session. In case of trouble review the TI's CC3200 help doc.

You (hopefully) did it!

If everything worked correctly, within a few seconds you should see a debug log that says:

    connected to broker.xively.com:8883

If you do not see that, double check that you followed all the previous steps accurately. If you see a state value other than 0, check within xively_error.h to see which error could be occuring (ex: 34 means bad credentials).

If you are just testing (or on a Mac), skip the next step and go straight to Congratulations!

Step 7 of 7: Flash your client application onto the device (Optional, Windows Only)

By default Code Composer uploads your application into RAM for execution. This is great for quick iterations, but it also means that your device will lose your changes when you unplug it.

To permanently make changes to the device, flash the device using a Windows binary executable called Uniflash. This tool is external to Code Composer Studio™.

Download and install the Code Composer Studio™ Uniflash software

  1. From Code Composer Studio™ Uniflash download page choose Windows Offline Version.
  2. Begin the installation process
  3. On the "Select Components" window, leave only the Simplelink Wi-Fi CC31xx/CC32xx option selected and continue installation process.

Run the Code Composer Studio™ Uniflash Software

  1. Plug in your CC3200 device and make sure that the J15 Jumper is set to ON.
  2. From File select New Configuration and select the following:
    • Connection: CC3x Serial(UART) Interface
    • Board or Device: SimpleLink Wi-Fi CC3100/CC3200
  3. On the left panel under the System Files, highlight the /sys/mcuimg.bin file.
  4. From the right panel click the Browse button right next to the Url field.
  5. Pick the name_of_your_project.bin from your workspace_name/project_name/RELEASE/.
  6. From the left panel highlight CC31xx/CC32xx Flash Setup and Control.
  7. Click the Program button.
  8. Set the J15 jumper to OFF and restart your device.

Your device runs the test program.

Congratulations!

You did it! You now have a CC3200 board connected and communicating with Xively.

You should be able to go back to your device page in Xively management app and see that its status is now Connected and within the logs see its Device connected lifecycle log.

When you enter the Product Launcher you will be able to see the graphical representation of data received from your CC3200 device such as temperature and button states. You can also turn on and off CC3200's LEDs using this web page interface.

What to do next?

How to use a more secure configuration of wolfSSL with OCSP Stapling?

For advanced security with OCSP support, take a look at the next tutorial: TI CC3200 with enhanced security.

More coming soon

For now please visit our docs and view some other guides and please let us know any feedback or questions that you may have regarding this guide or Xively in general!

Common pitfalls or errors

More coming soon

Q. When I build the example application I get the "Xively Hello World" debug message, but with a state of 34.
    connection to broker.xively.com:8883 has failed reason 34

A. A state of 34 means that the device connected to the Xively system, but its credentials are invalid. This could occur if you copied the credentials incorrectly or if you have regenerated the device credentials and are using older ones. The easiest way to fix this issue is to regenerate the device credentials (see Step 5.2) and re-copy the new credentials within main.c. Once you've done this rebuild the image flash the hardware again.

TI CC3200

How to connect a TI CC3200 to Xively