S3A7 with Smart Chef Demo – Quick Start Guide

Overview

 

This tutorial will show you how to get started with the Synergy S3A7 IoT Fast Prototyping Kit which includes the Renesas Synergy S3A7 MCUs and Renesas IoT Sandbox and IoT workflows.  The kit is preloaded with a Smart Chef IoT demo.  

In this Quick Start Guide, you will:
  • Send air quality, temperature, touch screen, proximity, and vibration data from the S3A7 board to the cloud
  • Visualize the data on a mobile app and web dashboard
  • Receive email, push and board notifications
  • Explore workflows that process alerts, serve a recipe and more!
Here’s what you need to get started:
  1. Synergy S3A7 IoT Fast Prototyping Kit
  2. Optional: Digilent GPS Pmod  (Order here)
  3. Optional: Grove connector for GPS (Order Here)
  4. WiFi Internet access (2.4GHz)
  5. iOS or Android phone mobile app (Download here)
  6. Smart Chef .srec file, if not already programmed on the board (Download – Last Updated Feb 7 2017)
The Synergy S3A7 IoT Fast Prototyping Kit includes:
  • Renesas’ Synergy S3A7 module which supports 4 PMOD headers, and is flashed with the Smart Chef IoT Demo.
  • Onboard Qualcomm GT202 WiFi module for Internet connectivity
  • Onboard New Haven 2.4” LCD
  • J-Link Lite Cortex-M 9-Pin
  • AMS Environmental Sensor Pmod module
  • Bosch Motion Sensor Pmod module
  • USB Battery and Cable
  • USB Thumb drive
  • The kit also includes a free subscription to Renesas’ IoT Sandbox for real-time data stream processing
  • Mobile App
Prerequisites:
Afterwards:  Build an IoT Solution ! ! !

After you’ve completed the S3A7 IoT Fast Prototyping Kit, go to our Smart Garage Monitoring Quick Start Guide and BUILD an actual IoT solution using this kit!

 

Step 1: Program the Smart Chef App

If you received a S3A7 kit pre-programmed with the Smart Chef application, you can skip this step and go to step 2. Otherwise, program the Smart Chef image to the S3A7 board following the instructions in the “How to flash the S3A7 board” tutorial. Be sure to download the latest release .srec file that is specific to this kit.

 

Step 2: Activate Kit in Renesas IoT Sandbox

Click here to activate the kit and complete the registration process to create a Renesas IoT Sandbox account preloaded with the Smart Chef IoT demo workflows.  Important note: Workflows were last updated November 19, 2016.  If you activated your kit prior to that date, we recommend you activate a new project again to get the latest workflows.

Note: Be sure to use the activation link provided in this guide because it will create specific Renesas IoT Sandbox workflows for this demo.  If you already have a Renesas IoT Sandbox account, a new project will be added to your account for this demo.

Once activation is completed, you will receive an email with your account credentials needed to provision the kit and access the cloud portal.  

This email will include your:

  • Renesas IoT Sandbox web login
  • API Key
  • Device username and password

 

Step 3: Connect the S3A7 kit to the Cloud

Note: The S3A7 kit only works with 2.4GHz wifi

Provision the Board for WiFi and Renesas IoT Sandbox API:

  • Power up the board by connecting the white microUSB cable found inside the white box into J1 on the board, and then either power with the external battery in this box or by connecting to the USB port to a laptop.  Touch the screen within 10 seconds of powering up the board to boot it up in provisioning mode and the board will become a WiFi Access Point.

smartchefblog

  • When you see the screen below, connect to the board from a computer via the WiFi network printed at the top of the screen.  This is a Wifi Access Point served by the board and is a unique SSID.  Important: Lenovo and Dell laptops running Microsoft Windows consistently face trouble connecting with Wireless Module. MacBook, on the other hand, shown no issues so far. If you’re not using MacBook, your best bet is to use your mobile phone. Note: Keep a copy of your activation email readily available.  Once connected to the board’s Wifi Access Point, you will not have internet access on your computer or mobile device.
  • file_000-2
  • Once connected, click on the link at the bottom of the activation email you received in step one. This autofills the following form with the configuration details specific to your project. Alternatively, you can open the provisioning page served by the board by going to  http://192.168.3.1 on your browser and manually enter the information yourself.  

  • On the provisioning page, enter the WiFi information from your home or office network (the router which will be linked to the board). You will need to specify the router’s WiFi authentication mode.  If you’re not sure, most Wifi routers use WPA2 so try that first.  The other possible Wifi authentication modes are Open (non secure), WEP with 40 or 128 key, and WPA.
  • NOTE:  This is NOT the information from the board’s WiFi Access Point.

