Other Parts Discussed in Post: ENERGIA

I hate to admit it, but one of my biggest weaknesses is my vocabulary.  What better way is there to try and improve my vocabulary than with an interactive Internet of Things (IoT) device?  This project uses Texas Instruments hardware and services provided by Temboo, Wordnik, and Wolfram Alpha to retrieve and display a random word, then show the definition utilizing the built-in LCD screen on the Educational BoosterPack™ MKII.  In this example we will be using two different API calls in the same project to really show the breadth of Temboo.  The best part is since this project uses API calls and Wordnik's database, there is no onboard memory dedicated to storing a dictionary, and the list of words that can be retrieved is almost endless!

Temboo Set-up:

At this point I have used Temboo for a few projects, and it makes interacting with APIs so seamless and easy.  Even when interacting with two APIs in the same program, there were not any unforeseen speed bumps.  We will be using the Wordnik RandomWord Choreo in order to retrieve a random word and then pass this word to the Wolfram Alpha GetSearchResult Choreo.  Because these are two different services, there is not always a Wolfram Alpha definition for the Wordnik word, but most of the time it returns a definition.

Wordnik:

Wordnik is "world's biggest online English dictionary, by number of words" so what better resource is there to use when trying to learn new words?  Go ahead and get set up with a Temboo account if you have not done so already.  I go into a little more detail around the actual Temboo set up here if you run into any issues.

We will be using the RandomWord Choreo under the Words subsection of the Wordnik Choreos.  Running this Choreo will require signing up with Wordnik and getting an API key. Once you get an API key, the Chore set up is very easy.  Enter your API key on the Choreo page.  For this project I edited the optional settings so that "HasDefinition" is set to "true" and "MinDictionaries" is set to five.  This was in an attempt to maximize the number of words for which Wolfram Alpha would have a definition.

Once these settings are entered, the Choreo should be good to run.  Test it in the web browser and make sure that you receive a random word back.  The code provided through Temboo will now be able to retrieve a random word, but we want to do more with it.  Make sure to save your Wordnik profile with Temboo with a memorable name as you will need it later.  If you look at the randomWord.ino at the bottom of the page, you can see the process of parsing out the random word and then actually passing it to the Wolfram Alpha Choreo, which we set up in the next step.

Wolfram Alpha:

We will be using the GetSearchResult Choreo from Wolfram Alpha, which returns the first search result for a query as text.  Sign up for a developer account with Wolfram Alpha and and obtain an API key.  After getting an API key, enter it into the GetSearchResult Choreo and search "define _____," filling in the blank with the word.  Assuming Wolfram Alpha has a definition it should return the result to you in a text format.  Again take a look at randomWord.ino  and see how we parse out the first definition returned and pass it to the main function.

Setting up the LaunchPad™ development kit:

Now we will be using the LaunchPad kit to put all these Choreos to work.  Download the randomWord.ino and open it in Energia. This code will require a few changes, but it is already set up to interact with the Educational BoosterPack MKII and the SimpleLink™ Wi-Fi®CC3100 BoosterPack.  Line 153 requires you to enter the profile name under which you saved your Wordnik settings in Temboo. Line 206 requires you to enter your AppID from Wolfram Alpha. Trace through the code and see that when the user presses the S1 pushbutton on the BoosterPack, Temboo is triggered to retrieve both the random word and the definition.  When the user then presses S2, the definition replaces the word.  There are a few functions in the code as well to help with printing to the LCD such as midPrint which simply prints to the middle of the LCD screen and wordWrap which starts in the top left and prints line by line (it will continue to print off the screen if the definition is too long however).

Make sure you also have your TembooAccount.h in your Energia library folder and set up to match your Temboo and Wi-Fi credentials!

Once you have this project up and running you will be learning new words that you can work in casual conversation and impress everybody in no time!

Anonymous