GBP | USD

A Fast Solution for Prototyping IoT Applications

Contributed By Digi-Key's North American Editors

Internet of Things (IoT) applications promise users instant access to detailed information about their health, their environment, and their machines. For developers, however, the IoT levies a very broad set of requirements that draw on multiple disciplines including wireless sensor design, secure communications, and cloud-based software development.

Adding to the challenges are fast changing demands and emerging opportunities, leaving developers with shrinking windows for turning concepts into working IoT applications.

This article will discuss the design of IoT applications. It will then show how the combination of the Renesas IoT Sandbox and the Renesas Synergy S3A7 IoT Fast Prototyping kit provide a comprehensive platform that can be used by designers to eliminate the lengthy process of IoT development.

IoT application requirements

IoT applications present unusually diverse and demanding requirements. Unlike traditional embedded designs or backend software systems, IoT applications require expertise across a complex hierarchy of systems and services (Figure 1).

Diagram of IoT applications complex hierarchical architectures (click for full-size)

Figure 1: IoT applications build on complex hierarchical architectures that are needed to transform data acquired from multiple trusted sources into meaningful information. This information is then delivered directly to users or for further use in the enterprise. (Image source: Microsoft Corp.)

At the periphery, developers need to achieve highly accurate sensor data acquisition from combinations of sensor nodes that might include existing devices upgraded with suitable client software, or custom devices designed for long-term operation on battery power alone. In many cases, systems architects follow end nodes with intermediate gateways designed to aggregate data, particularly from IoT devices built with short-range wireless technologies.

Using standard communications protocols, IoT nodes and gateways need to deliver their data payloads to the application securely, rapidly, and reliably. As suggested in Figure 1, IoT developers need to marshal myriad cloud-based services to handle fundamental tasks such as provisioning new devices and services, validating the identity of authorized devices, maintaining data streams, storing data, and more. Finally, application-specific services for data analytics and machine learning help software engineers transform the raw data into meaningful information for the end user.

Rapid IoT development

Although IoT developers can readily find the individual pieces to implement complex hierarchical IoT architectures, the task of integrating each piece of the IoT puzzle remains daunting for new developers, and much too time consuming even for experienced engineers. Designed to simplify IoT development, the Renesas IoT Sandbox delivers a full complement of software components needed to move data from end nodes to the cloud and deliver information to end users.

Used in combination with the Renesas Synergy S3A7 IoT Fast Prototyping kit, the IoT Sandbox offers a comprehensive end-to-end development platform that enables developers to rapidly deploy IoT prototypes with minimal development. Using a series of menus, developers configure the Sandbox to stream sensor data through cloud-based processing services that are able to respond to events, interact with other cloud services, provide detailed analytics, and support users’ mobile devices (Figure 2).

Diagram of Renesas IoT Fast Prototyping kit and IoT Sandbox

Figure 2: Together, the Renesas IoT Fast Prototyping kit and IoT Sandbox provide a complete development platform for IoT application rapid prototyping. (Image source: Medium One)

The Renesas Synergy S3A7 IoT Fast Prototyping kit is a high-performance real-time platform for designing and evaluating IoT wireless sensor node designs and is based on the Renesas R7FS3A77C MCU. The S3A7 MCU board includes 32 Mbytes of flash memory, a 2.4 GHz Wi-Fi module (802.11a/b/g/n), an LCD display, LEDs, and a user button for simple interaction. The S3A7 core processing unit is based on the 32-bit ARM Cortex-M4 core.  The MCU integrates on-chip flash, 192-KB SRAM, a 14-bit analog-to-digital converter (ADC), a 12-bit digital-to-analog converter (DAC), multiple connectivity options, and multiple security features including on-chip encryption.

The S3A7 MCU board offers four Pmod connectors and four Grove connectors (Figure 3), allowing developers to easily configure it with available add-on boards. Additionally, the IoT Fast Prototyping kit comes supplied with two Pmod sensor modules – a 6-axis motion sensor module and an environment module with lighting, humidity/temperature, air quality, and color/proximity sensors. Along with the S3A7 MCU board and Pmod sensors, the IoT Fast Prototyping kit includes a fully functional software application designed to demonstrate the entire IoT process flow using the IoT Sandbox.

Image of Renesas S3A7 MCU board includes four Pmod connectors

Figure 3: Along with 32-bit MCU, 32 MB flash, Wi-Fi, and LCD, the S3A7 MCU board includes four Pmod connectors (bottom row of black connectors) and four Grove connectors (white connectors above Pmod connectors). (Image source: Renesas)

IoT Sandbox

Using simple web connectivity protocols, the Renesas IoT Sandbox provides essential services including security, data processing, analytics, and graphical display of real-time sensor data. At the same time, developers can build on sample applications to rapidly configure these services through a series of menus with minimal additional programming.

