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 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. It is another great example of the ease of use of Temboo. 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 on board 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 does return 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 in your API key on the Choreo page. For this project I did edit the optional settings so that "HasDefinition" is set to "true" and "MinDictionaries" is set to 5. 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. Go ahead and test it in the web browser and make sure that you receive a random word back. The code provided through Temboo would now be good enough 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. First head over to Wolfram Alpha and sign up for a developer account and obtain an API key. After getting an API key, enter it into the GetSearchResult Choreo and go ahead and search "define _____" filling in the blank with whatever you want and run the Choreo. 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:
Now we will be using the LaunchPad to put all these Choreos to work. Go ahead and download the randomWord.ino and open it in Energia, or copy it and paste it into a blank Energia sketch. This code will require a few changes to get it functioning, but it is already set up to interact with the Educational BoosterPackMKII and the CC3100 WiFi booster pack. Line 153 requires you to enter the profile name under which you saved your Wordnik settings when setting up Temboo. Line 206 requires you to enter your AppID from Wolfram Alpha. After those slight changes, you should be good to go! 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 WiFi 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! I hope you enjoy!
Comments
Please log in or sign up to comment.