LEVEL 2: INTERMEDIATE |
This tutorial will show you how to connect the Synergy Starter Kit SK-S7G2 to Renesas IoT Sandbox. See Appendix A for the link to view the source code.
What you need to get started:
- Synergy Starter Kit SK-S7G2
- USB Cable
- Ethernet access with DHCP
- iOS or Android phone – Download
- ConnectedWeatherPanel.srec – Download (Last Updated November 3rd, 2016)
Step 1: Program the Connected Weather App
Program the Connected Weather App image to the SK-S7G2 board using the How to flash the SK-S7G2 board guide listed in the prerequisite.
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 Connected Weather 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 Renesas IoT Sandbox account credentials which you will need to provision the kit and access the cloud portal.
You will receive a second email with your Connected Weather project information including:
- API Key
- MQTT project, MQTT user id and password for the device
- API login and password for the mobile app
IMPORTANT: You will need this information for the steps below.
Step 3: Provision Kit with Credentials
Connect the ethernet cable and power up the board. Once the weather panel is displayed, the LAN IP address is printed on the top right of the board display.
Make sure your computer is connected to the same network as the board. From your computer’s browser, type in the LAN IP address of the board. This will load the provisioning page.
On the provisioning page, enter the Renesas IoT Sandbox API credentials emailed to you when you activated the kit and click Connect. You will get redirected to an error page. This is expected.
Restart the board.
Step 4: Connected Weather
When the board is connected, you will see the location and weather forecast displayed on the screen. This is determined using the IP address of the board.
Step 5: Visualize Data On Dashboard
Log onto Renesas IoT Sandbox using the web credentials emailed to you. If you already have a Renesas IoT Sandbox you can use your existing account. Note: If you have multiple Renesas IoT Sandbox projects, be sure to select your Connect Weather project in the top right corner. Your project name can be found in your activation email. Refresh your browser after switching projects.
Once logged in, click on Dashboard on the left panel.
The last value table will display the most recent weather and location information. This widget refreshes the results periodically.
The gauge will show set temperature from the board. Increase and decrease the temperature on the board display. You should see the gauge increase and decrease to match the temperature setting on the board.
The User Input widget will set a desired temperature between 60 to 85 degrees and has the same effect of the board sending the data. If the board is connected you will see the set temperature update. If you send a value below 60, it will set it to 60. If you send a value above 80, it will set to 80.
The Map will show city level accuracy of the board location based on the IP address. The location is looked up once when the board is connected after a restart. Note: The location lookup for your IP address may not be available and may not display on the map.
The real-time chart will log data events as they are received from the board. The events are displayed in JSON format.
TIP: You can build your own dashboard by adding the widgets at the bottom of the screen. Remember to click “Save”.
Step 6: Connect to Mobile (Optional)
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.
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.
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’.
Next, add a new Gauge widget by clicking on Add Widget.
The Gauge will display and will require configuration. You need to specify the stream and tag for the Gauge to connect to.
On iOS, click on the Gauge icon to show the popup configurator.
On Android, slide the widget to the left.
Set stream = “raw” and tag = “temperature” and enable “Auto” to automatically adjust the range. click “Done”.
The Gauge will now show the temperature setting by the board.
Recommended reading: Mobile App Getting Started Guide to learn how to use all the widgets.
Step 7: Set Temperature
On the SK-S7G2 board, you can change the temperature by clicking on the + – buttons. In doing so, you can view the changes in Renesas IoT Sandbox as well as the mobile app if it is connected.
To view the temperature changes on Renesas IoT Sandbox:
- Go onto the dashboard and scroll down to the ‘Real Time Gauge’ widget
- As you adjust the temperature on your SK-S7G2 board, you should see the temperature reflected on the ‘Real Time Gauge’ widget
To view the temperature changes on your mobile app:
- Make sure you’ve completed the necessary steps from Step 6 above
- In Step 6, you should’ve configured a Gauge widget to temperature
- As you adjust the temperature on your SK-S7G2 board, you should see the temperature reflected on the Gauge widget in your mobile app
In addition to changing the temperature on your SK-S7G2 board, you can also view the temperature as you are changing it on the mobile app:
- Make sure you’ve completed the necessary steps from Step 6 above
- Click ‘Add New Widget’ and select the ‘Slider’ widget
- Click on the slider icon on the left to configure it. For stream, type in ‘raw’. For tag, type in ‘set_board_temperature’.
- Slide the controller to set a numerical value for the temperature
- Once you let go of the controller, an event should be sent and the board should now display the value you’ve selected
- The gauge on the mobile app should be updated as well
Step 8: Workflows Explained
The Connected Weather kit is provisioned with real-time workflows that trigger on events from the board. To view the workflow, click on Workflows Studio. You will see three workflows.
Here’s a brief description on the functionality of each workflow.
Workflow: Get Weather and Location
This workflow will trigger when the SK-S7G2 board successfully authenticates and connects to the Renesas IoT Sandbox. It retrieves the IP address from the board and gets the location and weather information.
Workflow: Set Board Temperature
This workflow will trigger when the you send the tag raw.set_board_temperature. It will push to the SK-S7G2 board over MQTT and then the board will update its temperature value and echo back to raw.temperature.
Workflow: Send Push Notification
This workflow monitors the thermostat temperature set by the user on the touch screen. When the temperature is set to above 80 degrees, a push notification is sent to the user’s mobile app.
Workflows are written in Python. To open a workflow, double click on the Get Weather and Location workflow.
TIP: The green box labeled “raw:ip_address” is the event trigger.
TIP: The orange boxes are generated events when this workflow is ran.
Next, double click on the Base Python box to view the workflow code.
To learn more about workflows, click here.
Step 9: What’s Next
Congrats! You have just setup the Connected Weather Demo! The rest is up to your imagination. Here are some advanced tutorials in the Appendix.
A: Build and Compile Project
This section explains how to open the project, build and run the project in e2studio. This tutorial assumes you have e2studio and Synergy Software Package (SSP) installed.
Download the “Medium One Cloud Agent for Synergy Project” from https://synergygallery.renesas.com/addon/detail/63.
Open E2 Studio, then click File -> Import.
Select “Existing Projects into Workspace” in the Import dialog box, then Next.
Click “Browse” beside the “Select root directory” dropdown.
Browse and select the ConnectedWeatherPanel folder you downloaded from github.
Then click Finish on the Import dialog box to import the project.
Once import is complete, you’ll see the project in E2 Studio.
To build the project, right click on the project “ConnectedWeatherPanel” and select Build Project. This will start the build process and could take a few minutes.
To debug the project, make sure the USB cable is connected to your computer and the debug port of the board. Then click on on the toolbar to debug and run the project.