Developers start using the IoT Sandbox by manually creating an API key and authorized user through the IoT Sandbox Web interface. The API key and API Basic User identity are used to authorize subsequent transactions with the Sandbox.

In building a new IoT application, one of the first transactions might include sending a sample data package to the cloud. This simple operation both illustrates the connectivity protocol and sets the stage for subsequent data processing in the IoT Sandbox.

IoT devices such as the S3A7 MCU board send event data to the IoT Sandbox using the JSON format. The data payload for each event includes key:value pairs for the time the event occurred (observed_at) and for the data set itself (event_data), which in turn can be several key:value pairs. For example, an event observed at a given time with two associated values would be transmitted in JSON format as follows:

{"observed_at":"2017-01-01T12:00:00.0-0600", "event_data": {"force_strength":67, "level":"apprentice"}}

For data streaming and other interactions, the IoT Sandbox supports two simple protocols for connectivity. Devices communicate with the IoT Sandbox using MQTT (Message Queue Telemetry Transport) or REST operations. Built on top of TCP/IP, MQTT is an ISO-standard lightweight protocol for sequenced and lossless messaging. MQTT is built on a flexible publish/subscribe model that can be implemented in a small code footprint. As such, MQTT is particularly attractive for IoT devices that are built with limited memory or limited bandwidth, but nevertheless require reliable data communications.

MQTT requires an intermediate message broker that mediates its publish/subscribe model. As part of its services, the IoT Sandbox provides this broker as well as a Python library that devices use to publish data to the cloud. As with other Sandbox API calls, the MQTT library abstracts data publishing down to a basic call. For example, publishing a data payload such as that shown above to some specific device via the Sandbox MQTT broker is simply:

MQTT.publish_event_to_client(device, payload)

Alternatively, developers can program interactions in any language using the supported REST API. Here, programmers use familiar Web protocols such as GET, PUT, and POST to transmit (Listing 1) or receive (Listing 2) data from the Sandbox. As shown in these code listings, each session begins with a login transaction using the API key, API user ID, and password. Subsequent writes or reads use a basic http POST method to send, or GET method to receive a data payload in JSON format.

Copy

import requests

import json

 

headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}

data = {'login_id': 'john.doe@renesas.com', 'password': '12345', 'api_key': 'ABCDEFGHIJKLmnopabcdefghijklmnop1234567890'}

 

session = requests.session()

response = session.post('https://api-renesas-na-sandbox.mediumone.comv2/login', data=json.dumps(data), headers=headers)

 

url = 'https://api-renesas-na-sandbox.mediumone.com/v2/events/raw/john.doe@renesas.com'

data = {'observed_at': '2015-01-10T00:00:00.000-0800', 'event_data': {'sensor1' : 38.6}}

 

response = session.post(url=url, data=json.dumps(data), headers=headers)

Listing 1: The Renesas IoT Sandbox API provides specific endpoints on the Medium One cloud for session login and for adding data using a standard http POST method to a “raw” stream for the given user. (Code source: Renesas/Medium One)

Copy

import requests

import json

 

headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}

data = {'login_id': 'john.doe@renesas.com', 'password': '12345', 'api_key': 'ABCDEFGHIJKLmnopabcdefghijklmnop1234567890'}

 

# Login

session = requests.session()

response = session.post('https://api-renesas-na-sandbox.mediumone.com/v2/login', data=json.dumps(data), headers=headers)

 

url = 'https://api-renesas-na-sandbox.mediumone.com/v2/events/raw/john.doe@renesas.com'

headers = {'Accept': 'application/json'}

params = {"since":"2015-01-10T00:00:00.000-0800", "until":"2015-01-17T00:00:00.000-0800", "limit":100, "include":"$.event_data.tagname"}

 

# GET

response = session.get(url=url, params=params, headers=headers)

Listing 2: Developers perform simple GET transactions using standard http libraries supported in most programming languages (such as Python shown here) to pull JSON-formatted data with the requested characteristics from the “raw” stream. (Code source: Renesas/Medium One)

Cloud processing

Given a raw data stream, the IoT Sandbox builds processing steps, called “workflows,” around the keys, called “tags,” defined in the data payloads within the stream. Workflows represent basic data processing steps such as filtering, transforming, or otherwise operating on a data stream.

With more traditional approaches, developers can often find themselves caught up in identifying and maintaining the binding between the parameters used in code and the specific sets of data streaming in from an external device. In contrast, the IoT Sandbox automatically recognizes tags and lets developers use them as inputs to workflows, which execute code on the data values associated with each tag. For example, if the developer sends a data payload such as that described earlier, the system will automatically recognize the associated data types (such as numeric or string) and build a data stream comprising time-series data with those tags. Developers use the IoT Sandbox web interface to confirm or modify the schema automatically generated by the Sandbox (Figure 4).

