Skip to content

In this challenge, we're going to learn how to write a serverless .NET Core backend for an IoT device.

Notifications You must be signed in to change notification settings

LambdaSharp/AWS-IoT-Button-Challenge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build a Serverless .NET Core app for the AWS IoT Button

In this challenge, we're going to learn how to write a serverless .NET Core backend for an IoT device. We're going to use the AWS IoT Button, which is a nifty little devices that is very simple to setup and send events to the AWS IoT service. We're then going to define new AWS IoT rules to store events in DynamoDB and send them to a AWS Lambda function for additional processing.

Prerequisites

  1. AWS Tools
    1. Sign-up for an AWS account
    2. Install AWS CLI
  2. .NET Core
    1. Install .NET Core 1.0
    2. Install Visual Studio Code
    3. Install C# Extension for VS Code
  3. AWS C# Lambda Tools
    1. Install Nodejs
    2. Install Yeoman
    3. Install AWS C# Lambda generator: npm install -g yo generator-aws-lambda-dotnet

Level 1: Sending an email from the AWS IoT Button

To begin, let's register the AWS IoT Button and confirm it can communicate with the AWS IoT backend. The followig instructions should get you there.

  1. Get an AWS IoT Button (if not provided)
  2. Install and launch AWS IoT Button mobile app on your mobile device
  3. Register the AWS IoT Button
  4. Select Send Email (nodejs) as action

ACCEPTANCE TEST: Press the AWS IoT Button and confirm that you receive an email!

NOTE: if you get the red blinking LED of doom, see the AWS IoT Button FAQ to determine what it means.

Level 2: Store AWS IoT Button events in DynamoDB

For the second part, we want to enhance the AWS IoT rule that was created in the previous step so that each received event is stored in a DynamoDB table. Make sure to split the message into multiple columns when it is stored. Also, beware that DynamoDB records are uniquely identified by their primary and sort key. Check the AWS IoT SQL syntax for some ideas.

ACCEPTANCE TEST: The AWS IoT button can send three different kind of events: single click, double click, and long click (3 seconds). Each event should be recorded as a new row, giving you a history of all clicks on your AWS IoT Button.

Level 3: Invoke C# AWS Lambda function

For the third part, we want to invoke a C# AWS Lambda function when a long press occurs. When this function is invoked, it should query the DynamoDB table for all records belonging to the button, tally the results and print them on the console (console output is visible in the CloudWatch Logs).

There is a skeleton C# function in src/AWSIoTButton that is ready to be deployed. Assuming you have already stored your default AWS credentials under .aws in your user folder, all you need to do is run:

dotnet lambda deploy-function -fn my-iot-button-function

ACCEPTANCE TEST: Do a sequence of single and double clicks on the AWS IoT Button. Confirm all events are recorded in DynamoDB then do a long click. Confirm in the CloudWatch Logs

Boss Level: Show results in a Console app

For the final part, we want the results of the C# Lambda function to be displayed on a console screen. Details of the implementation are left as an exercise to the reader.

ACCEPTANCE TEST: Do a sequence of single and double clicks on the AWS IoT Button. Do a long click. Confirm the result is shown to everyone and that all the records are gone from the DynamoDB table.

About

In this challenge, we're going to learn how to write a serverless .NET Core backend for an IoT device.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages