All Projects → aws-samples → aws-appsync-iot-core-realtime-dashboard

aws-samples / aws-appsync-iot-core-realtime-dashboard

Licence: other
This sample application demonstrates a React based web dashboard receiving real-time updates from IoT sensors. The solution is built with AWS AppSync, AWS Amplify, Amazon Location Service, and AWS IoT Core technologies.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to aws-appsync-iot-core-realtime-dashboard

twitter
A serverless social network that's under development with some cool stuff, such as Serverless Framework, AppSync, GraphQL, Lambda, DynamoDB, Cognito, Kinesis Firehose, and Algolia ☁️
Stars: ✭ 29 (-61.33%)
Mutual labels:  aws-lambda, dynamodb, cognito, appsync
aws-serverless-fullstack-swift-apple-carplay-example
This application demonstrates a full-stack Apple CarPlay app that uses Swift for both the UI and the backend services in AWS. The app accesses Lambda functions written in Swift and deployed from Docker images. The app accesses Amazon Location Service and a 3rd party weather api to display information in the vicinity of the user.
Stars: ✭ 84 (+12%)
Mutual labels:  location-services, amplify, appsync
Aws Iot Chat Example
💬 Chat application using AWS IoT platform via MQTT over the WebSocket protocol
Stars: ✭ 474 (+532%)
Mutual labels:  aws-lambda, dynamodb, aws-iot
voterocket-lab
AWS Summit Dev Labs: Build a modern serverless web application in minutes using the AWS Amplify Framework
Stars: ✭ 23 (-69.33%)
Mutual labels:  amplify, appsync
graphql-ttl-transformer
♻ Enable DynamoDB's time-to-live feature to auto-delete old entries in your AWS Amplify API!
Stars: ✭ 75 (+0%)
Mutual labels:  dynamodb, amplify
photo-sharing-website
Static pre-rendered photo-sharing website
Stars: ✭ 33 (-56%)
Mutual labels:  dynamodb, amplify
Aws Toolkit Eclipse
AWS Toolkit for Eclipse – an open-source plugin for developing, deploying, and managing AWS applications.
Stars: ✭ 252 (+236%)
Mutual labels:  aws-lambda, dynamodb
amplify-material-ui
A Material-UI based implementation of aws amplify
Stars: ✭ 32 (-57.33%)
Mutual labels:  cognito, amplify
enjoytheshow
Real-time facial expression gathering
Stars: ✭ 32 (-57.33%)
Mutual labels:  amplify, appsync
osx-location
🌎 Utility for polling OS X Location Services for current geographic coordinates. Works on Lion or better.
Stars: ✭ 31 (-58.67%)
Mutual labels:  geolocation, location-services
MirrorMirrorOnTheWallSkill
Alexa skill for controlling a MagicMirror²
Stars: ✭ 37 (-50.67%)
Mutual labels:  aws-lambda, aws-iot
super-serverless-sample
Backend serverless que simula o sistema de votação do BBB
Stars: ✭ 30 (-60%)
Mutual labels:  aws-lambda, dynamodb
amazon-ivs-ugc-web-demo
This repository shows how you can build a compelling user-generated content (UGC) live streaming webapp with Amazon IVS.
Stars: ✭ 14 (-81.33%)
Mutual labels:  dynamodb, cognito
amazon-ivs-chime-messaging-ugc-demo
This demo is designed to educate people who want to build live streaming platform with chatting feature. This demo is implemented using Amplify with Amazon IVS, ChimeSDK Messaging.
Stars: ✭ 20 (-73.33%)
Mutual labels:  amplify, amplify-js
serverless-stack-demo-user-mgmt-client
Source for demo app client with user management in Serverless-Stack.com
Stars: ✭ 41 (-45.33%)
Mutual labels:  cognito, amplify
react-amplify-appsync-files-s3
An example project showing how to upload and download public and private images in GraphQL using AppSync and S3
Stars: ✭ 69 (-8%)
Mutual labels:  amplify, appsync
cognito-to-dynamodb-lambda
Copy newly-confirmed users from Cognito to DynamoDB
Stars: ✭ 68 (-9.33%)
Mutual labels:  dynamodb, cognito
Dialetus Service
API to Informal dictionary for the idiomatic expressions that each Brazilian region It has
Stars: ✭ 202 (+169.33%)
Mutual labels:  aws-lambda, dynamodb
Yoyo
A dead simple comment engine built on top of AWS lambda and React, alternative comment service to Disqus.
Stars: ✭ 210 (+180%)
Mutual labels:  aws-lambda, dynamodb
gozeit
GoZeit
Stars: ✭ 19 (-74.67%)
Mutual labels:  dynamodb, cognito

