IoT: In the Cloud

Enter Your Project for a chance to win an Arduino MKR WAN 1300 Kit with a Compatable Lora Gateway or an MKR 1400 GSM with a Shield Combo + a $100 shopping cart!

Back to The Project14 homepage

Project14 Home
Monthly Themes
Monthly Theme Poll

 

My project for Arduino Day 2019 is an autonomous sensor device that reports its battery status to Amazon Web Services.

It uses AWS for data insight, graphs and to indicate how long it's expected to continue living without charging.

It raises an email alarm at near death.

 

This post shows the AWS modules used to store, report and mail, and how they interact.

AWS MQTT Analyze SNS Quicksight flow

 

The connectivity to AWS - safe, with certificate authentication - is covered in its own blog post.

 

The activities I explain here are:

  • Receive metrics from Arduino
  • Enrich the data, add calculations for reporting and alerting
  • Store the enriched data
  • Report and Graph on the stored data
  • Alert on low battery

 

 

Receive

In this part, the data arrives in the AWS domain

 

The messages from the Arduino arrive in the AWS IoT Core module, on the MQTT server, as a JSON payload

 

 

If we don't do anything, the data will get lost. We'll use rules in the same module to decide what to do with the data.

 

Enrich

In this part, we calculate the timestamp of arrival and the active time left in the battery.

 

A rule subscribes to the MQTT topic. It uses SQL to calculate additional info.

That data is then sent onwards for the two different functions:

  • to AWS IoT Analytics for data collection
  • to a new MQTT topic, to prime the alerting functions.

 

 

Store

In this part, the enriched data is sent ot AWS IoT Analytics, where it is stored for later reporting.

 

AWS has several storage options. I'm using a data set in the IoT Analytics module here.

The rule from the previous section streams the data, via a data channel, to the data set.

It's stored here for as long as you define, and can be used in the reporting module later on.

 

You can configure the refresh rate of the data set. If you don't set that up, refresh can be done from the web console.

MQTT messages are volatile. If you want to work with your gizmo's data later on, take care to use one of the AWS services to persist it.

 

 

Report and Graph

In AWS Quicksight, I retrieve the data from IoT analytics. It can be presented, analyzed and shared in various formats.

 

While most of the other modules get data pushed, the reporting module pulls data from the IoT Analytics data set.

 

You can create dashboards, snapshots, etc...

The capture below shows the battery charge % over time, and a silly pie chart with number of messages per charge %.

 

Alert

The AWS SNS (Simple Notification Service)  can send push notifications.

It supports messages to a phone, mails and (also external) web services.

 

I set up an sql filter in IoT Core to only call a rule when the battery authonomy is below 1 day.

When that rule is triggered, it sends the MQTT payload to an SNS topic.

 

 

In SNS, I subscribe to that topic The subscription is configured to shoot a mail to my personal mailbox.

 

I selected RAW format when moving data to SNS. That's why you see the raw payload in the contents.

 

 

Tutorials

 

If you want to make a similar setup, you can check these tutorials and how-to's:

 

image: tutorial map

 

 

Try it!

 

related blog posts
Manage Arduino MKR WIFI 1010 Battery Life in the Cloud - How Long until the Next Recharge?
Arduino MKR WIFI 1010 and Amazon Web Services: Safe MQTT with SSL and Certificate
Project14 | IoT in the Cloud: Make Use of a Wireless Technology and a Cloud Provider!
Keithley DMM6500: Measure Amp-Hours of an Arduino MKR WIFI 1010
Manage Arduino MKR WIFI 1010 Battery Life in the Cloud - AWS, Graphs and Alerts
Arduino MKR 10xx, ETH Shield and Amazon Web Services: Safe MQTT with SSL and Certificate