Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learning AWS IoT

You're reading from  Learning AWS IoT

Product type Book
Published in Jan 2018
Publisher Packt
ISBN-13 9781788396110
Pages 278 pages
Edition 1st Edition
Languages
Author (1):
Agus Kurniawan Agus Kurniawan
Profile icon Agus Kurniawan

Table of Contents (14) Chapters

Title Page
Packt Upsell
Contributors
Preface
Getting Started with AWS IoT Connecting IoT Devices to AWS IoT Platform Optimizing IoT Computing Using AWS Greengrass Building Local AWS Lambda with AWS Greengrass Expanding IoT Capabilities with AWS IoT Button Visualizing AWS IoT Data Building Predictive Analytics for AWS IoT Securing AWS IoT Other Books You May Enjoy Index

Chapter 5. Expanding IoT Capabilities with AWS IoT Button

Amazon provides a one-click solution through AWS IoT Button hardware. This solution enables an interaction between the AWS platform and other IoT devices. In this chapter, we will learn how to work with AWS IoT Button and build an IoT application applying AWS IoT Button.

The following is a list of topics that we will explore in this chapter:

  • Introducing AWS IoT Button
  • Reviewing the project scenario for AWS IoT Button
  • Setting up AWS IoT Button
  • Interacting between AWS IoT Button and IoT devices
  • Building your IoT project with AWS IoT Button

Introducing AWS IoT Button


AWS IoT Button is one of the AWS services that interacts with the AWS backend. AWS IoT Button is built based on the Amazon Dash Button hardware. This device provides connectivity capability through Wi-Fi to communicate with the AWS server.

The first AWS IoT Button hardware appeared in October of 2015. The current AWS IoT Button hardware is the second generation. You can buy this hardware on Amazon's website at https://www.amazon.com/All-New-AWS-IoT-Button-Generation/dp/B01KW6YCIM. You can also check it on your local Amazon website.

The AWS IoT Button form can be seen in the following image.  It consists of a button and indicator LED. AWS IoT Button can detect users pressing in the following three types:

  • Single clicked
  • Double clicked
  • Long clicked

Each clicked type can be connected to a specific action. AWS IoT Button can also be integrated with other AWS services, such as AWS IoT and AWS Lambda.

Reviewing a project scenario for AWS IoT Button


If you search for Dash Button on the Amazon website, you will see various Dash Buttons that are provided by companies to serve certain business services. These scenarios could probably inspire you to implement AWS IoT Button in a real environment:

For instance, we can connect our AWS IoT Button to a smart home. While you click the button, you can turn on all the lamps in your home. In addition, you can connect AWS IoT Button for safety scenarios; for instance, the button will call the police while it is being clicked. You can see this scenario in the following figure:

The idea of AWS IoT Button revolves around what your system will do if AWS IoT Button is clicked. There are a lot of scenarios that you can see in your environment.

Setting up AWS IoT Button


In this section, we are going to set up AWS IoT Button. Assume you have a second generation, or later, AWS IoT Button. If you don't have AWS IoT Button hardware, you can buy it from Amazon's website. You also need a Wi-Fi hotspot with a supported internet connection.

In general, we can set up AWS IoT Button by performing the following steps:

  1. Register AWS IoT Button to AWS IoT
  2. Connect AWS IoT Button to a network
  3. Test the connectivity

Each step will be presented in the following sections.

Registering AWS IoT Button to AWS IoT

To set up your AWS IoT Button, we should register it on AWS IoT Management Console. Since AWS IoT Button can be treated as a thing, we can perform this registration through a browser with the URL https://console.aws.amazon.com/iot. Please refer to Chapter 4, Building Local AWS Lambda with AWS Greengrass, to register a thing, namely AWS IoT Button.

On successful registration of the button, we will obtain a certificate and public and private key files...

Interaction between AWS IoT Button and IoT devices


We have learned how to communicate with AWS IoT Button. In this section, we will continue developing the IoT application to enable interaction between IoT devices and AWS IoT Button. Our scenario is to apply Raspberry Pi 3 with the attached LED. When AWS IoT Button is clicked, the LED will be lit. Otherwise, the LED will be turned off if AWS IoT Button is double clicked. You can see this scenario in the following image:

To enable accessing AWS IoT from Raspberry Pi 3, you should register it to obtain a certificate, private, and public keys files. We will use them to access the AWS IoT server. We use the same wiring from  Chapter 4, Building Local AWS Lambda with AWS Greengrass. We attach the LED on GPIO 18 (pin 12), as seen in the following image:

For program implementation, we use the Node.js platform. We should install AWS IoT SDK for Node.js. We also need the rpio library to access GPIO that we learned in Chapter 4Building Local AWS...

Building your IoT project with AWS IoT Button


We will continue to develop IoT projects using AWS IoT Button. We will use the Lambda rule and trigger to perform a certain action. For the demo, we save a message from AWS IoT Button into the AWS database, DynamoDB.

You can see this scenario in the following figure. Each button clicked from AWS IoT Button will be filtered and then call AWS Lambda. Inside AWS Lambda, the program will store a message into the database, AWS DynamoDB:

Configuring AWS DynamoDB

Firstly, we create a table on AWS DynamoDB. You can open a browser and navigate to https://console.aws.amazon.com/dynamodb. Then, you can create a new table. For instance, we set the table name as aws-iot-button-db. We also set the primary key as msg-id with the String data type. You can see the AWS DynamoDB table configuration in the following screenshot:

With this we have successfully created AWS DynamoDB on Amazon AWS. Next, we will connect it with AWS Lambda.

Building Lambda and its rule

After...

Summary


We have now learned how to work with AWS IoT Button. We saw how to interact with IoT devices, such as Raspberry Pi 3. We also developed an IoT program, applying other AWS services.

In the next chapter, we will learn how to visualize IoT data on an AWS service.

 

lock icon The rest of the chapter is locked
You have been reading a chapter from
Learning AWS IoT
Published in: Jan 2018 Publisher: Packt ISBN-13: 9781788396110
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}