Develop IoT Applications Fast with Open-Source Hardware
Contributed By DigiKey's North American Editors
2016-09-15
Internet of Things (IoT) development poses significant challenges from device hardware design through cloud application software. At the same time, open-source hardware and accompanying cloud development software offer an attractive platform for rapid development of sophisticated IoT applications. With the availability of the BeagleBone Green Wireless kit and associated software development kit (SDK) for Amazon Web Services (AWS) IoT, developers can take advantage of the BeagleBone ecosystem while deploying IoT applications in a leading cloud service environment.
In the rush to exploit emerging opportunities in the IoT, developers must navigate a complex development process extending from hardware design through to high-level applications software development. Even as the industry sorts out competing mechanisms and protocols, industry leaders such as Amazon have quickly established comprehensive platforms for IoT application development and deployment.
For designers, however, the challenge starts with finding the balance between multiple hardware requirements including power consumption, radio performance and overall system performance required for a successful IoT solution. Along with those fundamental hardware issues, however, companies can find IoT projects stumble further as designers struggle against the long learning curve associated with nascent IoT cloud platform software technology.
For companies looking to deploy IoT applications, the choice of device design and of cloud service provider are equally critical. Poor IoT device design can compromise the very IoT data that fuels the application, while an inadequate cloud solution can compromise the robustness and performance of the application itself, regardless of the quality of the underlying data. Just as important, any time-to-market delays, due to weak development support for either the IoT device or the cloud-based service implementation, can kill what might have otherwise been a successful product launch. Consequently, development platforms that combine hardware with cloud software support are an increasingly important factor for success in IoT development.
IoT platform
Among available IoT development kits, the BeagleBone Green Wireless (BBGW) board offers a compelling solution for designers looking to rapidly build systems able to leverage current and emerging IoT platforms. Based on the Texas Instruments Sitara processor, the BBGW board provides a comprehensive solution for creating low-power, high-performance IoT devices. Designers can rapidly build products on the BBGW, quickly enhance its capabilities with available add-ons, or even extend this open-source hardware board with custom features.
The BBGW board offers a further advantage for IoT developers. Texas Instruments and Amazon Web Services (AWS) have collaborated to create an integrated solution that simplifies connectivity to AWS IoT systems built on this board. This solution is particularly compelling as IoT applications developers look to position their products alongside market-leading cloud services.
Although the choice of cloud service provider typically depends on multiple technical and business factors, AWS has emerged as a compelling candidate for many companies looking to field IoT applications, thanks to a combination of geographical reach and services breadth. In fact, it surpasses that of its nearest competitors combined (Figure 1).

Figure 1: Amazon Web Services (AWS) remains the dominant cloud services provider with a market share greater than its nearest competitors' shares combined. (Image source: Synergy Research Group)
Development platform
Based on the open-source hardware design of BeagleBone Black, the BBGW is the first board in the BeagleBoard.org community with wireless connectivity, supporting both Wi-Fi and Bluetooth low energy (BLE). The connectivity comes via a Texas Instruments WiLink 8 single-band (2.45 GHz) Wi-Fi (IEEE 802.11b/g/n) and Bluetooth 4.1-complaint combo module with dual-antenna support. The board combines the wireless module with the Texas Instruments AM3358 Sitara processor, 512 MB of DDR3 RAM, four USB 2.0 host ports, and two Grove sockets.
Designed for high-performance applications processing, the TI AM3358 combines a 1 GHz ARM Cortex-A8 processor, 3D graphics accelerator, floating-point accelerator, and a diverse set of on-chip peripherals. In addition, the device's programmable real-time unit subsystem and industrial communication subsystem (PRU-ICSS) integrates two PRU 32-bit microcontrollers dedicated to I/O event handling. Designed to provide greater flexibility in implementing fast real-time responses, the PRU-ICSS meets a critical need for performance in IoT device operations – supporting specialized data-handling operations and custom peripheral interfaces, as well as offloading peripheral-processing tasks from the device's Cortex-A8 host core.
At the system level, the board's Grove sockets offer a mechanism for rapidly adding additional hardware (Figure 2). Rather than breadboard sensors or build custom circuits, developers can simply plug in standardized sensor modules such as Seeed Technology's 101020192 barometric sensor, 105020012 gyroscope, or 101020212 temperature and humidity sensor. Interacting with the Grove peripheral is as simple as loading the associated support library and reading or writing value for the Grove peripheral at the associated GPIO pin (Listing 1).

