Hardware

Create Temperature Sensor Data Graphs with Temboo


Monitor sensors with Cloud Controls

In this tutorial we'll show you how to use Temboo's Data Visualization tools to graph temperature sensor data in your browser. Here's what we'll cover:

  • Setting up the Texas Instruments LMT84 temperature sensor
  • Auto-generating sensor monitoring code
  • Accessing your sensor data graph
  • Triggering email alerts with your temperature sensor

Monitoring Sensor Data

Before You Start

1You'll need a free Texas Instruments account to use their online IDE, CCS Cloud. You can sign up here.

2If you haven't already done so, prepare your board for making secure connections by following our Setting up CC3220 for SSL tutorial.

3Log in to Temboo. If you don't already have an account, you can sign up for free.

Set Up Your Sensor

1Once you're logged in, go to our code generation tool and find the Gmailv2 > Messages > SendMessage Choreo. A Choreo is a cloud-based process that connects your CC3220 to any web-based service, and every Temboo application is associated with at least one Choreo.

2Use the dropdown menu at the top of the Choreo page to select a CC3220 board as your device.

Selecting a CC3220 board on the Choreo page.

3The first step in monitoring sensor data is to set up the sensor you wish to monitor. We provide unit converted data for specific sensor models, such as Celsius and Fahrenheit for temperature sensors. We also support unconverted data which is reported as raw values for analog data and high/low for digital.

For this tutorial we're going to read temperature data from a Texas Instruments LMT84P. Our unit conversion formula assumes that your temperature sensor is connected to your CC3320's 5V pin for its voltage in, and set up as specified in the sensor's data sheet.

Using the virtual pin board on the Choreo page, select pin 60 to set up your sensor. Select the category 'Temperature', then choose the Texas Instruments LMT84LP.

Setting up a pin on the virtual pin board

4Now that you've selected your sensor, Temboo will give you a choice of unit conversions—we'll use Fahrenheit.

Each time you set up a sensor you'll be asked to specify the safe bounds and the caution bounds. These bounds are used to determine the color coding of the data that appears on your graph. Safe data is colored green and data near the bounds is orange. Data outside the bounds is red.

Set the safe bounds as 40º and 45º, and the caution bounds as 5º. That's all we need to do to set up our sensor, so press Save.

5We will focus on getting sensor data graphs running first. In part 2 of this tutorial, we will set up the email alert. So for now, set a condition based on that sensor so that it doesn't trigger the email. Use the conditions interface to set a condition that will always be false so we don't send any emails.

Setting a condition

Generate your code

6Next, we'll generate the code that will send our sensor data to Temboo. Scroll down and find the code box. Click the triangle next to Simple Code to open the code menu, and choose Enhanced Code.

Selecting Enhanced Code

7Now you will register your device. To do so, name your device and, optionally, give it a description. Specify the device location—this will allow you to view your devices on a map. For testing purposes, it's good to set a relatively short sensor interval so that you can see sensor data populate your graphs quickly. You can use the custom interval option for this. Press Save when you're done.

Device registration on Temboo

Run your code

8Click the "Send to CCS Cloud" button to the right of your generated code. Name your application, then click Send. Click the link that appears to visit the CCS Cloud IDE in your browser.

Sending code from Temboo to CCS Cloud

9Plug your CC3220 board into your computer via USB. Select its USB connection in CCS Cloud via the Target > Connect COM port... menu.

10Now, run the code on your CC3220 from CCS Cloud.

Running your code on your CC3220 board from CCS Cloud

View your sensor data graph

11Now that the code is running on your CC3220, keep this Choreo page open, and save it for later to use with part two of this tutorial. Open a new browser window to head over to your Devices page to see it in action. A virtual representation of your device will be waiting for you.

Temboo Devices Dashboard

12Select your new device and you'll see a sensor data graph for the sensor that you set up. Over time, you'll be able to see sensor data graphs for various time periods. Additionally, at any time, you can request the latest value of your sensors. This is a handy feature for when you're between sensor intervals but want to know what's happening on your device.

Single device view

That's it! You now know how to monitor sensor data with Temboo. Follow along with part two of this tutorial to add email alerts triggered by sensor values to your new application.

Need help?

We're always happy to help. Just email us at support@temboo.com, and we'll answer your questions.

