The SimpleLink™ Wi-Fi® CC3200 LaunchPad™ development kit is an evaluation development platform for the CC3200 wireless microcontroller (MCU) from Texas Instruments; a single-chip programmable MCU with built-in Wi-Fi connectivity.

Requiremets

Setup

1. Download Energia IDE here and install it on your pc.

This tutorial assumes you have already flashed a program into your CC3200 launchpad before. If you’re not sure about this, we recommend flashing the basic “blink” example to make sure you’re being able to code your device.

2. Open Boards Manager from Tools -> Board menu and install CC3200 platform

3. Go to Tools -> Board and select LaunchPad w/ cc3200 (80MHz).

4. Download our library here.
 
5. Now, click on File -> Include Library -> Add .ZIP Library

6. Select the .ZIP file of Ubidots CC3200-LAUNCHXL and then "Accept" or "Choose"

7. Close the Energia IDE and open it again.


Hardware Setup

Before compile your board make sure your board’s Jumpers are in the right place. The settings below worked for us, but we strongly advise you to follow Energia’s guides to make sure you’re able to program your board:

Put a wire from “TCK” pin to 2 pin in SOP pins

To make sure you're able to code your device, we recommend you flashing the basic "blink" example before start.

Change default name

The library will create a new Ubidots device named "CC3200", also assigns the same name for the device label. If you desire to assign a different device label, please add to your setup() function the line below:

client.setDeviceLabel("my-new-device")

Send values to Ubidots

To send one value to Ubidots, go to Sketch -> Examples -> Ubidots CC3200-LAUNCHXL and select the "UbidotsSaveValuesHttp" example.

Update your WiFi crendentials, assign your Ubidots TOKEN and the variable label where is indicated. Once the parameters are assigned, upload the code. Then, open the Serial monitor to check the results.

NOTE: If no response is seen, try unplugging the board and then plugging it again. Make sure the baud rate of the Serial monitor is set to the same one specified in your code.

// This example sends data to multiple variables to
// Ubidots through HTTP protocol.

/****************************************
* Include Libraries
****************************************/

#include "Ubidots.h"

/****************************************
* Define Instances and Constants
****************************************/
const char* UBIDOTS_TOKEN = "..."; // Put here your Ubidots TOKEN
const char* WIFI_SSID = "..."; // Put here your Wi-Fi SSID
const char* WIFI_PASS = "..."; // Put here your Wi-Fi password

Ubidots ubidots(UBIDOTS_TOKEN, UBI_HTTP);

/****************************************
* Auxiliar Functions
****************************************/

// Put here your auxiliar functions

/****************************************
* Main Functions
****************************************/

void setup() {
  Serial.begin(115200);
  ubidots.wifiConnect(WIFI_SSID, WIFI_PASS);
  // ubidots.setDebug(true);  // Uncomment this line for printing debug messages
}

void loop() {
  float value1 = random(0, 9) * 10;
  float value2 = random(0, 9) * 100;
  float value3 = random(0, 9) * 1000;
  ubidots.add("Variable_Name_One", value1); // Change for your variable name
  ubidots.add("Variable_Name_Two", value2);
  ubidots.add("Variable_Name_Three", value3);
  bool bufferSent = false;
  bufferSent = ubidots.send(); // Will send data to a device label that matches the device Id
  if (bufferSent) {
    // Do something if values were sent properly
    Serial.println("Values sent by the device");
  }

  delay(5000);
}

Send values with context

The following example is to send one value with context to Ubidots, it will create the variable automatically with the label assign by you into the code.

Add your Ubidots TOKEN where indicated, as well as the WI-FI settings.

// This example sends data and context to a variable to
// Ubidots through TCP protocol.

/****************************************
* Include Libraries
****************************************/

#include "Ubidots.h"

/****************************************
* Define Instances and Constants
****************************************/

const char* UBIDOTS_TOKEN = "...";  // Put here your Ubidots TOKEN
const char* WIFI_SSID = "...";      // Put here your Wi-Fi SSID
const char* WIFI_PASS = "...";      // Put here your Wi-Fi password
Ubidots ubidots(UBIDOTS_TOKEN, UBI_TCP);

/****************************************
* Auxiliar Functions
****************************************/

// Put here your auxiliar functions

/****************************************
* Main Functions
****************************************/

void setup() {
  Serial.begin(115200);
  ubidots.wifiConnect(WIFI_SSID, WIFI_PASS);
  // ubidots.setDebug(true); // Uncomment this line for printing debug messages
}