Figure 2: The BBGW's Grove interfaces provide an easy method for adding sensors and other peripherals. This figure illustrates the simple addition of a Grove-compatible pushbutton. (Image source: Seeed Technology)
/*
Get input form Grove-button and print its current state one time in a second
*/
// Load Grove module
var groveSensor = require('jsupm_grove');
// Create the button object using GPIO pin 60
var button = new groveSensor.GroveButton(60);
// Read the input and print, waiting one second between readings
function readButtonValue() {
console.log(button.name() + " value is " + button.value());
}
setInterval(readButtonValue, 1000);
Listing 1: After plugging a Grove peripheral into the BeagleBone Green Wireless, developers read, write or control the peripheral using an associated software module. In this example, it reads the state of a Grove pushbutton and simply writes the value on the javascript console. (Code source: Seeed Technology)
Cloud connection
In combination, the performance of the TI AM3358 and the extensibility of the open-source hardware BBGW offer an effective hardware platform for IoT development. For cloud services, TI and AWS collaborated to deliver pre-integrated AWS IoT connectivity through a custom port of the AWS IoT device software development kit (SDK) in server-side javascript (node.js) for the BeagleBone Green series.
Accessible through a variety of open-source library language bindings, the AWS IoT Device SDK enables developers to easily connect a variety of standard hardware devices with the AWS IoT platform itself. AWS IoT expands AWS's message-based approach for loosely connected applications to the IoT, providing a mechanism for loosely connecting hardware devices with cloud-based applications and services (Figure 3).

Figure 3: The AWS IoT platform builds on the message-based AWS architecture with specialized services that maintain a virtual "shadow" of each physical device. This lets it deliver device data even if the actual device has gone offline. (Image source: Amazon Web Services)
Within the AWS IoT, services such as the message broker, rules engine, device gateway and security/identity services provide IoT-specialized versions of services that are common throughout the AWS cloud services architecture. For the IoT, however, the AWS IoT message broker supports MQTT messaging. MQTT provides a standards-based (ISO/IEC PRF 20922) lightweight mechanism for devices, applications and services to exchange data with other devices, applications or cloud services. This "pub/sub" model serves as the fundamental mechanism for loosely coupling devices in the IoT periphery and applications in the cloud. In the AWS model, devices subscribe to "topics" (message queuing services) and publish data in JSON format to topics.
Creating a connection is simple: The TI/AWS SDK provides a device class that wraps the standard mqtt.js node.js package to provide a secure connection to the AWS IoT platform. Besides exposing the underlying mqtt.js interface, the device class provides features to simplify handling of intermittent connections. These features include progressive backoff retries, automatic re-subscription upon connection, and queued offline publishing. As shown in Listing 2 below, after instantiating a "device" instance, a device can easily subscribe to some AWS "topic" (topic_1) and publish data (test_data) in JSON format to another AWS topic (topic_2). In turn, the device can receive a message and operate on its payload (or simply display it as shown in the listing).
var awsIot = require('aws-iot-device-sdk');
//
// Replace the values of '<YourUniqueClientIdentifier>' and '<YourAWSRegion>'
// with a unique client identifier and the AWS region you created your
// certificate in (e.g. 'us-east-1'). NOTE: client identifiers must be
// unique within your AWS account; if a client attempts to connect with a
// client identifier which is already in use, the existing connection will
// be terminated.
//
var device = awsIot.device({
keyPath: <YourPrivateKeyPath>,
certPath: <YourCertificatePath>,
caPath: <YourRootCACertificatePath>,
clientId: <YourUniqueClientIdentifier>,
region: <YourAWSRegion>
});
//
// Device is an instance returned by mqtt.Client(), see mqtt.js for full
// documentation.
//
device
.on('connect', function() {
console.log('connect');
device.subscribe('topic_1');
device.publish('topic_2', JSON.stringify({ test_data: 1}));
});
device
.on('message', function(topic, payload) {
console.log('message', topic, payload.toString());
});
Listing 2: At the software level, connecting an IoT device to an application involves simply subscribing to a named message queue (aka "topic") and publishing device data in JSON format to target topics as appropriate (see highlighted code sections). (Code source: Amazon Web Services)
Many of the services provided in the AWS IoT SDK offer functionality similar to enterprise-level services in the AWS service family. For the IoT, however, AWS IoT provides a specialized service that "shadows" physical devices. This shadowing enables it to deliver the most recent data provided by those devices, even if the IoT device itself is physically removed or functionally disconnected from the network.
In the AWS IoT architecture, each device, or "thing", has a thing shadow that stores and retrieves state information. An application can request the current state information for a thing. The shadow responds to the request by providing a JSON document with the state information. In turn, an application can control a thing by requesting a change in its state. The shadow accepts the state change request, updates its state information, and sends a message to indicate the state information has been updated. At the same time, the actual physical "thing" receives the message, changes its state, and then reports its new state. As a result, IoT devices appear to be online continuously – able to be read or updated even if the corresponding physical device is offline.
In the node.js SDK for the BBGW, the 'thingShadow' class implements additional functionality for accessing Thing Shadows via the AWS IoT API; the thingShadow class allows devices to update, receive change notifications from, or get the current state of Thing Shadows from the AWS IoT. Using this approach, a remote device can update its Thing Shadow in AWS IoT, allowing a user to view the device's last reported state via a mobile app, for example. The user can also update the device's Thing Shadow in AWS IoT and the remote device will synchronize with the new state.
Implementation and use of shadows is straightforward, as illustrated in the code snippets in Listing 3. Similar to a "device" instance, a "thingShadows" instance registered in Thing Registry can receive updates and reflect that changed state on displays, or be used by other object methods as appropriate.
var awsIot = require('aws-iot-device-sdk');
//
// Replace the values of '<YourUniqueClientIdentifier>' and '<YourAWSRegion>'
// with a unique client identifier and the AWS region you created your
// certificate in (e.g. 'us-east-1'). NOTE: client identifiers must be
// unique within your AWS account; if a client attempts to connect with a
// client identifier which is already in use, the existing connection will
// be terminated.
//
var thingShadows = awsIot.thingShadow({
keyPath: <YourPrivateKeyPath>,
certPath: <YourCertificatePath>,
caPath: <YourRootCACertificatePath>,
clientId: <YourUniqueClientIdentifier>,
region: <YourAWSRegion>
});
//
// Client token value returned from thingShadows.update() operation
//
var clientTokenUpdate;
//
// Simulated device values
//
var rval = 187;
var gval = 114;
var bval = 222;
thingShadows.on('connect', function() {
//
// After connecting to the AWS IoT platform, register interest in the
// Thing Shadow named 'RGBLedLamp'.
//
thingShadows.register( 'RGBLedLamp' );
//
.
.
.
//
// Thing shadow state
//
var rgbLedLampState = {"state":{"desired":{"red":rval,"green":gval,"blue":bval}}};
clientTokenUpdate = thingShadows.update('RGBLedLamp', rgbLedLampState );
.
.
.
Listing 3: After creating a shadow instance of a thing (awsIot.thingShadow) and registering the shadow (thingShadows.register), a cloud application can update the shadow (thingShadows.update) and the corresponding physical "thing" will be updated accordingly. Conversely, changes in the thing's state will be available to cloud applications through the shadow. (Code source: Amazon Web Services)
Conclusion
Implementing an IoT application from scratch can require mastery of a broad, deep range of functional features, complicate development, and compromise tight delivery schedules. Alternatively, the open-source BBGW – with its custom port of the AWS IoT SDK – offers an effective platform for rapid development of sophisticated IoT applications. Using this combination of hardware for IoT device design and AWS services for cloud application development, developers can rapidly implement complex IoT applications. These applications will be able to fully exploit the sophisticated capabilities for IoT data processing and analytics now available with advanced cloud services.
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 DigiKey or official policies of DigiKey.