Triggering Emails with your Temperature Sensor

Triggering the Email Alert

The application we just built in part one of this tutorial successfully graphs temperature data on Temboo. Now let's make it do a little more. We're going to set up the code to use temperature data to trigger the CC3220 to send an email via Gmail. As we discussed in part one, a Choreo is a cloud-based process that connects your CC3220 to any web-based service, and we'll be looking specifically at the Gmailv2 > Messages > SendMessage Choreo. However, the process for setting a Choreo Trigger condition is the same for any Choreo.

Get set up with Gmail

Gmail uses OAuth authentication. This short video demonstrates how to use our OAuth Choreos, and it's a good idea to take a break and watch it now before you dive into this step.

1You'll need a Google account. If you don't already have one, you can sign up here.

2Login to Google's Developer Console, and create a new Project if you haven't done so already.

3Using the API Manager, enable API Access for the Gmail API in the Overview tab.

4Under the Credentials tab, create a new Client ID and specify Web application for the Application Type. When configuring the Consent Screen, you must fill out the Email Address and Product Name fields. Save the Consent screen details.

5Specify this callback URL as the Authorized Redirect URI:

https://ACCOUNT_NAME.temboolive.com/callback/google

6 Go to the Google > OAuth > InitializeOAuth Choreo page and specify the Client ID from the app you registered at Google and at least one of the following Scopes:

https://www.googleapis.com/auth/gmail.modify
https://www.googleapis.com/auth/gmail.readonly
https://www.googleapis.com/auth/gmail.compose
https://mail.google.com/

7Run the Choreo by clicking the Generate Code button. The InitializeOAuth choreo will return an authorization URL and a callback ID (required for the FinalizeOAuth step).

8Open a new web browser window, navigate to the authorization URL returned by the InitializeOAuth Choreo, and click Accept to grant the app access to your Google account.

Google OAuth Accept

9Run the Google > OAuth > FinalizeOAuth Choreo, specifying the callback ID returned earlier by the InitializeOAuth Choreo. This process will return a Refresh Token which can be used along with the Client ID and Client Secret to authenticate with Google. You'll need these for the next step.

Fill in the Choreo Inputs

10Go back to the browser window you saved earlier where we set up our device using the Gmail2 > Messages > SendMessage Choreo. Supply the ClientID, ClientSecret, and RefreshToken you just obtained from the OAuth process.

11Fill in the From address with the email address of the Google account you authenticated in your OAuth steps above. Supply the email Subject and MessageBody. In To, enter the address of the email's recipient.

Supplying inputs to the Gmail Choreo

12Test your Choreo inputs by clicking Generate Code. You should see a success message on the page, and if you emailed yourself, you'll find a new message in your inbox.

Setting Up the Choreo Trigger

When we set up the temperature sensor in the first part of this tutorial, we were given the ability to specify a condition based on our sensor value that would trigger our Choreo to run. We then set it to prevent our Choreo from ever running, but now let's set it so an email alert is sent whenever our temperature reading is too high.

13We want the CC3220 to send an email if the temperature value is higher than 50ºF, so click the operator dropdown menu and choose the greater than sign, and change the number to 50. We can also set how many times we want our email to send in the event that the condition is met—this helps prevent sending too many alert messages.

Setting a condition to trigger an email alert

Run your code

14Send your updated code to CCS Cloud again by scrolling down to the code box and clicking the Send to CCS Cloud button. This time, give your application a different name than the first version, and click Send.

View your sensor data graph & receive alerts

15With your new graphing application on your CC3220, you'll still find your device graphs on the Devices page. Now, whenever your temperature sensor reads a temperature higher than 50ºF, your CC3220 will send an email alert.

What's next?

Congratulations! You've just created a robust application complete with sensor data monitoring and email alerts, all without writing any code. Now that you know how to connect your CC3220 to the cloud with Temboo, you're just a few steps away from making something extraordinary. With Temboo handling all the small stuff, you're free to think big.

The principles introduced in this tutorial are applicable to any Choreo in our library and any combination of sensors. Why not explore our Choreo Library and start planning your next project? Or, try one of these tutorials:

Need help?

We're always happy to help. Just email us at support@temboo.com, and we'll answer your questions.


Back