Create a new workflow to trigger the LED on when a high noise level is detected (for example, from clapping). The amount of times the LED blinks will be proportionate to the noise level detected.
Learn how to connect to a mobile app and utilize a mobile widget to blink the LED light on the board.
Here’s a diagram of the 7 workflows in this tutorial; you will create one new workflow called “Blinky Clap”, while the remaining workflows come pre-built with the S5D9 Diagnostics Intelligence Tutorial.
Connect S5D9 kit to Renesas IoT Sandbox account. At this point, your board should be connected to Ethernet and you should see a green LED light on as shown below.
STEP 2: CREATE BLINKY CLAP WORKFLOW
In this step, you will create a workflow that blinks the board’s yellow LED light based on the detected noise level. To trigger the blinks, you can clap your hands; specifically, use a single (different strength) clap to trigger different noise levels.
If noise level value is within <1000, 2000>, yellow LED blinks once
If noise level value is within <2000, 3000>, yellow LED blinks twice
If noise level value is <3000+>, yellow LED blinks three times
Note: Each single clap has to be at least 10 seconds apart to trigger the workflow.
In Renesas IoT Sandbox, create a new workflow and name it “Blinky Clap” by clicking on Workflow Studio and “Create”.
Drag the “mic.value” tag from the raw stream into the workflow.
Double click on “mic.value” tag and confirm that it’s Trigger is checked.
Similarly, drag a Base Python module and connect its “in1” input to the “mic.value” tag.
Your overall workflow should look like this:
Double click on Base Python, then delete and replace the Base Python script with the following code:
import MQTT# set output to inputmic = IONode.get_input('in1')['event_data']['value']log(mic)if mic > 1000 and mic < 2000: # Blink Yellow LED once MQTT.publish_event_to_client('s5d9', 'B2:' + str(1))elif mic >= 2000 and mic < 3000: # Blink Yellow LED twice MQTT.publish_event_to_client('s5d9', 'B2:' + str(2))elif mic >= 3000: # Blink Yellow LED three times MQTT.publish_event_to_client('s5d9', 'B2:' + str(3))
Then click the “Save and Activate” button to finish setting up the workflow.
Observe your board; you should see a single green LED (LED2) light on. This means the board is properly connected to the cloud.
Clap with your hands near your board; if the board detected the noise level of your clap, a yellow LED will flash. The number of flashes depends on the clap’s strength.
The Real Time Events Log shows detected noise value of 3915.
Based on the created workflow, the yellow LED (LED3) will flash 3 times.
Now, you can decrease/increase the intensity of your clap and observe the yellow LED flash once, twice or three times.
STEP 3: CONNECT TO MOBILE APP
Now, you will learn how to connect to your mobile app. To create a mobile profile, you need the following info:
The user password is not viewable in Renesas IoT Sandbox; thus, you will need to update your password. Once you update your password, you will receive a new email notification, which will include your API login and API Password for mobile app.
To change the User password, go to Setup -> Manage Users of Renesas IoT Sandbox, then click on Edit.
In Edit Details, click ‘Update’ to update your password.
Enter and confirm your new password; then click ‘Save’.
You have updated your user’s password.
To view the API key, go to Setup -> Manage API Keys of Renesas IoT Sandbox, as shown below. Record it as you will need it in your mobile app.
You have changed your user password. Now, go to your email account and view the email you received from firstname.lastname@example.org. This email will contain your API user, and your new API password as shown below.
Now you are ready to create a new profile in your mobile app.
Open IOT Control app on your phone .
Click +; A profile named ‘new’ appears on the phone display.
Click on ‘new’ to set the API login credentials as shown below. Enter:
Desired profile name
API Key (from Setup -> Manage API Keys in Renesas IoT Sandbox)
API Login (from above mentioned email)
API Password (from above mentioned email)
Select “Renesas”, then click on ‘Done’.
Now, you will add a new slider widget.
Click on +Add New Widget, then select Slider widget as shown below.
Configure the Slider widget by clicking on the slider icon. Create a new raw tag called “blink” as shown below; then click ‘Done’. The new “raw:blink” tag will control the LED light on the board.
Now you are ready to test the mobile app.
Select desired number of blinks in mobile app; in this case, the “blink” tag is set to 8 blinks.
Observe red LED on S5D9 board blink 8 times.
The following two pictures show the LED light flashing.
Congratulations! This concludes the Mobile & Clap tutorial for S5D9 Renesas Synergy Kit. You have learned to write a workflow to trigger the LED dependent on noise level. You also followed the steps on how to connect to the mobile app and utilize the mobile widget to blink the LED light on the board.
The rest is to your imagination!
Try another S5D9 Renesas Synergy Kit quick start guide: