This tutorial will guide you through the steps to setup an IoT Smart Kitchen application on scriptr.io using a Nebula 2.0 board. The Nebula board can be installed on a kitchen appliance and, equipped with the Weather click board by MikroElektronika, it will detect humidity, pressure, and temperature, and send the readings to scriptr.io by going through the IBM Watson IoT DMP (Data Management Platform).

Prerequisites

Hardware

  • Nebula 2.0: make sure you connect your Nebula board to your PC using the USB cable before you start. This is needed to install the nebula20-watson app on it using WICED Studio.
  • Weather click: install the Weather click board on your Nebula board. The Weather click from MikroElektronika is used in this tutorial to read environmental data. If you use a different sensor board, make sure you modify the Nebula application accordingly using WICED Studio.

Software

  • WICED Studio: you need to download and install the WICED Studio by Cypress, and use the 43xxx_WiFi project to build the Nebula 2.0 application as described later in this guide.
  • You need to install a terminal tool such as Tera Term or CuteCom (115,200bps, n, 8, 1) in order to connect to your Nebula device and see the output.

Step by Step Instructions

  1. Registering for a free scriptr.io account with the nebula20 promo code

    Navigate to https://www.scriptr.io/register?promocode=nebula20 and follow the registration instructions to register to scriptr.io using the nebula20 promotion code. This will automatically install the Nebula Smart Kitchen app on your account.

    Alternatively, if you would like to use your existing scriptr.io account, you can import the app from its GitHub repository and run the installer (refer to its Readme.md file for more details). Then go to Install Module… by clicking the arrow next to New Script and install the underscore.js module.

  2. Installing the Nebula 2.0 Smart Kitchen app using WICED Studio

    In this step, you will install the nebula20-watson app on your Nebula board so that it can send the Weather click sensors data to IBM Watson IoT.

    1. Clone the nebula20-watson repository.
    2. Copy the cloned repository code into your 43xxx_Wi-Fi WICED Studio project. This repository already contains the NEB1DX_02 platform and the BME280 sensor libraries, which means that you don’t have to worry about importing them into your project.
    3. Configure your Nebula board to connect to your local WiFi network as follows:
      1. Open the apps/nebula/watson/wifi_config_dct.h file
      2. Set the CLIENT_AP_SSID constant to your WiFi SSID
      3. Set the CLIENT_AP_PASSPHRASE constant to your WiFi Network Security Key
      4. Save
    4. Now you need to set the MQTT topic and Client ID to be used with IBM Watson IoT Quickstart. For that, follow the below steps:
      1. Log in to your scriptr.io Workspace using the credentials you used to register in step #1 above
      2. Copy the Token provided to you in your landing page in step #1.4.1
      3. Go back to WICED Studio, and open the file apps/nebula/watson/watson.h
      4. Replace <TOKEN> in the PUB_TOPIC constant value with the Token you copied from your scriptr.io Workspace
      5. Replace <TOKEN> in the CLIENT_ID constant value with the Token you copied from your scriptr.io Workspace
      6. Save
    5. Generate a new build target as follows:
      1. Right-click the 43xxx_Wif-Fi project folder
      2. Select Make Targets > Create…
      3. Set the Target name to “nebula.watson-NEB1DX_02 download download_apps run”
      4. Click OK
    6. In the Make Target window, double-click the new make target you created in the previous step in order to build it. This will install the app on your Nebula board.

    Check your terminal program to the results.

  3. Sending data to IBM Watson IoT

    Now that you’re all set, let’s start sending the data to IBM Watson IoT:

    1. On your Nebula board, press Button 1, this will trigger a message to be sent to IBM Watson IoT. The message will have a payload similar to the one below:
      {"parameters": {"p": 94465.42,"h_unit": "%","p_unit": "Pa","t": 28.41,"h": 52.71,"t_unit": "°C"}}
    2. If you would like to check the data on IBM Watson IoT Quickstart, follow the below steps:
      1. Navigate to the IBM Watson IoT Platform Quickstart page: https://quickstart.internetofthings.ibmcloud.com
      2. In the Device ID, enter the Token as retrieved from your scriptr.io Workspace above, prefixed by nebula20
      3. Click Go

    You should now be able to see the data packets on Watson IoT Quickstart.

  4. Running your IoT application in scriptr.io

    To run your application, all you need to do is:

    1. Go to your scriptr.io Workspace.
    2. From the tree on the left, navigate to smartkitchens/view/html/index.html and double-click it open it in the editor.
    3. Click View to view it in your browser (the default credentials are demo / demo).

    You should now see your device on a default location on the map (which you can change from smartkitchens/config/config by modifying the lat/lon values under the nebula20 device). Zoom in on the device and click its icon, you will see the sensors readings. Press Button 1 on the Nebula board to see the values change instantaneously.

    map

    You can click View Dashboard to go to a dashboard showing several charts, including time series charts showing the variations over time:

    dashboard

    You can also click View Alerts in order to see the warnings logged whenever a value exceeds a certain preset threshold:

    alerts

    Thresholds are set as rules in the Rules Designer which  you can access from the left side bar:

    rules

    Here you can set several rules for each of the sensors values, i.e. temperature, humidity and pressure, which are listed in the first column of the rules designer. As you can see, in the “Rule 1” column, the first row (temperature row) reads “>8”, meaning that whenever the temperature is great than 8, an email notification is sent to the user, as indicated in the sendEmail row, and an alert is logged, as indicated in the last row corresponding to the isAlert row when set to true. Similarly, “Rule 2” means than an email alert is sent to the user whenever the humidity is greater than 30; and so on…

    In order to set the recipients of the alerts, click on the user icon on the top right corner of the screen and select Notification Settings. This will open a form allowing you to enter a comma-separated list of email addresses to receive the email alerts:

    notification-settings

  5. Going Forward

    Scriptr.io allows you to reduce the time to market of your IoT applications by accelerating your development pace, thanks to a plethora of API and visual development tools, such as our dashboard builder, our decision table editor, and the multitude of tools at your disposal in the Workspace. You can also find a long list of demo applications / modules / connectors under our GitHub account.

    This app’s code can be found in your Workspace under the smartkitchens folder, so you can modify it as you see fit. You can check out the Readme file under the app’s folder to learn more about it.

    For a deeper dive in scriptr.io, we suggest to check our one-page documentation and our how-to guides.

    Finally, if you have any questions or feedback, we’d love to hear from you at support@scriptr.io.