Realtime IoT Dashboard with AWS AppSync and Amazon Location Service

This application demonstrates a web application dashboard receiving real-time updates from a series of IoT sensors. It depicts a fictitious set of pH sensors deployed around the San Francisco Bay. The solution is built with React, AWS AppSync, Amazon Location Service, AWS Amplify, and AWS IoT technologies.

Image description

The sensors are represented as the colored dots. Their color will fluxuate between red, green, and yellow based on the messages received from the sensors.

Click on a sensor to view the detailed values received in realtime from that specific sensor.

Image description

Architecture

Image description

  1. The sensor component is developed with the AWS IoT Device SDK for JavaScript. The sensors are registered as Things in IoT Core and publish random values to the Cloud on a configurable frequency. Metadata about each sensor, such as its geolocation, is stored in a Thing Shadow.

  2. Rules in IoT Core subscribe to the message topic and forward the JSON payload to a Lambda function and the IoT Analytics pipeline.

  3. The Node.js Lambda function executes a GraphQL mutation in AppSync. The mutation saves the sensor's value in DynamoDB and broadcasts the value in real-time to the web dashboard. The Lambda function uses an IAM role and policy to obtain permissions to interact with AppSync.

  4. The React web dashboard application is written in TypeScript and subscribes to the AppSync sensor subscriptions. When new values are received, an Amazon Location Service map is updated in real-time to reflect the new sensor values. The application uses Cognito to authenticate users and allow them to perform the AppSync subscription.

  5. The QuickSight dashboard generates charts and reports for Business Intelligence functions using data from the IoT Analytics timeseries optimized datastore.

Getting Started

Prerequisites

  1. An AWS account in which you have Administrator access.

  2. Node.js (^16.18.0) with NPM (^7.19.1)

  3. Amplify CLI (^6.2.1).

After you have installed and configured Amplify, take note of the AWS profile you selected during the configuration. If you created a profile other than default, you will need the profile name for later steps in the deployment.

Installing

If you run into issues installing or configuring anything in this project please checkout the Troubleshooting section below.

Clone this code repository

$ git clone https://github.com/aws-samples/aws-appsync-iot-core-realtime-dashboard.git

Switch to the project's web folder

$ cd aws-appsync-iot-core-realtime-dashboard/web

Install the web app's Node.js packages

$ npm install

Initialize your Amplify environment

$ amplify init

? Enter a name for the environment: mysandbox
? Choose your default editor: [select your favorite IDE]
? Select the authentication method you want to use: AWS Profile
? Please choose the profile you want to use: default

When you select your profile, make sure to select the same profile you used when configuring Amplify.

Amplify will then begin to provision your account for the project deployment.

Once your account has been provisioned, entering the 'amplify status' command will show you the resources Amplify will create in your account:

$ amplify status

Current Environment: mysandbox

┌──────────────┬──────────────────────┬───────────┬───────────────────┐
│ Category     │ Resource name        │ Operation │ Provider plugin   │
├──────────────┼──────────────────────┼───────────┼───────────────────┤
│ Auth         │ iotdashboard6b12339b │ Create    │ awscloudformation │
├──────────────┼──────────────────────┼───────────┼───────────────────┤
│ Function     │ listsensors          │ Create    │ awscloudformation │
├──────────────┼──────────────────────┼───────────┼───────────────────┤
│ Function     │ getsensor            │ Create    │ awscloudformation │
├──────────────┼──────────────────────┼───────────┼───────────────────┤
│ Function     │ createsensorvalue    │ Create    │ awscloudformation │
├──────────────┼──────────────────────┼───────────┼───────────────────┤
│ Api          │ iotdashboard         │ Create    │ awscloudformation │
├──────────────┼──────────────────────┼───────────┼───────────────────┤
│ Geo          │ iotdashboard         │ Create    │ awscloudformation │
├──────────────┼──────────────────────┼───────────┼───────────────────┤
│ Iotrule      │ createsensorvalue    │ Create    │ awscloudformation │
├──────────────┼──────────────────────┼───────────┼───────────────────┤
│ Iotanalytics │ batch                │ Create    │ awscloudformation │
└──────────────┴──────────────────────┴───────────┴───────────────────┘