screen-shot-2016-10-01-at-7-28-58-pm

  • If you did not use the hyperlink in the email, manually enter the Renesas IoT Sandbox API credentials emailed to you when you activated the kit in Step 2.
  • After entering the information, click Connect.  This will automatically exit out of provision mode and you will see a “Provisioning complete” screen.

 

Step 4: Connect the Sensors to the board

Connect the Grove cable to the AMS sensor as follows.

img_2920

Connect both the AMS and Bosch sensor to the board as follows.  Note the option GPS PMOD.

fullsizerender-7-300x247

Note: Make sure the Grove connector ejection clip is seeded to ensure that it is properly connected. If you don’t get any sensor data in Step 5, this connection may be loose.  See next section Sensor Readings to determine how to check for sensor data.

Note: The GPS sensor is optional. You can order it here and a Grove connector here.

Power up the board (by either unplugging and replugging the USB cable or pressing the small white button to the right of the screen) and boot it up in Smart Chef mode (by waiting 10 seconds).  A Green LED above the screen means that the WiFi is successfully connected.  If the green light does not appear, the board is unable to connect to Wifi.  Try the previous step again to ensure the correct Wifi information is entered. You may have specified an incorrect Authentication Mode for Wifi.

It will take a few seconds to connect to Wifi and the cloud, once connected your board screen should look something like this.

img_2927

Sensor Readings

  • The board will read the sensor data from the AMS once every 10 minutes.
  • The vibration sensor sampling period is configured to once every 10 minutes.
  • If available, the GPS sensor will sample once every 10 minutes.
  • Sensor data can be viewed in the Real Time Events Log (by selecting the Real Time Events Log widget in the Dashboard).  If sensor data for temperature, humidity, vibration, etc. is TRUE, then sensor data is not being received.  Sensor data is being received when these values are a number.  If you are not seeing numbers (e.g. “vibration”: 0.056789), then your sensor might not be plugged in all the way.

Note: See appendix on how to change the sampling rates.

Note: Regardless of whether the GPS sensor is attached, the Renesas IoT Sandbox workflow will look up the location and weather information based on the IP address of the board.  This location is only accurate up to the city level.

If the board is successfully connected, you will observe the IP address, Sensor readings and Location information printed on the board display.  All data printed on the board is sent from a Workflow from the Renesas IoT Sandbox. If the location of the board cannot be detected from the IP Address then it will show ‘unknown’.

Note: Each time the board powers up, you will receive an email Smart Chef Alert!

 

Step 5: Visualize Data On Dashboard

Login to Renesas IoT Sandbox with your web credentials.  Note: If you have more than one Renesas IoT Sandbox project, make sure you select this project in the top right drop down.  After selecting your project, refresh your browser.  If you forgot the name of your project, it can be found in the activation email.

Select Dashboard from the left navigation panel.   On the main view, you will see the Dashboard with multiple widgets (at the bottom).  

The first widget is the Real Time Event Log.  This widget will display messages received from the board as they come in.  You can use this as an indicator that the board is successfully connected to the Renesas IoT Sandbox.  Note: the messages are received in JSON format.

Restart the board by pressing the button marked ‘RESET’ or unplugging and reconnecting the USB cable.

After the board is connected to Wifi, you should see messages appear in the Real Time Event Log. Touch the screen on the board to test this; data should pop up after a few seconds.

If you do not see data, then go back to Step 3 to ensure that you have entered the correct API and MQTT credentials.

The next widget is the Last Value Table, which will display the last values sent for sensor readings, weather, and settings.  This table automatically refreshes every few seconds.

Note: It takes about 5 minutes for the air quality sensor to self calibrate after power up.  On this table, process:status will indicate RUNNING if the air quality sensor is in calibration mode or OK if it’s in detection mode.  During RUNNING mode, the air quality reading is not transmitted.

 

screen-shot-2016-10-01-at-9-04-15-pm

The Real Time Gauge widget will show readings for air quality, humidity, proximity, and temperature.

If the GPS Sensor is connected, the Geopoint widget will show a map with city level accuracy of the device location based on IP address.

