The demo is based on the humidity sensor (DHT11) readings which is attached to a Raspberry PI GPIO. The readings are sent/received via MQTT protocol and the AWS IoT cloud service stores the values in a database and also alerts the user on the event of a critical value from the sensor.

topologia aws iot

At the beginning it´s necessary to do the sensor onboarding process which creates a SDK (in this case a Linux/Python one) to be installed wherever the sensor is attached . This SDK enables a relationship among the device, a digital certificate and the policies, all through a script to be executed.
The digital certificate´s role is to authenticate a device with AWS IoT.
The policies allow the authorization to the IoT operations like HTTP or MQTT.

In more detail the script runs a program called basicPubSub.py, that publish MQTT messages to AWS using the certificate and the keys obtained during the onboard process.
This program has the definition for the MQTT topic, the data and frequency for the publishing. We also configure this program to adjust the payload format to JSON or any other preferred one.

Due to the NoSQL database (DynamoDB) integration (made by a SQL query and a rule) it´s possible to store all values published by MQTT. In order to store only critical values it is necessary to create a condition within the rule, for instance: humidity > 80%  would trigger a database feed.

At last, similar to the DynamoDB feed, AWS SNS service is able to send e-mail messages or SMS´s in case of “critical” values whenever they occur.

A practical application would use the sensor to notice and alert whenever an environment is suffering from mold due to an increasing humidity. For this demo I assume 70% as a critical value for humidity which must be informed to the user by e-mail. I put the sensor inside a plastic cup of water to check the increasing humidity.