Deploy the app infrastructure to your AWS account

$ amplify push

? Are you sure you want to continue? Y
? Do you want to update code for your updated GraphQL API (Y/n) Y

? This will overwrite your current graphql queries, mutations and subscriptions Y

You will then see a series of output messages as Amplify builds and deploys the app's CloudFormation Templates, creating the app infrastucture in your AWS account.

Resources being created in your account include:

  • AppSync GraphQL API
  • DynamoDB Table
  • Cognito User Pool
  • Lambda Functions (3)
  • IoT Rule
  • IoT Analytic
  • Amazon Location Service Map

Install the IoT sensor simulator

Open a new terminal window then switch to the app's sensor folder (aws-appsync-iot-core-realtime-dashboard/sensor).

Install the Node js packages, and run the Node js app to create your sensor as a Thing in AWS IoT Core. It will also create and install the certificates your sensor needs to authenticate to IoT Core.

From the app's sensor folder:

$ npm install
$ node create-sensors.js

*Note - this will create the sensor using your default AWS profile account and region. If you have not specified a default region in your local AWS configuration, it will default to us-east-1.

If you do not have a default profile or you are using a profile other than default, run the app with an AWS_PROFILE environment variable specifiying the profile name you would like to use.

Replace [my-aws-profile] with the name of your profile:

$ AWS_PROFILE=[my-aws-profile] node create-sensor.js

Run the Web App

Start the IoT Sensor

From the sensor terminal window:

$ node index.js

You will see output from the app as it connects to IoT Core and publishes new messages for six sensors every few seconds.

published to shadow topic $aws/things/sensor-sf-north/shadow/update {"state":{"reported":{"name":"SF Bay - North","enabled":true,"geo":{"latitude":37.800307,"longitude":-122.354788}}}}

published to telemetry topic dt/bay-health/SF/sensor-sf-north/sensor-value {"pH":5,"temperature":54.7,"salinity":25,"disolvedO2":6.1,"timestamp":1591831843844}

Start the web app

Switch back to the terminal window pointing to the web folder and run:

$ npm start

This will launch the application in your machine's default web browser.

Sign-up and Sign-in

The web app requires users to authenticate via Cognito. The first screen you will see is a logon screen. Click the Create account link and create a new account using your email address.

Cognito will then email you a confirmation code. Enter this code into the subsequent confirmation screen and logon to the app with your credentials.

Use the Web App

You should now see a screen similar to the one at the top of this guide. If you look at the terminal window running the sensor app, you shoud see the values being published to the Cloud reflected in the web app's sensor gauge in real-time.

From the initial map screen, click on a sensor to navigate to the sensor's detail page.

Build the QuickSight BI Dashboard

Sensor data has been transmitted to both the real-time dashboard and IoT Analytics. We will now use IoT Analytics to build a BI dash board using QuickSight.

Logon to the AWS Console and navigate to the IoT Analytics service and select Data sets from the menu.

Select the bayhealth_app_dataset

Image description

From the Actions menu select Run now to refresh the data set.

Image description

From the AWS Console navigate to the AWS QuickSight service in the North Virginia region.

If you have not registered for QuickSight in your account follow these instructions to configure the service:

  • Enroll for standard edition (if you have not used it before)
  • Click on your login user (upper right) -> Manage QuickSight -> Account Settings -> Add and Remove -> Check IoT Analytics -> Apply
  • Click on QuickSight logo (upper left) to navigate to home page
  • Change the region to your working region

From the QuickSight menu:

  • Select New Analysis -> New data set -> Choose AWS IOT Analytics
  • Select an AWS IoT Analytics dataset to import - Choose bayhealth_app_dataset
  • Click Create data source -> Visualize
  • Select items from the Field List to visulaize
    • Choose sensorId for Y axis
    • Choose all the sensor readings for Value axis
    • Choose average from Value drop down

Image description

Cleanup

Once you are finished working with this project, you may want to delete the resources it created in your AWS account.

From the web folder:

$ amplify delete
? Are you sure you want to continue? (This would delete all the environments of the project from the cloud and wipe out all the local amplify resource files) (Y/n)  Y

From the sensor folder:

$ node delete-sensors.js

Troubleshooting

Installing Amplify

$ npm install -g @aws-amplify/cli

If you receive EACCES permisisons errors, make sure your system is setup properly to install global packages. See this Guide for options.

License

This sample code is made available under a modified MIT-0 license. See the LICENSE file.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].