Refer to the documentation to learn more about the Dashboard and Widgets.

smartchef_dashboard

Step 6: Notifications

This step is meant to be informative.  The Workflows will generate notifications based on various scenarios.  As you proceed through the rest of the guide, you will see various types of notifications.  Appendix D describes how to disable notifications.

Note:

  • Some notifications such as the “Screen touched” notifications are received instantly whenever you touch the screen
  • Some notifications such as the “Impact detected” notifications are received delayed by default because the accelerometer sends an event every 10 minutes. The workflows wait for this event before the notification is sent. To change how often the accelerometer sends an event, see Appendix F.

 

Dashboard:

Notifications are sent to the notification stream with the message tag.  Note: Refer to the documentation for the meaning of streams and tags.

smartchef_dashboard2

Board Screen:

Some notifications will appear on the board display.

smartchef_screen

Phone Push:

Some notifications will appear on the mobile app.

img_2944

Phone SMS:

See Appendix B on instructions to add your phone number and enable SMS.

Email:

This is enabled by default and will use the email you signed up with on the Action page in Step 2.  See Appendix B on instructions to change the email.

 

Step 7: Connect to Mobile

In this section you will connect the mobile app to:

  • Transmit the GPS location of your phone
  • Display temperature reading from the sensor
  • Display notification and receive push notification from your Renesas IoT Sandbox project

Note, the app is currently in BETA.

You can find links to the mobile app on renesas-docs.mediumone.com/?mobile or search for “IoT Controller” on the Apple or Google app store.  The IoT Controller allows you to build custom dashboards.  The UI may look different from iOS and Android but the concept is similar.

Recommendation: Send a copy of the activation email to your mobile phone.  That will allow you to copy and paste your credentials to the mobile app to save time.

Open the app and click on + on the top right to add a new profile.  A profile is a saved dashboard view.  You will see a profile called “new” displayed.  Click on it.

img_2921

Next, replace “new” with “Smart Chef” (or any arbitrary name) specify API Settings received from the mobile section of your kit activation email.  If you already have a profile created, you can access the API Settings by clicking on “API Login” on the top right.

img_2922

Then, add your API credentials from the welcome email you received so the Dashboard knows which account it is connected to.  Select Renesas to connect the app to the Renesas IoT Sandbox and click ‘Done’.

file_000

Click on Add Widget to add each of the following widgets (one at a time):

Add 1 Gauge widget, 1 Notification widget, and 1 GPS widget (only if there’s an attached GPS PMOD), 

img_2924

To configure each widget:

On iOS, click on the icon of the widget to show the popup configurator.

On Android, slide the widget to the left.

img_2923

 

Configure the Gauge by clicking on the Gauge icon on the left :

  • Set Temperature: stream = “processed” and tag = “temperature” and enable “Auto”. 

The min and max range for the gauge can be fixed (default 0 to 100) or set to Auto.

Note: Renesas IoT Sandbox stores data in multiple streams.  In this demo, data is stored across multiple streams such as raw, processed and notification.  This is a design choice, learn more about streams and tag in the documentation.

 

img_2845

Next, configure the Notification widget:

  • Set stream = “notifications” and tag = “message”

This widget will display the most recent event from the notification stream and message tag.  This is the stream/tag that is used for notifications for the Smart Chef demo.

For iOS remember to click “Save” at the bottom to save the profile settings.  

Note: While each Widget is connected, it will consume your Renesas IoT Sandbox credits (1 event credit per widget every 3 seconds).  

img_2846

OPTIONAL:

If enabled, configure the GPS widget by clicking on the GPS location icon the left side of the widget.

  • Set GPS: stream = “raw” and “tag” = “myGPS” (case-sensitive) and turn on the GPS switch.  This will transmit GPS coordinates to your Renesas IoT Sandbox account to the raw data stream as the myGPS tag.

Be sure to turn off the GPS widget when the App is not in use.  Otherwise it will continue to send GPS coordinates every 5 seconds and quickly consume your free Renesas IoT Sandbox credits.

img_2848

 

Note: You can learn how to use all the widgets by reviewing the Mobile Quick Start Guide or learn more about data streams and tags on the documentation

 

Step 8: Screen Tap Notifications

Let’s do a quick notification test.  Assuming push notification is enabled, tap on the screen of the S3A7 board. You will get a notification with the coordinates.

