LEVEL 2: INTERMEDIATE |
This guide will show you how to get started with the RX65N Wi-fi Cloud Connectivity Kit. You will learn how to set up an Ultrasonic Presence sensor with the RX65N board and connect it to Renesas IoT Sandbox. Then you will create a Smart Proximity Demo that will detect the presence of an object and transmit distance data to the cloud in real-time. The current distance, duration length, total presence count, and other statistics will be viewable on your Renesas IoT Sandbox Dashboard.
HERE’S WHAT YOU NEED TO GET STARTED:
- Renesas RX65N Wi-fi Cloud Connectivity Kit
- WiFi Internet access (2.4GHz only)
- Maxbotix Ultrasonic Range Finder
- PMOD USBUART – USB to UART
- .srec file – download here (Last Updated 5/31/2017)
STEP 1: PROGRAM THE RX65N BOARD
Program the RX65N image to the board following the instructions in the “How to flash the RX65N 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
- Project MQTT ID
- User MQTT ID
- API Key
- Device password
STEP 3: CONNECT THE KIT TO THE CLOUD
Note: The kit only works with 2.4GHz WiFi.
Configuring the WiFi connection and Renesas IoT Sandbox credentials for this kit is easily done through a Command-Line-Interface (CLI) via the UART PMOD.
First, power the board using the mini USB power cable provided. Then, connect the UART PMOD to the board (PMOD3 on the top row) and plug it into your computer like the picture below.
Now, you can configure your WiFi connection and Renesas IoT Sandbox credentials through your computer. There are two steps to this:
- Communicate with board
- This step is to communicate with the board through serial via the USB to UART PMOD. The steps differ for Windows and Mac.
- Configure WiFi and Cloud Credentials
- This step is to use the activation email you’ve received and let the board know which project and user the data will be sent to. Your WiFi credentials will also be set here.
1. Communicate with Board
- Download PuTTY here
- When you connected your board to the computer and install the driver, this screen should’ve popped up. Note the USB Serial Port. In this example, note the ‘COM17’.
Only if the screen did not pop up, open ‘Device Manager’ on your computer. This can be done by clicking ‘Start’ and searching for ‘Device Manager’. Once on this page, expand the ‘Port’ row and you can find the USB Serial Port there.
- Now that you know the USB Serial Port number, open PuTTY and under ‘Category’, select ‘Serial’. Type in the USB Serial Port that you got from the previous step.
- Now, under ‘Category’ select ‘Session’. Make sure ‘Serial’ is selected for ‘Connection type:’ and that the ‘Serial line’ corresponds to your USB Serial Port.
- Click ‘Open’ and a terminal should pop up. You can now continue to configure the wifi and cloud credentials.
- Open Terminal
- Copy and paste in:
screen /dev/tty.usbserial-A503OV2N 9600
2. Configure WiFi and Cloud Credentials:
- You should have a terminal open (PuTTY for Windows, Screen for Mac). It should be blank.
- On your RX65N board, press and hold the button labeled ‘PB3’. While holding down ‘PB3’, press the ‘Reset’ button for a few seconds then release the same button. Then, release the ‘PB3’ button
- Now, the screen should be updated with the following text. This terminal will be used to type in the credentials for your Renesas IoT Sandbox Account a as well as your WiFi credentials.
– If you use backspace in this terminal, the character is actually deleted but will show until you start typing again.
– If you paste a string into the terminal, the string will look cut off but will still actually be sent.
- Open the activation email you’ve received from Step 2 of this tutorial. The email subject is Your RX65N Presence Kit is activated!”. Here, you can find the credentials you will enter in the next steps.
- First, we will set the Project MQTT ID. In the terminal, type ‘proj’. Now, you are able to input the Project MQTT ID. Copy the Project MQTT ID found in the activation email. Paste the Project MQTT ID in the terminal and press enter.
- Repeat this for the rest of the credentials in the welcome email.
- ‘proj’ -> Project MQTT ID (This was done in the previous step)
- ‘user’ -> User MQTT ID
- ‘api’ -> API Key
- ‘pw’ -> API Password
- View a summary of all credentials so far by typing ‘summ’
- Next, you will need to specify your WiFi credentials. In the terminal, type ‘ssid’ and enter your WiFi ssid.
- Then, type in ‘psk’ and enter your WiFi password.
- When all the fields are completed, type ‘prov’. You should see this message appear:
Provisioning complete. Please push the RESET button or power cycle the board.
- Remove the UART PMOD and connect the Sonar PMOD in it’s place (PMOD3, top row). Unplug and replug the board back in, and the board should now be connected to the cloud! If successfully connected, the green LED1 should be lit. If the green LED is not lit, please verify that the credentials are correct.
STEP 4: VISUALIZE DATA ON DASHBOARD
Now that you’ve connected the kit to send real-time data to the cloud, it’s time to visualize it on the 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. The first widget you should see at the top is the Real-Time Gauge Widget.
This widget displays the current values for:
- Current Distance: the current distance read by the sensor (inches)
- Presence Detected: displays ‘1’ if there is currently a presence detected, and ‘0’ if not. By default, a presence is considered detected if it is within 30 inches of the sensor.
Note: The value shown is based on the last distance data that was sent in the cloud. So if the gauge shows ‘1’ and the board is not connected, this is because the last distance sent to the cloud was considered presence detected.
- Presence Count: the total number of times presence was detected (# of occurrences)
- Last Duration: the total time the previous presence was detected for (seconds)
The next widget is the Bucketed Histogram. 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). This widget will allow you to see the count of each time bucket. To refresh the table and see new data, click the refresh icon .
The next widget is the User Input Widget, which allows you to change the settings of the board.
If you want to reset the Count , you can set ‘Set Count’ as ‘0’ and click ‘Send Event’. You should then see the count on the Gauge widget change to ‘0’.
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 and sending data.
To learn more about widgets, check out our Dashboard Widgets Documentation.
STEP 5: EXPERIENCE THE SENSOR
To experience the ultrasonic presence sensor, we will now trigger the sensor to detect a presence and visualize it in the Dashboard.
- First, we will verify the board is connected to the cloud and the sensor is working . Go to your Dashboard on Renesas IoT Sandbox. Wave or place your hand above the sensor. On the Real Time Events Stream, you should see new events coming in, highlighted in light blue. These events contain the tag “current_distance” which describes how far away the sensor senses an object in inches. The board will transmit one of these events every 10 seconds OR if there is a change in distance (1/sec max).
- Next, we will trigger a presence. Scroll up to the Real Time Gauge Widget. With nothing in front of the sensor, the “Presence Detected” Gauge should read ‘0’. Take note the current “Presence Count”. Now, cover the sensor with your hand. The “Presence Detected” gauge should now show ‘1’ and the “Current Distance” gauge should reflect your hand’s distance from the sensor. Note: The minimum value of the sensor is 6 inches.
- Keep your hand here for ~15 seconds.
- Remove your hand from the sensor. Now, you should see “Presence Count” on the gauge to increment by one. “Last Duration” should also now display the length of time your hand was in front of the sensor (in seconds).
- When a presence is no longer detected, the sensor sends an event to the cloud with the total duration and average distance of that presence. This duration is also bucketed into one of the following categories that is shown on the bucketed histogram widget.
- < 10 seconds
- < 30 seconds
- < 60 seconds
- < 5 mins
- > 5 min
- You’ve successfully triggered a presence and visualized the statistics generated from the cloud.
Congratulations! You’ve successfully run the Smart Proximity Demo by connecting an ultrasonic sensor to your RX65N board then sending the data to the Renesas IoT Sandbox.
You’re now familiar with RX65N Wi-fi Cloud Connectivity Kit, Renesas IoT Sandbox platform, and just tapped into the possibility of exciting new projects.
The rest is up to your imagination!