Skip to content

AWS Serverless Backend

Dan Lwo edited this page Jul 20, 2017 · 16 revisions

Introduction

The system architecture is shown in the figure above. We use Raspberry Pi & DHT22 as sensor device to send readings to AWS Gateway, then each reading will be sent to AWS DynamoDB to be saved as an item in a table, and simultaneously trigger an AWS Lambda function to exam the reading and send out warning alert when the reading exceed expected range.

AWS DynamoDB

First we need to create a table to store readings. Each table must have a partition key. If two items have the same value in the attribute which is selected as partition key, the later one will overwrite the previous one. To avoid readings being overwritten, we'll give each reading a uniq UUID by using a trick in API Gateway, here we just fill in the partition key space with "UUID", and add "Moment" as sort key (or whichever attribute you want).

Keep in mind that DynamoDB reserved some words for its own use, you can NOT choose these words as names of attributes. Please refer here for the reserved list and details: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ReservedWords.html

If you have a lot of sensor device or you're going to query it a lot, you might need to adjust Write/Read capacity to ensure expected performance.

to be continued...

AWS API Gateway

to be continued...

AWS Lambda

https://github.com/danlwo/Temperature-Humidity-Sensor---Raspberry-Pi-DHT-22-and-AWS-Serverless-Architecture-Backend/blob/master/sensorReadingAlarm

Clone this wiki locally