Tag Archives: Energia

Send Notification from TI CC3200 Launchpad to Iphone4s using “If This Then That”

IFTTT or If This Then That provides a way to interact two web services in a “If This Then That” condition. The two web services that are paired up at IFTTT are called recipe.

At IFTTT setting both web services to work together are like cooking the web service ingredients to become one recipe.

Here are some recommended recipes from IFTTT:

  • Tweet your Facebook Status Updates
  • Save your new Instagram photos to Dropbox
  • Rain Tomorrow? Get notification
  • Save new texts your receive in a Google Spreadsheet
  • Get an email if there will be rain in your area tomorrow
  • Mute your phone when you arrive at work
  • Unmute my phone when I get home
  • Get Notified with your Teams Final Score
  • Document your daily activity in a Google Spreadsheet
  • Every day at 6 AM, add today’s weather report to my calendar

I am going to use TI Adrian Fernandez guide on “how to trigger an event with the Texas Instruments LaunchPad & the IFTTT Maker Channel”. From the guide, what is used is, MSP-EXP432P401R LaunchPad and CC3100 Wi-Fi BoosterPack from Texas Instruments. What I will use instead is TI CC3200 Launchpad. Using Energia Sketch I will just need to set the target board to “Launchpad w/ cc3200EMT (80MHz)”.

The ingredients for this IFTTT recipe are Maker Channel and Boxcar 2.

ifmthbsmall

The Maker Channel enables you to connect IFTTT to any microcontroller board that can make or receive a web request.

Boxcar 2 is an app, that provides notifications to your mobile phone. It provides services similar to Pushover and Parse Push Notifications.

I upload the Energia Sketch Project to my TI CC3200 Launchpad and run it.

Tera Term Output:

ifttt

Notification at my Iphone4s:

IMG_0238

Upon pressing the Notification, Boxcar App opens showing the Notification contents:

IMG_0239

Advertisements

Post Updates to Twitter from TI CC3200 Launchpad Using Temboo Choreo and Energia Sketch

Here is YouTube video below after I have copied the Temboo Choreo code to Energia and build without errors.

Requirements to post updates to Twitter from CC3200 Launchpad:

  1. You need a Temboo account. If you don’t have one yet, you can register for free here.
  2. Get the latest version of Energia Sketch here.
  3. Twitter account.
  4. A TI CC3200 Launchpad.
  5. A WiFi internet connection.

Register your Application at Twitter:

  1. You need to register your application at Twitter here.
  2. At the “Create and Application” page, enter your Application Name and Description at the corresponding fields. At the Website field, enter https://www.temboo.com/oauth_helpers/confirm_twitter/.
  3. Agree to the “Developers, Rules of the Road”, and then finish creating your Twitter Application.
  4. In order to post Tweets to Twitter, set Permissions to either Read and Write, or Read, Write and Access direct messages.
  5. At the Key and Access Tokens tab, generate your Access Token.
  6. Copy your Twitter Application Access Token, Access Token Secret, Consumer Key, and Consumer Secret.

Auto-Generate your Launchpad Energia Sketch Code from Temboo:

  1. Log in to Temboo, and go to Twitter->Tweets->StatusUpdate Choreo Library.
  2. Turn the IoT Mode switch to ON, and select Texas Instruments Launchpad from the drop down menu. Also, at “How is it Connected” drop down menu, select TI CC3200 Launchpad (Wifi) and provide the details of your WiFi internet connection.
  3. Enter your Twitter Application Access Token, Access Token Secret, Consumer Key, and Consumer Secret at the Input fields.
  4. Click “Run” to test the Twitter->Tweets->StatusUpdate Choreo. If there are errors after the test, means that you have a wrong value at the input fields. If pass, your C codes below are good to be copied into Energia Sketch. (YouTube video after step 4 is shown at the top of this post)

CC3200tembootwitter.c Energia Sketch code.

//CC3200tembootwiter.c

