A (human) index that likes to code
Also drinks way too much coffee
Published Sep 05, 2019 19:30
In theory, this tutorial is out of scope if we’re talking about the title; however, this tutorial is crucial, because it completes the entire IoT stack. In this tutorial, you will be building on whatever you have done in Part I and Part II, to build application logic that makes decisions and commands the IoT actuators based on information obtained via sensors.
The previous tutorials, Part I and Part II, must be done.
Click on IAM | Source: Me
Roles | Source: Me
Create a role | Source: Me
Choosing the service to use the role | Source: Me
AWSLambdaBasicexecutionRole | Source: Me
AmazonDynamoDBFullAccess | Source: Me
AWSIoTDataAccess | Source: Me
Next: Review | Source: Me
Create the role with a name | Source: Me
Click on Lambda | Source: Me
Creating a function for new users | Source: Me
Creating a function for existing users | Source: Me
Fill in the fields, and create the function | Source: Me
Fill in the code for the lambda function | Source: Me
TABLE_NAME
, IOT_ENDPOINT
, and IOT_PUBLISH_TOPIC
based on the DynamoDB table name, your IoT endpoint, and the topic subscribed by the ESP32.
Set environment variables | Source: Me
Save the lambda function | Source: Me
Click on IoT Core | Source: Me
IoT Core | Source: Me
Act | Source: Me
Click on IoT rule created previously
Add another action | Source: Me
Adding a lambda action | Source: Me
Select the correct lambda function | Source: Me
Similar to how it was done in Part II, go to the DynamoDB table and refresh the contents. Count the number of records currently on the table, and press the ‘BOOT’ button on the ESP32 until that count reaches a multiple of 10. The led of the ESP32 should light up only when there is a multiple of 10, otherwise, it will be turned off.
The lambda script you pasted earlier is in charge of causing this to happen; firstly, it will obtain device data. Then, it will make a decision based on the device data; in this case, “is the number of records a multiple of 10? If so, turn on the led, else, turn it off”.
Try connecting multiple ESP32s to the same topics, and see what happens when one of the devices are used to make the number of records reach a multiple of 10!
Congratulations! You have made a full IoT application, starting from Part I: Controlling stuff, to Part II: Collecting data and finally, to Part III: Making decisions. Experiment with this a little bit more, and build the next big thing; you now have the basic skills required to do that on AWS!
If you found this trilogy useful, please do share it with your friends.
Until next time!
Happy Coding,
CodingIndex