For more details you can visit these TempTracker "GitHub WIKI Sites":
- Basic Documentation
- Source folder content description
- Code to be changed in the sample
- Setup steps for the full TempTracker Sample
Table of content of the readme.md
- Introduction for possible UseCase the Topics for the integrated usage of IoT, Bluemix and Mobile
- The objective of the "TempTracker" sample
- The "TempTracker" sample on YouTube
- Environment Prerequisites to use the full TempTracker sample
- Concrete Steps to Setup the full TempTracker Sample
- Known limitations
A alternative Introduction can be found here: A IoT Cloud, Bluemix and MobileFirst Sample – What makes you happy?
0. Introduction for possible UseCases of the topics for an integrated usage of IoT, Bluemix and Mobile
Monitor sensible ware (goods, food, electronics, etc. ) temperature – ware which is stored in special containers that have sensors for location and temperature control.
-
Questions:
- Is the Temperature in critical condition?
- How can I notify the closest service operator or the driver in case of emergency?
-
Objective: Monitor the state of the container and notify on emergency Report a problem if needed with Picture / Comment Get a list of currently available drivers to check the situation
-
Solution: The temperature sensors can be connected and managed over the Bluemix IoT cloud service monitored over a mobile application having the backend running on Bluemix. The mobile application allows feedback (comments and picture) Notifications can be sent via SMS, Twitter, email, voice, etc.
The objective is to help to understand how the integration technical works between:
- Sensor
- IoT Cloud
- Bluemix
- Bluemix Services
- Bluemix Container
- MobileFirstPlatform
The setup is divided in two main steps:
-
Setting up the Bluemix application in Chapter 4.1. The Bluemix application is the important part to get and store the sensor data inside the cloudant database and to integrate the services.
-
Setting up the Mobile application based on MobileFirst in Chapter 4.2. This part is important to have a Mobile application and to use the given data from the sensor on a mobile device, report a problem, take picture ....
Note: Just take a look at the sample UseCases defined in Chapter 0. Feel free to use the parts separately.
On YouTube: IoT Cloud, Bluemix and MobileFirst ... trying to understand https://www.youtube.com/playlist?list=PLUte4WEyMEjU83oQIjqOKIPm35q9I1eZd
Here are the prerequisites you need to setup the environment, to run the full "TempTracker" sample.
This is just an overview for your basic installation tasks. The concrete configuration steps you will find in 4. Concrete Steps to Setup the full TempTracker Sample.
- Get the TI Sensor and connect to IoT Cloud ( https://developer.ibm.com/recipes/tutorials/connect-a-cc2650-sensortag-to-the-iot-foundations-quickstart/ )
- In case you don't have a real Sensor you can use alternative : https://quickstart.internetofthings.ibmcloud.com/iotsensor/ in the upper left corner is the DeviceID you later must use inside Node-RED for the IoT-Node.
- Get a Bluemix Account (https://console.ng.bluemix.net)
- Instantiate IoT Foundation Starter + add Text2Speech service (https://console.ng.bluemix.net/catalog/starters/internet-of-things-foundation-starter/) (https://console.ng.bluemix.net/catalog/services/speech-to-text/)
- Get a Google Maps JavaScript API Key (https://www.google.com/work/mapsearth/)
- Instantiate "ibm-mobilefirst-starter Container – Small 1 GB" (https://www.ng.bluemix.net/docs/images/mobilefirst/index.html)
- Install MobileFirstPlatform CLI on your machine (https://developer.ibm.com/mobilefirstplatform/install/ )
- Install Android SDK(http://developer.android.com/sdk/installing/index.html)
- Create a Virtual Android Device using the avd command ( https://developer.android.com/studio/run/managing-avds.html)
- Install a Editor or IDE on your machine (https://atom.io)
- Install Google Chrome browser to take the advantage of the developer tools (https://developer.chrome.com/devtools)
- Get yourself a Bluemix Account – register at bluemix.net
- Instantiate IoT Foundation Starter (https://www.ng.bluemix.net/docs/starters/IoT/iot500.html)
- Give it a name <>
- After your application is running – click ADD A SERVICE OR API
- Select Text to Speech from the Catalog
- Search for entering “Text to “ in the Search field and click the icon
- Create your Text To Speech service instance
- Click CREATE
- Restage the application
- Instantiate ibm-mobilefirst-starter Container (https://www.ng.bluemix.net/docs/images/mobilefirst/index.html)
- On Bluemix, go to your application and click on the url to open your Node-RED
- Delete the content of the default created sheet by selecting all and DEL
- Copy the ClipboardNodeRed-containsAllNodes.txt content into the Clipboard Either you have it cloned with git or you can get it from git.hub here:(http://bit.ly/1QC39ld)
- Import from Clipboard
- Make changes in yours in the lines marked with CHANGE as comment in code. NOTE: Please use the WIKI link for the detailed instructions: under Node-RED (https://github.com/thomassuedbroecker/TempTracker_IoTBluemixMFPSample/wiki/Code-to-be-changed)
- Change the Text2Speech node to match your Text2Speech service (https://github.com/thomassuedbroecker/TempTracker_IoTBluemixMFPSample/wiki/Code-to-be-changed)
- Change the url in http response for audio, map and cloudant nodes to match your nodeRed http address (https://github.com/thomassuedbroecker/TempTracker_IoTBluemixMFPSample/wiki/Code-to-be-changed)
NOTE: Maybe you have to change the device ID in the Node Check Temperature and create JSON Data of the flow. Because you will use other devices.
And maybe by updates of the TI App the JSON data structure will change. In that case you have to configure your code like this:
if (msg.payload.d.ambient_temp !== undefined) {
temp = msg.payload.d.ambient_temp; // Typical Android datastructure
}
- In your Bluemix Appliction, click the Cloudant service from your application
- Open the dashboard of your Cloudant service by clicking LAUNCH
- Click Create Database
- Create a new database named “my_demo_iot_db” This will simplify your usage of the provided code
- Create new Search Index - use the documentation in ..\TempTracker_IoTBluemixMFPSample-master\tempTrackCloudantConfiguration or (http://bit.ly/1TnfJFv) to do that
- Get the Sensor and connect to IoT Cloud (https://developer.ibm.com/recipes/tutorials/connect-a-cc2650-sensortag-to-the-iot-foundations-quickstart/)
- In case you don't have a real Sensor you can use alternative : https://quickstart.internetofthings.ibmcloud.com/iotsensor/ in the upper left corner is the DeviceID you later must use inside Node-RED for the IoT-Node.
- Configure the IoT-Node in Node-RED using the given DeviceID
- Check the display of the sensor data on http://YOUR_BLUEMIX_APP_URL/map and in CloudantDB
More details about the used Frameworks? Take a look here
- Locally install MobileFirst CLI installer –if you have troubles running the installation directly, here a command line example: install_windows.exe LAX_VM "C:\Program Files\Java\jdk1.8.0_60\jre\bin\java.exe“
- Install an IDE locally – for example Android Studio 1.4 or Atom
- Make sure you have Java JDK, Ant and Android SDK installed and working
- On a Windows System set environment variables: JAVA_HOME
- Set ANDROID_HOME to the installation directory of the Android sdk
- Set Path : add ANDROID_HOME/platform-tools and ANDROID_HOME/tools to your path
- Set ANT_HOME to the installation directory of your ant
- If you want, you can create a new workspace folder for your MobileFirst projects
- Clone the git repository into a local folder, by entering the following commandline: git clone https://github.com/thomassuedbroecker/TempTracker_IoTBluemixMFPSample.git
- Note: you can also download the sources as zip from here: (https://github.com/thomassuedbroecker/TempTracker_IoTBluemixMFPSample)
- Open a command line window in the tempTrackerServer folder and run mfp start command
- In a Browser, check if the server is running: url: localhost:10080/worklightconsole User/password: admin/admin
- In Atom (or another editor) import the projects
- Navigate to ./tempTrackerServer/adapters/ and open CloudantAdapter.xml
- Enter your Cloudant credentials in the marked lines (https://github.com/thomassuedbroecker/TempTracker_IoTBluemixMFPSample/wiki/Code-to-be-changed)
- Save your changes
- Open command line to the ./tempTrackerServer folder
- enter: mfp push local
- In Bluemix go to your MFP Container
- Open MobileFirstConsole to Manage the MobileFirstServer (http://YOUR_CONTAINER_IP:9080/)
- Click Open Console under the Manage on the webpage
- Click Add new Applications or Adapters in the left upper corner in the console
- Add and upload the adapters from folder ../tempTrackerServer/bin - filename.adapter
- Using command line, cd to ../tempTracker directory
- enter: mfp server add
- Enter a name: BluemixServer
- Enter the url of your server (the ip address of the Docker container in Bluemix)
- Enter the login and password
- You will have to register first and choose a password
- Save the password Y
- Context root: worklightadmin
- Note: follow the instructions in code to be changed: (https://github.com/thomassuedbroecker/TempTracker_IoTBluemixMFPSample/wiki/Code-to-be-changed)
- In .. config.xml – change the ip to match your mfp docker
- In … www/template/watsonbrowseroutput.xml – change the url and ip
- In … index.html - change the google api key // you will need to generate a google browser key
- In … www/js/ctrl-realtime-data-output.js – change the url
- Save your changes
- Open a command line window and cd to the ../tempTracker folder (after changes)
- enter: mfp push BluemixServer
- This will push the changes to the MobileFirst Server in the container on Bluemix
NOTE: You can verify the Server Configuration in the config.xml in ./tempTracker/config.xml
The content will be for BluemixServer or the Local MFP Server.
`<preference name="mfpServerUrl" value="http://YOUR_CONTAINER_IP:YOUR_CONTAINER_PORT" />
<preference name="mfpServerRuntime" value="MobileFirstStarter" />
<preference name="displayName" value="temptracker" />
<preference name="mfpManualInit" value="false" />`
or
`<preference name="mfpServerUrl" value="YOUR_LOCAL_IP:10080" />
<preference name="mfpServerRuntime" value="tempTrackerServer" />
<preference name="displayName" value="temptracker" />
<preference name="mfpManualInit" value="false" />`
- In the Android sdk installation directory / start “ADV manager.exe” over command line
- Create new Android Virtual Device and check the emulator is running on your machine.
- Run the emulator using the commandline in the ./tempTracker directory: mfp cordova emulate
- Run as preview in the "Chrome Browser" using the command line in the ./tempTracker directory: mfp cordova preview
NOTE: mfp cordova preview only works with the local server.
Add the MobileQualityAssurance (MQA Bluemix service) to your Bluemix application following the steps in this Guide on Bluemix
Based on the feedback in StackOverflow you only have to do following steps.
-
Download the latest cordova sdk : http://www-01.ibm.com/support/docview.wss?uid=swg27044490
-
In the app directory, MQA plugin: "mfp cordova plugin add [/your_path/to_the/MQA/sdk]"
-
Add follosing code in the /tempTracker/www/js/index.js file, add following MQA code in the wlCommonInit() function:
MQA.startNewSession({ reportOnShakeEnabled: true, mode: 'QA', ios: { appKey: "YOU_IOS_KEY", screenShotsFromGallery: true, }, android: { appKey: "YOU_ANDROID_KEY", screenShotsFromGallery: true, } },{ success: function () {console.log("MQA Session Started successfully");}, error: function (string) { console.log("MQA Session error" + string);} });
Sample usage:
- update geo data
- search data
- get live data
- How to run the App on real iOS device?
If you want to run the app on a real iOS device, you must follow this steps:
-
a) Disable BitCode
-
b) Disable Security take a look here: reason
-
c) Edit the TempTracker-Info.plist under tempTracker/platforms/ios/TempTracker in a editor and add this code:
`NSAppTransportSecurity NSAllowsArbitraryLoads ``
- Photo limitation on iOS
If the photos should be also taken on a iOS device, the module ctrl-photo.js must be enhanced to do that. In this sample Photo is only working for Android.
- Live Message does not work with Safari or the default browser of Android
To get the life messages on the iOS/android devices. The chrome or firefox browser must be installed and defined as the default browser on the android devices. On iOS it will not work, because no other default browser can be configured.
- A Chart does show only maximum 25 data entries
Paging for the Cloudant database is not implemented.
- A Search does show only maximum 25 data entries
Paging for the Cloudant database is not implemented.
- Get sensor data show only 10 entries
Limit is set to 10 for the Cloudant database.