#include <WiFi.h>
#include <WiFiClient.h>
#include <Temboo.h>
#include "TembooAccount.h" // Contains Temboo account information

WiFiClient client;

int numRuns = 1; // Execution count, so this doesn't run forever
int maxRuns = 1; // Maximum number of times the Choreo should be executed

void setup() {
 Serial.begin(9600);
 
 int wifiStatus = WL_IDLE_STATUS;

 // Determine if the WiFi Shield is present.
 Serial.print("\n\nShield:");
 if (WiFi.status() == WL_NO_SHIELD) {
 Serial.println("FAIL");

 // If there's no WiFi shield, stop here.
 while(true);
 }

 Serial.println("OK");

 // Try to connect to the local WiFi network.
 while(wifiStatus != WL_CONNECTED) {
 Serial.print("WiFi:");
 wifiStatus = WiFi.begin(WIFI_SSID, WPA_PASSWORD);

 if (wifiStatus == WL_CONNECTED) {
 Serial.println("OK");
 } else {
 Serial.println("FAIL");
 }
 delay(5000);
 }

 Serial.println("Setup complete.\n");
}

void loop() {
 if (numRuns <= maxRuns) {
 Serial.println("Running StatusesUpdate - Run #" + String(numRuns++));

 TembooChoreo StatusesUpdateChoreo(client);

 // Invoke the Temboo client
 StatusesUpdateChoreo.begin();

 // Set Temboo account credentials
 StatusesUpdateChoreo.setAccountName(TEMBOO_ACCOUNT);
 StatusesUpdateChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
 StatusesUpdateChoreo.setAppKey(TEMBOO_APP_KEY);

 // Set Choreo inputs
 String AccessTokenValue = "xxxxxxxx";
 StatusesUpdateChoreo.addInput("AccessToken", AccessTokenValue);
 String AccessTokenSecretValue = "xxxxxxxx";
 StatusesUpdateChoreo.addInput("AccessTokenSecret", AccessTokenSecretValue);
 String ConsumerSecretValue = "xxxxxxxx";
 StatusesUpdateChoreo.addInput("ConsumerSecret", ConsumerSecretValue);
 String StatusUpdateValue = "Tweet! Tweet! from Markel's TI CC3200 Launchpad!";
 StatusesUpdateChoreo.addInput("StatusUpdate", StatusUpdateValue);
 String ConsumerKeyValue = "xxxxxxxx";
 StatusesUpdateChoreo.addInput("ConsumerKey", ConsumerKeyValue);

 // Identify the Choreo to run
 StatusesUpdateChoreo.setChoreo("/Library/Twitter/Tweets/StatusesUpdate");

 // Run the Choreo; when results are available, print them to serial
 StatusesUpdateChoreo.run();

 while(StatusesUpdateChoreo.available()) {
 char c = StatusesUpdateChoreo.read();
 Serial.print(c);
 }
 StatusesUpdateChoreo.close();
 }

 Serial.println("\nWaiting...\n");
 delay(30000); // wait 30 seconds between StatusesUpdate calls
}

TembooAccount.h Energia Sketch code:

/*
IMPORTANT NOTE about TembooAccount.h

TembooAccount.h contains your Temboo account information and must be included
alongside your sketch. To do so, make a new tab in Energia, call it TembooAccount.h,
and copy this content into it. 
*/

#define TEMBOO_ACCOUNT "xxxxxxxx" // Your Temboo account name 
#define TEMBOO_APP_KEY_NAME "myFirstApp" // Your Temboo app name
#define TEMBOO_APP_KEY "xxxxxxxx" // Your Temboo app key

#define WIFI_SSID "xxxxxxxx"
#define WPA_PASSWORD "xxxxxxxx"

/* 
The same TembooAccount.h file settings can be used for all Temboo sketches.

Keeping your account information in a separate file means you can share the 
main .ino file without worrying that you forgot to delete your credentials.
*/