S5D9 HowTo: Variable Blinky from IoT Cloud Event



Project Goals

  • Create widget to accept a number value for blinks per minute
  • External LED blinks at the specified rate


  • Widget sends event to Python workflow
  • Python workflow receives integer value for blinks per minute
  • Workflow uses MQTT to publish event to client
  • MQTT event sets pins on Grove connector to turn on and off

Learning Objectives

  • Create custom tag that is used to send event data
  • Add new widget to dashboard to use custom tag


Create blink_rate tag

Create a new user called, Mobile.

Configure Mobile Phone

Using the mobile app, create a new profile.

Copy and paste the settings from the email you received from the Renesas IoT Sandbox.

The email looks like this:

Open the email in your mobile phone and copy the API key into your mobile app.

Press the + sign to create a new widget.

Set the Tag to blink_rate.

Send blink_rate to the Renesas IoT Sandbox.

This will enable the tag blink_rate in the raw stream.

Configure Data Streams

Select raw events.

Move your mouse over the right column that says, Actions. A pencil will appear.

Select raw.blink_rate. If this does not appear, you need to create the Tag through the API or mobile app.

Make sure it is Active.

Set the Label to Blinks Per Minute. This is the label that will appear in the dashboard.


In the Workflow Studio, select Cloud GPIO.

Open the Python workflow, the green rectangle. Add Input.

Select Tags & Triggers, the link (1). Select raw (2). Select blink_rate (3).

Connect the output of the raw.blink_rate to the in3 input of Base Python Cloud GPIO.
Your workflow panel will look like this.

Open up Base Python Cloud GPIO again and replace it with this code.

Renesas Data Intelligence GPIO

def turnOff():
    MQTT.publish_event_to_client('s5d9', 'G4:11:0;G1:1:0') # sets pin 4_11 low and pin 1_01 low 
    log("LED turned off")
    return 0

def turnOn():
    MQTT.publish_event_to_client('s5d9', 'G4:11:1;G1:1:1') # sets pin 4_11 high and pin 1_01 high
    log("Grove connector on")
    return 1
import MQTT
import time

ledState = 0

if IONode.is_trigger('in1'):
    toggle = IONode.get_input('in1')['event_data']['value']
    if toggle == 1:
        ledState = turnOn()
    elif toggle == 0:
        ledState = turnOff()
        if ledState == 0:
            ledState = turnOn()
            ledState = turnOff()
        log("LED toggled")

# Blink Rate. Will blink 50 times at a rate specified from Dashboard
elif IONode.is_trigger('in3'):
    blinkRate = IONode.get_input('in3')['event_data']['value']
    log("Blink Rate: " + str(blinkRate))
    for blink in range(0, 50):
        if ledState:
            ledState = 0
            ledState = 1

elif IONode.is_trigger('in2'):
    blinkNum = IONode.get_input('in2')['event_data']['value']
    # modify code to blink external LED

    for blink in range(0, blinkNum * 2):
        if ledState:
            ledState = 0
            ledState = 1
        log("it blinked")
    log("LED blinked " + str(blinkNum) + " times")

Save and activate the workflow.

Configuring Dashboard

Single User Input

Select the gear in the upper right.

Scroll down and select raw:blink_rate. If the tag does not exist, you need to set it as active in Config -> Data Streams -> raw.


S5D9 IoT Fast Prototyping Kit Tutorials
Cloud-Driven Blinky Video Demo Overview
HowTo: Control Fan with S5D9 and IoT Sandbox Dashboard