smartchef_screentap

 

Step 9: GPS to Mobile

This step works if you have a GPS PMOD.  Otherwise skip to Step 10.

You can view the location of the device on the dashboard by clicking the Single User GeoPoint widget.

screen-shot-2016-09-29-at-12-31-39-am

Once the widget appears on the dashboard, select device from the top right dropdown.  This notifies the widget to view data for that specific device.  Next, select processed.geopoint from the left dropdown.  Processed is the data stream and geopoint is the tag.  You will now see the location of your S3A7 board.  

Note: the S3A7 will send it’s GPS coordinates once every 10 minutes to the processed.geopoint tag.

smartchef_geoloc

TIP:

When your phone and board comes within a 50m range of each other, a notification will be sent.

When your phone and board goes outside the range, a notification will be sent.

Both the mobile app, GPS, and the board need to be enabled for this notification to be generated.

 

Step 10: Start Smart Chef IoT Demo

The Smart Chef IoT Demo features a Sizzling Skirt Steak Recipe with step-by-step instructions that emulate how to cook a skirt steak on a barbecue.  It utilizes the sensors, notifications and screen.  It has a defined sequence of steps with rules and alerts for guiding the chef through the cooking process.  When each step is completed, it automatically proceeds to the next step.  This recipe contains a few simple steps like:  Setting the temperature and Closing the barbecue lid.

Before beginning, make sure there’s no object in from of the AMS sensor to simulate the lid closed.

Note: In this step, covering the AMS sensor will simulate lid being open as instructed in the recipe.

You will need to start the recipe from your Dashboard.  To start the recipe: type in “steak” in the User Input widget under tag “recipe.select” as pictured below. **If you activated your account prior to Nov 21, 2016, you should type in “skirt steak” to start the recipe instead**. Click on Send Event.  This will generate an event to trigger a Workflow to start the recipe.

smartchef_demo1

 

Once the recipe is started, the board will then acknowledge the recipe chosen with a message: “Recipe ‘steak’ was selected. Touch screen to get started” and will display the steps to follow:

smartchef_demo2

img_2935

Touch the screen to start the recipe. It should now say “OK, let’s get started! Set Temperature to 100”.

Since the sensors are not connected to a real barbecue, we will simulate the temperature changes by sending an event to the processed.temp tag from the dashboard as below.  On the dashboard, simply set it to 100 and press “send event”.  

screen-shot-2016-09-29-at-12-46-34-am

Next, we simulate opening the barbecue lid by using a proximity sensor. 

When prompted to open the lid, put your hand or some object over the AMS sensor and wait a moment to accomplish that step in the recipe. This may take a minute.

Follow the steps printed on the board display to complete the recipe. If you leave the board idle for 5 minutes without going to the next step of the recipe, the board will automatically exit the recipe. If you need to restart the recipe, send in ‘steak’ in the User Input widget again.

Completion of the recipe will print the message “Great job, you’re done!” on the board display.

img_2937

Note: You can learn to create your own recipe in Appendix E.

 

Step 11: Vibration Impact Detection

In this Step, we will demonstrate a notification sent when the board is impacted or shaken.  By default the board transmits aggregated vibration data once every 10 minutes.  Since we don’t want to wait up to 10 minutes to receive the impact notification, we are going to speed that up to once every 5 seconds.

When the board powers up and is connected to Renesas IoT Sandbox, it requests the vibration transmission rate.  Let’s change the Workflow that configures that setting.

Click on Workflow Studio in the Renesas IoT Sandbox

screen-shot-2016-10-01-at-7-44-44-pm

Click on the workflow called “Set Vibration Aggregate Window

screen-shot-2016-10-01-at-8-35-47-pm

You will see a workflow like this:

screen-shot-2016-10-01-at-8-35-53-pm

Double click on Base Python to reveal the code:

screen-shot-2016-10-01-at-8-39-09-pm

Look for the variable aggregation_window. At the time of writing this QSG,  it was located on line 11.  The default window is set to 600,000 milliseconds which equals 10 minutes.  Let’s change it to 5000 which is 5 seconds.

screen-shot-2016-10-01-at-8-36-14-pm

Click Check syntax and make sure it passes.  Then click Save and Activate.

screen-shot-2016-10-01-at-8-07-00-pm

Disconnect the board from power and reconnect it.  When the board reestablishes connection to Renesas IoT Sandbox it will download the new aggregration_window setting.

