Author: Hsien-wen "Steven" Deng
See my demo video here
This is a Serverless solution of home automation with different types of IoT devices implemented in Amazon Web Services (AWS). In this case, two type of IoT devices are tested in this application, light and Thermostat. Users can interact with these devices through a client program. User can add, remove or switch a light, and set temperature for a thermostat.
All the actions are taken place in AWS with a serverless architecture. As figure 1 shows, two DynamoDB databases (i.e. Device Database, Event Database) are deployed for devices and events. After the user making an action, the client program will deliver a message through Kinesis Data Stream (KDS) and trigger the Autohome Function. The Autohome function then updates both Device Database and Event Database, and publish a message using MQTT through AWS IoT Core. Devices subscribe to this MQTT topic can then act based on the message. In this case, there are no physical devices deployed, all the presentations only cover client side and cloud side. Nevertheless, physical devices connections are still possible as future extensions.
There are two major components in this branch to help you build up Autohome:
Template: The template includes a system of AWS services allows you to establish this application.
Client Program: The client program is a Python script running to test the availability of your cloud application and interact with IoT devices.
Figure 1. Architecture review of Autohome
- Python 3.8
- AWS Account
AWS Educate may not be eligible due to lack of permission configuring CLI - AWS User Credential
- From AWS Console go to IAM
- Select to users
- Click Add user
- Select Programmatic access for the AWS access type to generate an access key ID and secret access key for use with the AWS API, CLI, SDK, and other development tools
- Select the created user and select Security Credentials tab
- Click Create access key and copy the access key ID and secret access key after a new user is created
For more details, please check: AWS IAM
- AWS CLI
- Download AWS CLI and install
- Open CMD (Windows) or Terminal (Linux):
aws configure
- Input access key ID and secret access key copied from 3
- Configure region (default "us-east-1")
- Configure output (default "json")
For more details, please check: AWS CLI Configuration Guide
- From AWS Console go to CloudFormation
- Click Create stack
- Select Upload a template file and upload Autohome_Template.json
- Input a name and click Create stack
Check you AWS region to be US-EAST-1 (N. Virginia)
- Install boto3:
python -m pip install boto3
- Run Autohome_Client.py:
python Autohome_Client.py
(Linux / OS X)
py Autohome_Client.py
(Windows) - Check the changes you applied
- Through Client Program: Select 4) See Device Database or 5) See Event Database
- Through AWS: You can use both DynamoDB and IoT Core
- DynamoDB
- From AWS Console go to DynamoDB
- Select Tables
- Enter Autohome_collection (Device Database) or Autohome_logs (Event Database)
- Select items to find applied changes
- IoT Core
- From AWS Console go to IoT Core
- Select Test then choose MQTT test client
- Select Subscribe to a topic
- In Topic filter, input
/autohome/topic
- Click the Subsribe button
- DynamoDB
- From AWS Console go to CloudFormation
- Choose target stack
- Delete target stack