LEVEL 2: INTERMEDIATE |
This guide will show you how to get started with the Synergy SK-S7G2 Starter Kit. You will learn how to set up an Ultrasonic Presence sensor with the SK-S7G2 board and send the sensor data to Renesas IoT Sandbox. When the presence of an object is detected, the SK-S7G2 board will display the distance to the object, its duration in place, and the total number of objects present. This data is also viewable on the Renesas IoT Sandbox Dashboard.
HERE’S WHAT YOU NEED TO GET STARTED:
- Renesas Synergy SK-S7G2 Starter Kit
- Micro USB cable to power up the board
- One of the following:
- Renesas WiFi adaptor for GT202
- Ethernet connection
- WiFi Internet access (2.4GHz only) (if using WiFi adapter)
- Maxbotix Ultrasonic Range Finder
- srec file – download here (Last Updated 3/23/2017)
STEP 1: PROGRAM THE SK-S7 BOARD WITH THE SONAR IMAGE
Program the SK_S7_Sonar image to the SK-S7 board following the instructions in the “How to flash the SK-S7 board” tutorial. Be sure to download the latest release .srec file that is specific to this kit. This can be found in the HERE’S WHAT YOU NEED TO GET STARTED section.
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 Sonar kit workflows. 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
- API Key, login and password for mobile application
STEP 3: CONNECT THE SK-S7 KIT TO THE CLOUD
Note: The SK-S7 kit WiFi adapter only works with 2.4GHz WiFi.
The board can be connected to the internet via Ethernet (requires Ethernet cable) or WiFi (requires WiFi PMOD). The following pictures show WiFi PMOD, Ethernet connector, and micro USB cable connections to the board. The micro USB cable is necessary to power the board.
To read more about how the board connects to a network, go to Appendix A.
Connect your board as pictured below. If you are using a WiFi module, connect that to PMODA. The Ultrasonic sensor connects to PMODB using the cable provided. Make sure that the white markings on both ends of the cable match, with the sensor’s first pin lining up with PMODB’s first pin. This is pictured below.
NOTE: Ensure your PMODs are powered by 3.3V. To do so, connect pins 0 and 1 of jumper J13; similarly, connect pins 0 and 1 of jumper J15 to select 3.3V option.
The following pictures (Figure 1, 2, and 3 respectively) depict three different ways (Ethernet, WiFi, and Access Point) your board display may look like upon powering up the SK-S7 board. This also determines what provisioning you are required to do.
Note: Ethernet connection takes precedence over WiFi connection.
Option 1: Provision the Board for Ethernet access:
- Connect the Ethernet cable at J11 Ethernet port.
- Power up the board by connecting the micro USB cable into J19 (DEBUG_USB) on the board. Once Ethernet is detected, the board will boot up in provisioning mode.
- When you see the screen as shown in Figure 1, connect to the IP address printed on the screen using the browser on your computer. Make sure your computer is on the same network as the board. This will connect you to the provisioning page of the board to set up the IoT Sandbox credentials. Note: Keep a copy of your activation email readily available.
Option 2: Provision the Board for WiFi:
- Connect the Renesas WiFi Adaptor for GT202 to J12 (PMODA) on the board and disconnect the Ethernet cable.
- Power up the board by connecting the micro USB cable into J19 (DEBUG_USB) on the board. Once the WiFi Adaptor is detected, the board will boot up in provisioning mode and become a WiFi Access Point.
- If this is your first time provisioning the board with a WiFi adapter, you will see the picture as shown in Figure 3. Connect your computer to the board’s WiFi access point using the WiFi on your computer. The SSID and password is printed on the SKS7 display. This is a Wifi Access Point served by the board and is a unique SSID. 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.
Once the provisioning page is loaded, you will see a form similar to the image below. Enter your credentials provided in your activation email.
Note: If you accessed this page before, Renesas Kit Configuration will remember your previously entered login credentials, such as Project MQTT ID, User MQTT ID, API Key, and API User Password.
After clicking ‘Connect’, you will get a message: Provisioning complete. Please reset board to continue.
Reset your board by re-inserting the micro USB cable. Now you are ready to login to Renesas IoT Sandbox and visualize data on dashboard.
STEP 4: EXPERIENCE THE SENSOR
Now that your board is connected to Renesas IoT Sandbox, you get to experience the connected sensor. The interactive board display shows the following data from the cloud on the board’s screen:
- Distance: the current distance read by the sensor (inches)
- Duration: the time per stay (seconds)
- Counter: the number of times presence was detected (# of people)
When a presence is no longer detected, an event will be sent to the cloud with the duration in seconds. That will increment the counter by one.
To test the sensor, put your hand in front of the sensor and hold it there. Observe the duration on the screen increment in seconds. After a while, remove your hand to see the count increment by one. By default, the sensor determines there is a presence if it senses an object within 30 inches. If desired, you can change this ‘presence threshold’ on the Dashboard in the next step.
In the next step, you get to visualize the observed data in the Renesas IoT Sandbox.
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 sidebar. This tutorial comes with the following preloaded widgets in your dashboard: Bucketed Histogram, User Input and Real Time Events Stream.
Whenever the board finishes detecting a presence, it will send the duration data to the cloud. In the cloud, it is sorted into time buckets ( < 10 seconds, < 30 seconds, < 60 seconds, <5 minutes, and > 5 minutes). The Bucketed Histogram will allow you to see the count of each time bucket. To refresh the table and see new data, click the refresh icon next to ‘device’.
In the User Input Widget above, you can change the settings of the board. If you want to reset the total count on the board, you can set count as ‘0’ and click ‘Send Event’. The count on the board display should then change to ‘0’.
As mentioned before, you can also change the presence threshold (the distance value that the sensor determines when there is a presence). The default is 30 inches. To do this, type in the new threshold you want and click ‘Send Event’. This should be applied immediately.
Lastly, the Real Time Events Stream is the widget that displays events as they are being sent from the board to the cloud. This widget is a good way to check if your board is online.
To learn more about widgets, check out our Dashboard Widgets Documentation.
STEP 6: MOBILE APP & PUSH NOTIFICATIONS (OPTIONAL)
Note: The IoT Controller Mobile app is currently in BETA
For this step, you will be creating a Dashboard on your mobile phone to view the current distance the Ultrasonic sensor reads in real-time. In addition to creating this Dashboard, you will also enable Push Notifications to be sent to your phone when there is a presence detected that is too close to the sensor. By default, we’ve set this threshold as 12 inches but it is adjustable.
You can find links to the mobile app on renesas-docs.mediumone.com/?mobile or search for “IoT Controller” in the Apple or Google app stores. The IoT Controller allows you to build custom dashboards in addition to sending events to the cloud. The UI may look different from iOS and Android but the concept is similar. Be sure to allow push notifications when installing this app.
Once downloaded, open the app and click on ‘+’ icon on the top right corner to add a new profile. A ‘profile’ is a saved dashboard configuration. You will see a profile called “new” displayed. Click on it.
Then, add your API credentials from the activation email you received so the Dashboard knows which account it is connected to. Make sure to select ‘Renesas’ to connect the app to the Renesas IoT Sandbox and click ‘Done’.
If successful, ‘API Login’ will turn green at the top righthand corner. If it is red, please go back and check your API credentials.
Next, add a new Gauge widget by clicking on ‘Add Widget’.
The Gauge should appear on the Dashboard. You need to configure the widget and specify the stream and tag for the Gauge to connect to. To do this:
On iOS, click on the Gauge icon to show the popup configurator.
On Android, slide the widget to the left.
In the stream field, type in “raw” and for the tag field, type in “current_distance” as depicted below. Enable “Auto” to automatically adjust the range. Click “Done”.
After a few moments, the Gauge will show the distance that is read by the sensor connected to the board.
Now to test this, place your hand in front of the sensor. You can view the distance updated in 3 ways:
- View the number change on the board display
- View the event logged in Renesas IoT Sandbox on the Real Time Event Stream
- View the change on the gauge you’ve just configured on the mobile app.
In addition to seeing these changes in all three sources, you should also get a push notification to your phone whenever there is ever a presence detected within 12 inches of the sensor. This is the ‘distance_threshold’. To change this value, log on to Renesas IoT Sandbox, go to Workflow Studio, and click on the ‘Push Notifications’ Workflow.
Then, double click on the ‘Base Python’ module and a screen like this should show up:
On line 15, you can see that we’ve set the distance_threshold to 12 inches. Feel free to change this but note that this determines the frequency of push notifications you will be receiving.
Congratulations! You’ve successfully connected an Ultrasonic sensor to your SK-S7G2 board and have sent the data to the Renesas IoT Sandbox.
You’re now familiar with SK-S7G2 Starter Kit, Renesas IoT Sandbox platform, and just tapped into the possibility of exciting new projects.
The rest is up to your imagination!
Try another SK-S7G2 Starter Kit quick start guide:
Or build your own solution based on the Ultrasonic Presence demo (see APPENDIX).
1. Expand the Ultrasonic Presence demo
Login to your Synergy account and download the source code here to modify this demo and build your own customized solution.
2. Summary of how the board connects to the network
In SK-S7 Starter Kits, the network connection is “auto-detected”:
- First, a wired ethernet connection is attempted. If the wired connection link is up within 5 seconds, then DHCP resolution is attempted. If an IP address is resolved within 10 seconds, the wired connection is used and mode shows “Ethernet”.
- Otherwise, a WiFi connection is attempted and mode shows “WiFi”. If the WiFi credentials have been provisioned and the board is able to associate with the AP within 10 seconds, the WiFi connection is used.
- Otherwise, the board enters Access Point mode and mode shows “AP”.
A network connection must be found before the kit will run.
Regardless of the network connection, the provisioning server is always running. You can access the provisioning page by navigating to the board’s IP in the browser.