Once the board completes its power up and displays this view, go ahead and give it a little shake.  Within 5 seconds you will receive a push and email notification.

img_2944

img_2927-1

Note: increasing the rate to 5 seconds will quickly consume your free Renesas IoT Sandbox credits.  We recommend slowing the sample rate back to 10 minutes by repeating the same process.

 

Step 12: Workflows Explained

This step is meant to help you understand how the Workflows tie into the Demo. The Smart Chef IoT Demo comes with over 20 pre-built workflows for retrieving and analyzing data from multiple sensors (including air quality, temperature, humidity, and accelerometer sensors), as well as for using the GPS sensor for geolocation and local weather.

A Workflow is a python-based application that is triggered by events from the board, mobile app, or a timer.  These workflows are free and available to you to build your IoT solution; visit the documentation page to learn more about Workflows.

Here are the different workflows provided with the Smart Chef IoT demo.

smartchef_workflows

Below is a brief description on the functionality of each workflow.

Workflow Name Description
Air Quality Sampling Requests air quality (AMS) sensor reading from the board.
Air Quality Processing Decodes the air quality reading from the sensor.
GPS PMOD Sampling Requests GPS sensor reading from board.
GPS Processing Decodes the GPS sensor reading to geopoint format.
Temperature and Humidity Sampling Requests temperature and humidity (AMS) sensor readings from the board.
Temperature and Humidity Processing Converts the temperature and humidity readings to a readable format.
Process Sensor Rules Processes sensor responses and evaluates against the rules set in the recipe.
Update Display Updates board display.
Send Notifications Monitors workflow notifications and sends Email, SMS, Push, and Display notifications.
Select Recipe Starts the recipe based on sending the ‘select’ event to the recipes stream.
Recipe Flow Requests the sensor data corresponding to each step of the recipe based on a timer.
Set Target Temperature Prints the target temperature to the display.
Get Weather Request the current weather information based the IP address of the board, generating a personalized notification based on the weather.
IP and Location Monitoring Gets city and state base from IP address of the board.
GPS Mobile to BBQ Distance Calculates the distance between the GPS, phone, and BBQ. Generates notification messages if you are in or out of range.
Color and Proximity Sampling Requests color and proximity (AMS) sensor reading from the board.
Color Processing Decodes the color sensor reading to RGB and alpha.
Proximity Processing Decodes the proximity sensor reading.  Note: the higher the proximity reading, the closer the object.
Detect Vibration Impact Sends a notification when a high vibration level is detected.
Set Vibration Aggregate Window Specifies the vibration aggregate window size.  The frequency it should transmit to Medium One, and the board will receive this configuration once upon reboot.
Monitor BBQ GPS Monitors the GPS of the BBQ (if the GPS PMOD is connected) and sends notification if it is moved > 100m.
Update Settings Updates user settings such as email and phone number by sending an event to the settings stream with the relevant keys.
Detect BBQ Offline Detects if board goes offline for more than 15 minutes and sends a notification. Another notification is sent when board is back online.
Store Recipe Steps Saves the last step of the recipe.
Processed Touch Sends a notification when you touch the screen, along with the x,y coordinates.

 

Step 13: What’s Next

Congrats, You have just completed setting up the Smart Chef IoT Kit!  

Next, here are some other tutorials you can try:

The rest is up to your imagination! Here are some advanced tutorials in the Appendix.

Appendix

A: Printing to the display

On-board Display Specs

The screen can display 20 rows of text.  Each row can display 40 characters.  You’ll need to print each row from our workflow.

row text
0 <reserved>
1 Time: <display the time of transmission>
2 Device: WAN=111.111.111.111    LAN=111.111.111.111    
3 M1_Version=<m1_version_code>   Kit_Version=<kit_version>
4 Target Temperature: <raw:{“set_temperature”:<number>}>
5 Current Weather:  Temp=<temp>   Humidity=<humidity>   Condition=<cloudy,rainy,sunny,etc>
6 Location:  <City, State, Country>
7
8 Notification:
9 <Instructions>

Note: The ‘Send Notification’ workflow will send messages to the screen by specifying the line number (line) and the message to print (message) with the key screen: true

Example: Sending this event as the device user will send a “Hello” notification to SMS, email, mobile app and the screen.

{“event_data”:{“message”: “Hello”, “sms”: true, “email”:true, “push”:true, “screen”:true, “line”:10}}

