TP5 Manage a temperature sensor with iOt Goal : Using a virtual sensor to analyse temperature data. This sensor is an object which you can reach through internet. this exercise is just an approach of iOt (internet of things). Some real sensors can be used for this work. An Arduino Uno can be set to work with example. Rules : When temp is below or equal to 15°C, an email must be sent to signal that it’s cold. When temp is higher or equal to 25°C, an email must be sent to signal that it’s hot. You can try with some SMS on your smart phone. Remenber process to start : 1. Create an node.js web app based on boilersplates. 2. Choose nodeRed as boilersplates, and add a UNIQUE name to your app 3. Launch nodeRed editor You can find a virtual sensor at this address : https://quickstart.internetofthings.ibmcloud.com/iotsensor/ Requirements with nodeRed :





Be careful : to understand specs of each nodes, you must read informations in nodeRed editor (on the right, info panel), or search informations with Google.

Sébastien Gagneur – Bluemix – IBM - 2015

1

HTTP or HTTPS with nodeRED :

you can add a username and a password to a user. At this time, you must use HTTPS (443) to access the flow editor. WARNING : Behind a proxy (pfsense), use https://noderedapptest.mybluemix.net/red/ instead of http://noderedapptest.mybluemix.net/red/ to avoid a problem of connect. Please test and report, if needed : [email protected] 1. Add a ibmiot node :

Copy and paste the sensor id (from quickstart page), inside of configuration panel of the node :

Sébastien Gagneur – Bluemix – IBM - 2015

2

Check output on debug’s panel :

Don’t forget to deploy your app, on each change :

the JSON data are immediately available. Temp : air temp Humidity : air humidity objectTemp : object’s surface temperature 2. Put a delay to the flow

Sébastien Gagneur – Bluemix – IBM - 2015

3

this node can rate limits messages. Set one message per minute. 3. Write javascript code :

Set a function for testing temp. In this case, if temp >= 25, you must send « hot », if temp <= 15, you must send « cold ». Java Script example : var temp = msg.payload.d.temp if (temp >= 25) … 4. Switch temp function output

The switch node can take only two values : « hot » or « cold » 5. Check out your mailbox ! Send alerts to your email box and enjoy !

Sébastien Gagneur – Bluemix – IBM - 2015

4

The other messages are not sent to your email box. 6. Improve user experience When you’ll have finish, play around to improve this app. 7. Transform your cellular phone as a connected device to iOT A. Overview : You can install an app on your device, from a github repository. This method is not explain in this paper sheet. https://quickstart.internetofthings.ibmcloud.com/#/ B. Try this sample app : Without install an app you can test accelerometer and gyroscope from your device. https://developer.ibm.com/recipes/tutorials/mobile-devices/ Try it from your device, because if you want to test this app with a desktop computer, you must have an accelerometer on the mother board !!!

http://www.ibm.com/cloud-computing/bluemix/solutions/iot/

Sébastien Gagneur – Bluemix – IBM - 2015

5

C. Click play button : 1. Select your device : Choose smart phone !

2. Enter an unique smart phone ID :

Sébastien Gagneur – Bluemix – IBM - 2015

6

3. View live data from your smart phone :

4. Go to https://ibm.biz/BdHx37, to read raw data :

5. Meanwhile, previous page offers visualisation of the published messages :

Sébastien Gagneur – Bluemix – IBM - 2015

7

6. See more details from your device : Click on the following button :

Accessing to all informations about your device :

7. Deploy : You can deploy your app into bluemix.

Sébastien Gagneur – Bluemix – IBM - 2015

8

Click on Try, and follow instructions 8. That’s all !

Sébastien Gagneur – Bluemix – IBM - 2015

9

BM-TP5-temperatureSensor.pdf

Sébastien Gagneur – Bluemix – IBM - 2015 1. TP5. Manage a ... You can try with some SMS on your smart phone. Remenber ... BM-TP5-temperatureSensor.pdf.

634KB Sizes 1 Downloads 197 Views

Recommend Documents

No documents