Sensors and IoT Hub

The AWS IoT Service provides a secure way to connect devices to AWS. Devices can publish events to the IoT Hub for processing by the IoT Rules Engine. The rules engine can store data in DynamoDB, invoke Lambda functions and more.

The AWS IoT service is the boundary between the sensors and the users. The IoT rules respond to sensor events and perform actions which form the inputs of the user systems. In this case that is storing the soil moisture levels DynamoDb and invoking a Lambda function in the notification system.

Web

The monitoring system is a Web based dashboard. The client is a React based Single Page Application (SPA) hosted on Firebase. The backend is a GraphQL endpoint built with API Gateway, Lambda and DynamoDb. Auth0 provides for authentication for the dashboard. Users login through the client and pass a token to the backend.

Notifications

The notifications system sends messages to a Slack channel. The IoT hub invokes a Lambda function for each sensor data event. The Lambda function decides whether or not to send a notification. To notify the client, the decider publishes a message on a SNS topic. The SNS topic invokes another Lambda function which sends a message to Slack.

There are alternative ways to design this system. But this design keeps each Lambda focused on one task. It also makes it easy to add other notifications in the future, Text message, Email, ect.

What’s next

Over the coming weeks I plan on writing about how I implemented each component. The project is far from perfect, but many of the components are already implemented. If you want a sneak peek at the code you can find it on Github. To learn about more about GraphQL and the Serverless Framework try this video course that covers both in-depth.

If you want to read about how I created each component, follow Serverless Zone and myself on Medium or Twitter.

Update: Posts on the components

Myself and the team at A Cloud Guru are building a Serverless training system. If you need to get AWS certified or build Alexa skills sign up and start learning today.