EXERCISE:

Create a workflow that receives a string from the mobile app to generate a notification message that will print to the display.

B: How to Change SMS or Email for Notifications

By default your Renesas IoT Sandbox project uses your email during the activation process.  You can change your email and provide your mobile number to receive SMS notifications.  Simply set your information on the Dashboard using the User Input widget. Type your email in the box with the tag ‘settings.user.email,’ and make sure you click “Send Event”.

No phone number is set by default.  To add your mobile number, enter it into the settings.user.phone input field and click Send Event.

Either of these will send an event to the Workflow to update the user preferences.

WARNING: SMS notifications cost 100 credits each.  It might quickly consume your workflow credits.  Push notification is preferred, if possible.

smartchef_userinput1

C: Setting Temperature

Setting Temperature is a feature where you can change the temperature using your mobile phone or dashboard and it will print to the board screen.  It demonstrates the ability to send data back to the board.

From the Dashboard: use the slider to set the value under raw.set_temperature and click Send Event.  

smartchef_userinput2

You will see the temperature print on the board. (i.e. Set Temperature: 34)

Note: this is different from the “processed.temp” tag which allows for simulating the temperature sensor.

smartchef_notif

You can also set it on the mobile app.  Add a Slider widget and set the stream to “raw” and tag to “set_temperature” (case sensitive).  Then move the slider left or right to set the temperature and send it to the cloud and board. 

smartchef_settemp smartchef_settemp2

 

D. How to Disable Notifications

Method A: Disable All notifications: SMS, Push, Email, and Display.

This method will disable the Workflow that is responsible to sending all notifications.  Click on Workflow Studio to display all the workflows.

screen-shot-2016-10-01-at-7-44-44-pm

Click on the workflow named “Send Notifications.”

screen-shot-2016-10-01-at-7-44-54-pm

This will open the workflow, and you should see something like this:

screen-shot-2016-10-01-at-7-45-09-pm

On the right side of the screen, click on the  icon to revel the Revisions panel.  Note: This shows different revisions of this workflow. You can name the revision, or roll back to older versions of your workflow.  Notice the “activated” label at the top revision.

screen-shot-2016-10-01-at-7-45-29-pm

 

Click on “X” button under the activated revision to deactivate it.

screen-shot-2016-10-01-at-7-45-35-pm

You should now see no revision that is marked “activated“.  This workflow is displayed and will not send any notifications.  If you want to re-enable this workflow, click on the check mark icon to reactivate.

screen-shot-2016-10-01-at-7-45-41-pm

 

 

Method B: Selectively disable Push, SMS or Email.

This method will disable the selective disable the part of code that is responsible to sending the specific type of notification.  Click on Workflow Studio to display all the workflows.

screen-shot-2016-10-01-at-7-44-44-pm

Click on the workflow named “Send Notifications”.

screen-shot-2016-10-01-at-7-44-54-pm

This will open the workflow and you should see something like this:

screen-shot-2016-10-01-at-7-45-09-pm

Double click “Base Python” to reveal the workflow code.

Note: Click anywhere on the code and use command-F to search the code.

To disable email notifications, find the line containing “email.send()”(this is line 60 of this Quick-Start Guide). Add a # at the start of this line to comment it out like so:

screen-shot-2016-10-01-at-7-46-13-pm

To disable push notifications, find the line containing “FCM.send”. (this is line 68 of this Quick-Start Guide) Add a # at the start of this line to comment it out:

screen-shot-2016-10-01-at-7-46-28-pm

 

To disable SMS notifications, find the line containing “email.send()”. (this is line 51 of this Quick-Start Guide) Add a # at the start of this line to comment it out:screen-shot-2016-10-01-at-7-51-01-pm

 

Click “Check syntax” make sure you see “Pass!”, otherwise you make an error in this step.  If it passes, click “Save and Activate” to activate these changes!

screen-shot-2016-10-01-at-8-07-00-pm

 

E. Define Recipe Steps

ADVANCED ONLY.  We recommend this for developers who have built workflows before using Python on Renesas IoT Sandbox.

To set a new recipe, send an event to the RECIPE stream with the STEP definition in an object formatted similarly:

A STEP is an array of steps with:

name : A name to be referenced in the recipe (see below),

“name”: “pre-heat 100”,

set : Message to send on start of the step

“set”: “this will show as a notification”,