void loop() {
  float value = analogRead(A0);

  /* Adds context key-value pairs */
  ubidots.addContext("weather-status", "sunny");
  ubidots.addContext("time", "11:40:56 pm");

  /* Reserves memory to store context array */
  char* context = (char*)malloc(sizeof(char) * 60);

  /* Builds the context with the array above to send to Ubidots */
  ubidots.getContext(context);
 
  /* Sends the variable with the context */
  ubidots.add("temperature", value, context);// Change for your variable name
  bool bufferSent = false;
  bufferSent = ubidots.send();  // Will send data to a device label that matches the device ID
  if (bufferSent) {
    // Do something if values were sent properly
    Serial.println("Values sent by the device");
  }

  free(context);
  delay(5000);
}

Send values with timestamp

The following example is to send one value with timestamp to Ubidots, it will create the variable automatically with the label assign by you into the code.

Add your Ubidots TOKEN where indicated, as well as the WI-FI settings.

// This example sends data along with timestamp in POSIX ms standard
// to a variable to Ubidots API through HTTP, TCP or UDP protocol.                                         /****************************************
* Include Libraries
****************************************/

#include "Ubidots.h"

/****************************************
* Define Instances and Constants
****************************************/

const char* UBIDOTS_TOKEN = "...";  // Put here your Ubidots TOKEN
const char* WIFI_SSID = "...";      // Put here your Wi-Fi SSID
const char* WIFI_PASS = "...";      // Put here your Wi-Fi password

Ubidots ubidots(UBIDOTS_TOKEN);

/****************************************
* Auxiliar Functions
****************************************/

// Put here your auxiliar functions

/****************************************
* Main Functions
****************************************/

void setup() {
  Serial.begin(115200);
  ubidots.wifiConnect(WIFI_SSID, WIFI_PASS);
  // ubidots.setDebug(true);  // Uncomment this line for printing debug messages
}

void loop() {
  float value1 = analogRead(A0);
  unsigned long timestamp_seconds = 1571615253L;  // Put here your timestamp in seconds
  unsigned int timestamp_milliseconds = 0; // Put here the number of milliseconds to shift your timestamp
  ubidots.add("temperature", value1, NULL, timestamp_seconds,timestamp_milliseconds);  // Change for your variable name
  bool bufferSent = false;
  bufferSent = ubidots.send();  // Will send data to a device label that matches the device Id
  if (bufferSent) {
    // Do something if values were sent properly
    Serial.println("Values sent by the device");
  }

  delay(5000);
}

Get value from Ubidots

To get the last value of a variable from Ubidots, go to Sketch -> Examples -> Ubidots CC3200-LAUNCHXL and select the "UbidotsGetValueHttp" example.

Update your WiFi crendentials, assign your Ubidots TOKEN, the device and variable label from where you desire obtain the value.

Upload the code, open the Serial monitor to check the results.

NOTE: If no response is seen, try unplugging the board and then plugging it again. Make sure the baud rate of the Serial monitor is set to the same one specified in your code.

// This example retrieves last value of a variable from the Ubidots API
// using HTTP protocol.

/****************************************
* Include Libraries
****************************************/

#include "Ubidots.h"

/****************************************
* Define Constants
****************************************/

const char* UBIDOTS_TOKEN = "...";// Put here your Ubidots TOKEN
const char* WIFI_SSID = "..."; // Put here your Wi-Fi SSID
const char* WIFI_PASS = "..."; // Put here your Wi-Fi password
const char* DEVICE_LABEL_TO_RETRIEVE_VALUES_FROM = "weather-station"; // Replace by your device label
const char* VARIABLE_LABEL_TO_RETRIEVE_VALUES_FROM = "humidity"; // Replace by your variable label

Ubidots ubidots(UBIDOTS_TOKEN, UBI_HTTP);

/****************************************
* Auxiliar Functions
****************************************/

// Put here your auxiliar functions

/****************************************
* Main Functions
****************************************/

void setup() {
  Serial.begin(115200);
  ubidots.wifiConnect(WIFI_SSID, WIFI_PASS);
  // ubidots.setDebug(true); //Uncomment this line for printing debug messages
}

void loop() {
  /* Obtain last value from a variable as float using HTTP */
  float value = ubidots.get(DEVICE_LABEL_TO_RETRIEVE_VALUES_FROM,VARIABLE_LABEL_TO_RETRIEVE_VALUES_FROM);

  // Evaluates the results obtained
  if (value != ERROR_VALUE) {
    Serial.print("Value:");
    Serial.println(value);
  }

  delay(5000);
}

Did this answer your question?