AWS IoT Virtual Hackathon is a 6-day virtual hackathon where you can build your IoT solution using AWS out of the comfort of your own home. The hackathon starts with the kickoff day which includes an introduction to AWS IoT, AWS Lambda, Amazon Kinesis, Amazon QuickSight and Alexa to help you get started with developing your app. In the following days you can leverage this new knowledge to build your IoT solution with the support of the AWS Solution Architects and IoT Specialists.
The participants can build IoT applications with the support of the AWS architects and participate in the competition to win prizes. You can build your idea alone or join forces with others in a team. Ask questions in the chat with possibility of 1:1 sessions on gitter.im. AWS will guide you in the chat.
- Documentation: http://aws-iot-hackathon.com/
- Publish your idea on hackster.io
- Hardware: Raspberry Pi with Rasbian OS or any other preferred OS
Setup your device and connect it to AWS IoT
How does it work in detail: AWS IoT Device SDK, AWS IoT, Thing Registry, Security, Rules Engine, Connecting to other AWS Services
When the package is created: certificate, public and private key is created. Device SDK is installed which helps create connection and work with services in AWS IoT Service.
Details of device: go to the Security section. Certificate created by AWS IoT Service, certificate and a key. Downloaded together with the package and present on device. AWS IoT Service requires certificate and key to make connection to the service. Your device can verify that it is the right AWS IoT Service and the service can also verify your device. We cannot interact with the service just by connecting to them. We allow them to do certain actions with the AWS IoT Policy. You can create more sophisticated policies.
The glue between the policy and the device is attaching a policy to the certificate. You specify what the device may do with the AWS IoT service. Otherwise the device cannot interact with the service.
The device can be subscribed to particular topics.
You can bring your own certification authority to the AWS IoT Service. You can install it into the service. Alternatively you can use the one that comes with the AWS IoT Service.
All the steps to connect your device to the cloud can be done automatically using the quick start or manually.
When a device connects to a service, on AWS Events Subscription you can see that the service is sending messages to the device. You can send sophisticated messages to the cloud from the device.
The message format can be JSON, so that the Rules Engine built into the AWS IoT Service can query messages in JSON format with SQL queries and transfer data to other AWS services. You can define SQL statements and actions to specify to which services you want to send the data, like DynamoDB, NoSQL database, invoke a Lambda function and so on. This is a very simple method to send real sensor data into the cloud for example to create an alarm, like if the temperature is above or below a particular value then send a notification.
Create things and group devices together with thing types in the Thing Registry. Not only sensor but also lightboards.
You can read more about these details here.
IoT Analytics and Big Data with AWS
If you are building IoT apps which should analyze data, you normally have several data to collect, store, analyze and visualize the data.
Use AWS IoT Service to collect data. Use AWS Greengrass to bring IoT to the edge.
After we collect the data, we can transfer the data to services which store data. There are services to analyze and visualize the data. With some services you can store and analyze the data.
Amazon Kinesis consists of three services: Firehose, Analytics and Streams. If you are transferring a lot of data then you open a lot of connections and it might impact the performance, with Firehose you can batch the data together so more datasets are transferred in one transaction. You can process streaming data in real time with Analytics by applying SQL statements on your stream. The last components, Streams, where you have consumers at the end of the streams that process the data in the stream.
- Amazon DynamoDB, a NoSQL database, a service to deliver high scalability
- Amazon Elasticsearch Service
- AWS Lambda to run code in the cloud. Also on Greengrass devices.
- Amazon S3 to store any amount of data from any location on the web.
- Amazon Redshift, managed petabyte scale datahouse.
- Amazon Athena, makes it easy to do adhoc analyses for your data.
- Amazon Quickside, business analytics service.
Example: Data Analysis with Amazon Athena
- Create an empty bucket on S3.
- Create a Kinesis Firehose delivery stream with destination S3, configure S3 buffer and IAM role. Optional: data transformation with AWS Lambda.
- You can use the stream when it gets status is active so it’s ready to send data to S3.
- Go to IoT console to create a topic rule which will transfer data to your device via AWS IoT Service to Kinesis. Create rule query statement, attribute and topic filter. Add action to send messages to an Amazon Kinesis Firehose stream and configure it with a name, the stream information, role to grant access to the Firehose to perform action.
- Transfer data via AWS IoT: on MQTT client subscribe to topic. Go to the script that reads the sensor data and transfers the data to AWS IoT.
- Data is coming in. For troubleshooting, use Monitoring on the Firehose delivery stream.
- Query data with Amazon Athena on S3: go to the Athena console. Create database, create table to use to query the data. Here we use the bucket that should be used to query the data. You can create partitions with Athena to scan only parts of the data, it will be faster and cheaper.
It’s easy to work with the AWS services to collect, transfer and analyze data in a very short time without having to write and test code.
You can read more about here.
IoT Use Cases: Industrial IoT & Smart Home
iRobot with Roomba switched from their own platform to AWS for scalability, global footprint, flexibility, the big AWS ecosystem including the partners running on AWS. Bring Your Own Signing Certificate. Serverless event-based architecture. Mobile application built with API gateway, custom SDK, Lambda functions accessing different resources. Roomba is connected with MQTT.
Most industrial scenarios have equipment, this it the edge to cloud use case. Intel gateways inside each truck connected to AWS IoT with Connected Mine architecture. The trucks can fall over and the mine stands still for a day or more. The tires are very expensive, it is good to know when to replace them. Greengrass inside the truck, GPS location and sensors in the tire and in the truck to measure the vibration. Real time data gathering to find locations where the road has to be fixed to avoid trucks falling over.
From Clouds through Fogs to Devices with AWS Greengrass – Code your Lambdas in the Cloud and Deploy to your Device
The programming model is changing to make it more scalable and to go away from monolithic software architecture. There are a use cases when the data will not reach the cloud. In extreme environments not all the data will reach the cloud.
The same functionality that you have in the cloud is brought to the edge device with Greengrass. We can respond locally to events. We can operate offline. A simplified device programming. Reduce the cost of IoT applications by not having to transfer all the data to the cloud.
Local broker. Same security as AWS IoT, same authorization and authentication. Same device shadow concept. Local Lamba functions.
Greengrass is not a service. It’s just software. You need to bring your own hardware where Greengrass runs on top. Greengrass is meant for edge in a gateway.
How it works?
Available in different regions, Frankfurt for Europe. Go to AWS IoT, Greengrass section. Define Greengrass group, add a Greengrass Core and devices that are communicating with Greengrass Core.
It’s a simple wizard that creates a lot of stuff in the background. This makes it easy to deploy Greengrass for different deployment scenarios.
- Define group with name, core and run a scripted easy group creation
- Connect your Core device, download the certificate with public and private keys, and download the Greengrass software
- Configure Greengrass: upload certificate, private key and upload root-CA.crt to configuration/certs. Go to the configuration file configuration/config.json and configure with the right information.
- Prepare your device for Greengrass: Preparing a Raspberry Pi for Greengrass
- Run Greengrass: ./greengrassd start
- Configure and enable local logging.
- Deploy Lambda function to send data to the cloud. Example: greengrass-hello-world. Go to Actions, Publish new version. Add new, Use existing Lambda function. Configure memory limit, timeout and lifecycle. Make sure that the Lambda function can talk to the cloud. Filter data with a topic. Go to Actions, Deploy.
- Add device that talks to the Greengrass Core. Create Registry entry for device. Download security credentials. Add new subscription so that the device talks to a long running Lambda function that would crunch the data.
Build an Alexa Skill that controls your device through AWS IoT
Create a new Alexa Skill
- Log into developer.amazon.com, select Alexa on the Dashboard
- Add Skill information
- Define interaction model with intents offered in the skill and slots, that are arguments passed to the intent, and sample utterances
- Configure endpoint, e.g. Lambda function, REST API
- For Lambda function
- Configure the trigger to Alexa Skill
- Set the appropriate rights to update the device shadow by creating a new role with the necessary permissions and attach an additional policy (IoT Data Access policy)
- For Lambda function
- Test the Alexa skill
- In the Service Simulator: you get the request and response in JSON format
- For Lambda function: check the logs in the CloudWatch Management Console
- AWS IoT: in the MQTT client
It’s easy to create an Alexa Skill to control an IoT device. It’s a nice feature to wow your audience.
Have fun and start building your own IoT solution!