iotapp-connected-sensor [] [] {"id":"connected-sensors","title":"Connected Sensor: Build connected sensors to collect IoT data","displayTitle":"Connected Sensor","metaDesc":"Build a connected temperature sensor with thresholds and notification preferences that can be reprogrammed through a simple web interface.","tweet":"I'm building #IoT applications with connected sensors using @temboo, and you should too!","description":"Build a connected temperature sensor with thresholds and notification preferences that can be reprogrammed through a simple web interface.","device_count":"single","devices":{"arduinoyun":"Arduino Y\u00fan","samsung_artik_ten":"Samsung ARTIK 10","samsung_artik_five":"Samsung ARTIK 5"},"categories":["building-management","farming"],"choreos":{"SendEmail":{"uri":"Library\/Utilities\/Email\/SendEmail","templateName":"UtilitiesEmail","credentialDescription":"Sends an email using a specified email server.","description":"Sends an email using a specified email server.","credentialInputs":[{"name":"Username","type":"string","description":"Your username for your email account.","placeholder":"myUsername@myemail.com","callout":"When you save your email credentials here, you'll be able to use them with any Utilities Email Choreos in the library."},{"name":"Password","type":"password","description":"The password for your email account.","placeholder":"myPassword123"}],"inputs":[[{"name":"FromAddress","type":"string","description":"The name and email address that the message is being sent from.","placeholder":"myUsername@myemail.com"},{"name":"Port","type":"integer","description":"Specify the port number (i.e. 25 or 465).","placeholder":"465"},{"name":"Server","type":"string","description":"The name or IP address of the email server.","placeholder":"myemail.com"},{"name":"Subject","type":"string","description":"The subject line of the email.","placeholder":"Temperature alert email subject","callout":"When the temperature falls outside of the thresholds set through an accompanying web app, an email will be sent."},{"name":"ToAddress","type":"string","description":"The email address that you want to send an email to.","placeholder":"managerUsername@email.com"}]]},"StoreToken":{"uri":"Library\/Utilities\/TokenStorage\/StoreToken","description":"Stores a token.","inputs":[[{"name":"Name","type":"string","description":"The token name associated with the notification email address.","placeholder":"notificationAddress"},{"name":"Value","type":"string","description":"The token value associated with the notification email address.","placeholder":"youremail@email.com","callout":"This email address can be easily changed through an accompanying web app."}],[{"name":"Name","type":"string","description":"The token name associated with the high temperature threshold.","placeholder":"highThreshold"},{"name":"Value","type":"string","description":"The initial high temperature threshold.","placeholder":"100","callout":"This threshold can be easily changed through an accompanying web app."}],[{"name":"Name","type":"string","description":"The token name associated with the low temperature threshold.","placeholder":"lowThreshold"},{"name":"Value","type":"string","description":"The initial low temperature threshold.","placeholder":"0","callout":"This threshold can be easily changed through an accompanying web app."}]]}}}

Build a connected temperature sensor with thresholds and notification preferences that can be reprogrammed through a simple web interface.

We'll show you how you can build it.

Materials
Temperature Sensor
Like this sensor
Breadboard
A PHP web server
Requires PHP 5 (or later)

Connect the power and ground of your board to your breadboard.

When temperature levels are not within the range specified for lowThreshold and highThreshold tokens, an email alert is triggered.

We'll add some smoothing to our data in the final code by looking at the average of the last 100 readings.

Connect the middle pin of your temperature sensor to
Analog

Connect the first pin of your temperature sensor to power, and the third to ground.

Need help running the code?
Need help running the PHP code?

Run your web app

Before we get started, make sure that you've got PHP 5 (or later) and a PHP code editor.

First, copy the downloaded web app files to your PHP server. We used a local Apache server when building this example, and to start that server you run the following command from Terminal:

sudo apachectl start

Once you've got web app files copied to the your PHP server, and the server is running, navigate to the connected-sensor.html page in your browser, using the URL that is appropriate for your development environment. For instance, if you're running the PHP server locally:

127.0.0.1/WebApp/connected-sensor.html

Plug in a value to change one of the thresholds and submit. You should see the message:

Your token has been set.

This means that you've just updated the alerting behavior of your connected sensor. Congratulations! You now have a Connected Sensor that has remotely reprogrammable threshold settings and alert preferences.

Need help?

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

Install for Samsung ARTIK

If this is the first time using Temboo, you'll need to set up your ARTIK board to find the Temboo libraries. To do so, you'll need to create the file temboo.conf in /etc/ld.so.conf.d. Inside of temboo.conf, you'll want to copy the line below and paste it into the file:

/opt/iothub/artik/temboo/temboo_artik_library/lib

After saving temboo.conf, run ldconfig from the command line to add the Temboo library directory to the system library search path.

You’ll also need to get the IP address of your ARTIK board using ifconfig. The example below shows the results when the ARTIK board is connected to the internet through an ethernet cable. The IP address you'll want to use is listed next to inet.

[root@localhost ~]$ ifconfig
eth0: flags=4163  mtu 1500
inet 10.11.6.200  netmask 255.255.255.0  broadcast 10.11.6.255

Run the code

Download and unzip the IoT Application file. In your IoT Application folder, you'll find a Samsung folder containing the ConnectedSensor folder with code for the Artik. Copy the Samsung folder to your ARTIK board using scp. From your computer, go to the directory where the Samsung folder is located and type the command below. Make sure you use the IP address for your board you found using ifconfig.

[root@localhost ~]$ scp -r ConnectedSensor root@xxx.xxx.xxx.xxx:/home

Now cd into the directory on your Artik where you placed the folder and and compile and run your code using the command below.

make

Need help?

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

Install for TI LaunchPad

Open the .ino file with Energia. While the sketch is running, open the Serial Monitor and you should see your app running.

Congratulations! Now that you know how to make your LaunchPad run any Choreo, you're just a few steps away from making something extraordinary.

You can find more examples of how to use Temboo with your LaunchPad here.

Need help?

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

Run the Sketch and rejoice

Save and upload your sketch to the Arduino Yún, and open the serial monitor.

Congratulations! You've just run an IoT Application. With Temboo handling all the small stuff, you're free to think big.

You can find lots of examples of how to use Temboo with your Yún here.

Need help?

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

Running the iOS Application

Make sure you have the latest Xcode, which can be downloaded here.

Download the Code

Download the code at the link above.

Unzip the files where you can find them. You should see one folder containing the iOS code, and another containing the hardware device code.

Open the Xcode Project

Locate the .xcodeproj file in the iOS code. Open the file with Xcode and you should see all of the accompanying files in the Project navigator.

If the file titles in your Project navigator are red, you'll need to relink them by clicking control and selecting "Add Files to ", then select and add all of the files from the iot application folder contained in the iOS folder you downloaded. Control click and delete any of the unlinked files that appear in the Project navigator.

Download the iOS SDK

The latest Temboo iOS SDK can be downloaded here. Save and unzip it to a folder where you can find it.

Once again, you'll need to control-click on the top-level folder in your Xcode Project navigator. Select "Add Files to " and browse to where you saved the Temboo SDK, locate and click on the "core" folder inside the SDK "src" folder. Make sure that "copy items if needed" is unchecked and "Create groups" is selected, then and select "Add".

Repeat the above steps to add the appropriate files located in the SDk's src/library folder.

Run the App

Make sure you have a device selected in the simulator, and click the run button.

Congratulations! You should see the app displayed in the simulator window. Go ahead and try it out, and you should see the Choreo results printed to the console.

Need help?

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