get : Sensors to get data from:

“get”: [“temperature”, “proximity”, “air_quality”],

max_alerts : Max number of alerts for the step:

“max_alerts”    : 2,

complete_rules : Rules that indicate completion of the step:

“complete_rules”: [

      {“sensor”: “temperature”, “greater_than”: 30, “less_than”: 35, “message”: “BBQ ready, open the lid, put food on.”}

      ],

alert_rules : Rules that indicate an alert level, if the step is not proceeding as planned.

“alert_rules”   : [

  {“sensor” : “proximity”, “greater_than”: 800,

   “message”: “Keep lid close!”},

  {“sensor”      : “air_quality”,

   “greater_than”: 1000,

   “message”     : “Detecting too much smoke, check food.”},

  {“timeout_sec”: 60,

   “message”    : “BBQ not heating up!”},

  {“timeout_sec”: 120,

   “message”    : “Last warning.. BBQ not heating up!”},

],

abort_rules : Rules to indicate failure and cancelling of the recipe.

“abort_rules”: [

      {“sensor”: “temperature”, “greater_than”: 1000, “message”: “Too hot!!”},

          {“timeout_sec”: 1000, “message”: “Stopping Recipe, pls check your BBQ”}

      ]

A rule includes the following keywords:

  • “sensor”: “<name of the sensor to check>”
  • “greater_than”: <number – sensor value to compare to>
  • “less_than”: <number – sensor value to compare to>
  • “equals”: <number – sensor value to compare to>
  • “message”: <string message to output on alert triggered>
  • “timeout”: <number – message will be emitted after time passed>

Note that if the rule object includes both greater_than and less_than, both will be checked (i.e. it is a AND operation) while to perform an OR operation, one needs a rule with greater_than and a rule for less_than

See example below:

{

  “step”: [

      {

          “name”          : “start”,

          “set”           : “Touch screen to get started”,

          “get”           : [],

          “max_alerts”    : 2,

          “complete_rules”: [

              {“sensor”:”touched”, “equals”: 1,

               “message”    : “OK, let’s get started!”},

          ],

          “alert_rules”   : [

              {“timeout_sec”: 60,

               “message”    : “Touch screen to start.”}

          ],

          “abort_rules”: [

              {“timeout_sec”: 120,

               “message”    : “No touch event detected.”}

          ]

      },

      {

          “name”          : “pre-heat 100”,

          “set”           : “Set Temperature to 100”,

          “get”           : [“temp”, “proximity”, “air_quality”],

          “max_alerts”    : 2,

          “complete_rules”: [

              {“sensor”: “temp”, “greater_than”: 90, “less_than”: 130, “message”: “BBQ pre-heated & ready.”}

          ],

          “alert_rules”   : [

              {“sensor” : “proximity”, “greater_than”: 800,

               “message”: “Keep lid close!”},

              {“sensor”      : “air_quality”,

               “greater_than”: 1000,

               “message”     : “Detecting too much smoke, check food.”},

              {“timeout_sec”: 60,

               “message”    : “BBQ not heating up!”},

              {“timeout_sec”: 120,

               “message”    : “Last warning.. BBQ not heating up!”},

          ],

          “abort_rules”   : [

              {“sensor”: “temp”, “greater_than”: 130, “message”: “Too hot!!”},

              {“timeout_sec”: 180, “message”: “Stopping Recipe, pls check your BBQ”}

          ]

      },

      {

          “name”          : “open lid”,

          “set”           : “Open lid (cover proximity sensor)”,

          “get”           : [“proximity”],

          “max_alerts”    : 2,

          “complete_rules”: [

              {“sensor”: “proximity”, “greater_than”: 800, “message”: “OK, lid was opened.”}

          ],

          “alert_rules”   : [

              {“sensor”: “proximity”, “less_than”: 300, “message”: “Open the lid. BBQ is ready”},

              {“sensor”: “temp”, “less_than”: 90, “message”: “Check temperature”},

              {“timeout_sec”: 120,

               “message”    : “Aborting soon: open lid”}

          ],

          “abort_rules”   : [

              {“timeout_sec”: 230, “message”: “Stopping Recipe, lid was never opened”}

          ]

      },

      {

          “name”          : “cook 7min”,

          “set”           : “Cook for 7minutes”,

          “get”           : [“temp”, “proximity”, “air_quality”],

          “max_alerts”    : 2,

          “complete_rules”: [

              {“timeout_sec”: 120, “message”: “Food is ready.”}

          ],

          “alert_rules”   : [

              {“sensor”: “temp”, “greater_than”: 150, “message”: “Too hot, check temperature!”},

              {“sensor”: “temp”, “less_than”: 90, “message”: “Too cold, check temperature!”},

              {“sensor”: “proximity”, “greater_than”: 800, “message”: “Keep lid close!”},

              {“sensor”      : “air_quality”,

               “greater_than”: 1000,

               “message”     : “Detecting too much smoke, check food.”},

              {“timeout_sec”: 240,

               “message”    : “it’s been too long, check your food”}

          ],

          “abort_rules”   : [

              {“sensor”: “temp”, “greater_than”: 200, “message”: “Too hot!!”},

              {“sensor” : “air_quality”, “greater_than”: 2000,

               “message”: “Detecting too much smoke, aborting recipe.”},

              {“timeout_sec”: 360, “message”: “Stopping Recipe, pls check your BBQ”}

          ]

      },

      {

          “name”          : “turn off”,

          “set”           : “Turn off the BBQ, set T to 0”,

          “get”           : [“temp”],

          “max_alerts”    : 2,

          “complete_rules”: [

              {“sensor”: “temp”, “less_than”: 27.5, “message”: “You’re done. Good job!”}

          ],

          “alert_rules”   : [

              {“sensor”: “temperature”, “greater_than”: 60, “message”: “Temp. still high!”},

              {“timeout_sec”: 60,

               “message”    : “BBQ is still running!”},

              {“timeout_sec”: 8000,

               “message”    : “Last warning.. BBQ is still running!”},

          ],

          “abort_rules”   : [

              {“timeout_sec”: 120, “message”: “Abort, Abort!”}

          ]

      }

  ]

}