Image of IoT Sandbox automatically recognizes data types (click for full-size)

Figure 4: The IoT Sandbox automatically recognizes data types within new payloads, providing developers with a simple ad hoc method for creating new IoT processing flows. (Image source: Renesas/Medium One)

In addition, the Sandbox provides developers with an intuitive graphical approach for binding tags to code parameters. Using the previous example, developers use the Sandbox’s Web-based Workflow Studio to build the inputs and outputs for workflow code. On the input side, developers use the Workflow Studio to drag and drop the tag values from a “raw” stream received from external devices to specific input parameters of a code module. Similarly, they connect the output of the workflow code to a “processed” stream (Figure 5).

Diagram of IoT Sandbox Web-based Workflow Studio

Figure 5: The IoT Sandbox Web-based Workflow Studio lets developers build workflows graphically by dragging and dropping tags (such as raw.force_strength) into the workflow and connecting each tag as a named input parameter (such as in1) for use within the code module associated with each workflow. (Image source: Renesas/Medium One)

Within the workflow’s code module, the IoT Sandbox API’s built-in IONode module provides a few simple class methods for getting and setting tag values. For example, IONode.get_input('in1') returns a Python dictionary (an associative array of keys and values resembling a JSON payload), which contains values and metadata for the current instance of data from the in1 input to the code module. Using this approach, developers can set the output value (out1) to some processed combination of the input variables (Listing 3).

Copy

new_strength = IONode.get_input('in1')['event_data']['value'] + 100

new_level = "expert"

output = IONode.set_output('out1', {'new_strength': new_strength, 'new_level': new_level})

Listing 3: The Renesas IoT Sandbox provides several high-level libraries such as the built-in IONode Python module, which reduces workflow I/O to simple methods to read (get_input) and write (set_output) data. (Code source: Renesas/Medium One)

Processed streams can further connect to one or more subsequent workflows to implement sophisticated signal processing, analytics, or business logic. For example, developers could use a separate workflow to monitor the data stream. Here, the output from a primary workflow would be directed to a secondary workflow that uses an IoT Sandbox Python module to send an SMS alert to the user if a critical event has occurred. Each time the workflow finds a new event in the raw stream, it automatically launches and executes its code package. The result is automated processing of data streams in near real time. Developers can share inputs and outputs across different workflows to build complex processing flows with multiple sequential and concurrent processing steps.

For any IoT application, however, a critical objective is presenting the results of processed data streams to its users. The IoT Sandbox simplifies this development requirement by providing a series of graphical widgets that connect to data streams. Using the IoT Sandbox Web interface, developers can drop an appropriate set of widgets onto a dashboard to create an easily understood snapshot of IoT results. For example, the IoT Sandbox real-time gauge widget displays the current value of a specific tag, automatically updating the value and its min/max range. Developers can build a dashboard using multiple gauges to present results from multiple data sources in a compact format (Figure 6).

Image of IoT Sandbox simplifies data presentation

Figure 6: The IoT Sandbox simplifies data presentation by providing graphical widgets that display current values and trends from raw or processed data streams. (Image source: Renesas/Medium One)

The Renesas Synergy S3A7 IoT Fast Prototyping kit ships with the Renesas Smart Chef IoT demo, which demonstrates an end-to-end IoT application utilizing the full set of sensors provided with the kit. Renesas also provides several additional sample applications that demonstrate other usage scenarios including connectivity using Bluetooth low energy or Lora. Using the MCU board’s JLink connector, developers simply flash the S3A7 MCU board with the images provided in srec (S record) format. Developers can use the Renesas e2 Studio software development environment to extend these sample applications or build new ones from scratch, loading final srec images using the J-Link flash utility.

Conclusion

IoT application development builds on a broad array of technologies and methods for data acquisition, communications, and processing acquired from sensor hardware through the cloud to the user’s mobile device. As a result, developers find themselves caught between an extensive set of development requirements as well as continued pressure for faster delivery of IoT designs.

To help speed development, the Renesas Synergy S3A7 IoT Fast Prototyping kit and Renesas IoT Sandbox together provide a complete end-to-end development environment. Using a web-based interface, developers can configure the IoT Sandbox to support cloud-based processing flows with minimal additional programming.

Disclaimer: The opinions, beliefs, and viewpoints expressed by the various authors and/or forum participants on this website do not necessarily reflect the opinions, beliefs, and viewpoints of Digi-Key Electronics or official policies of Digi-Key Electronics.

About this publisher

Digi-Key's North American Editors