Define a RECIPE

Send an event to the RECIPE stream with a sequence of steps formatted as follows:

{“recipe”: {“name”: “steak”, “steps”: [“start”, “pre-heat 100”, “open lid”, “cook 7min”, “turn off”]}}

The recipe object should have a name (like steak) and steps to follow,  like the array of names of the steps defined above.

F. Change the Sampling Frequency of Accelerometer

By default, each sensor sends in data to Renesas IoT Sandbox every 10 minutes. If you want to change the accelerometer frequency, follow these steps. If you want to change the sampling frequency of another sensor, see Appendix G.

  1. Click on Workflow Studio on the navigation sidebar.
    screen-shot-2016-11-23-at-3-19-54-pm
  2. To change the accelerometer sampling frequency, click on the Workflow named “Set Vibration Aggregate Window”. Once in the workflow, double click on the box labeled “Base Python”. The screen below should pop up.
    screen-shot-2016-11-23-at-3-27-10-pm
  3. On line 11, you can set the ‘aggregation_window’ to the frequency you wish to send data in. By default, it is set as  600000 milliseconds (10 minutes). Once changed, click “Save and Activate”.
  4. Reset your board. Your board should now be sending accelerometer data in the frequency that you specified above.

 

G. Change the Sampling Frequency of Sensor Data

By default, each sensor sends in data to Renesas IoT Sandbox every 10 minutes. If you want to change the temperature/humidity, color/proximity, air quality, or GPS sampling frequency, follow these steps. If you want to change the sampling frequency of the accelerometer, see Appendix F. For this example, we will change the temperature/humidity sensor sampling frequency.

  1. Click on Workflow Studio on the navigation sidebar.
    screen-shot-2016-11-23-at-3-19-54-pm
  2.  To change the temperature/humidity sampling frequency, click on the Workflow named “Temperature and Humidity Sampling”.
    • For the color and proximity sensor, click on the “Color and Proximity Sampling” Workflow
    • For the air quality sensor, click on the “Air Quality Sampling” Workflow
    • For the optional GPS sensor, click on the “GPS PMOD Sampling” Workflow
  3. Once in the workflow, double click on the trigger box labeled “Custom”. The screen below should pop up.
    screen-shot-2016-11-23-at-3-34-10-pm
  4. You can set the sampling frequency (in minutes) at the “Minutely Interval” field. By default, it is set to send an event every 10 minutes. Once you have made this change, click “Save and Activate”.
  5. Reset your board. Your board should now be sending temperature and humidity data in the frequency that you specified above.