How alvurama/iniciando_aws_iot works
Project Type and Purpose
• This is an end-to-end AWS IoT tutorial repository that walks through three exercises:
• Exercise 1: Simulate an MQTT device in Python using AWSIoTPythonSDK.
• Exercise 2: Implement a real MQTT device on NodeMCU ESP8266 using Arduino IDE.
• Exercise 3: Define AWS IoT Core rules to route incoming MQTT messages into DynamoDB, SNS (SMS/email notifications) and SQS.
• It is not a monolithic web app or microservice suite, but rather an IoT‐focused reference architecture showing how devices connect securely over MQTT, and how the cloud ingests and processes streams of IoT data.
File Structure Analysis
• Top-level artifacts:
• README.md and supporting markdown docs (NodeMCU_ESP8266.md, instalarOpenSSL.md) for setup.
• ejercicio1.py (and duplicate under ejericio1/) – the Python simulator.
• ejercicio2.txt – the Arduino C++ sketch for the ESP8266.
• arduino/ folder (three sample sensor sketches) shows evolution of firmware.
• libreria/NTPClient contains a custom fork of the NTP Client library used on the ESP8266 to timestamp messages.
Main Components to Capture
A. Devices (Edge Components)
– Python Simulator (ejercicio1.py) running on desktop, using AWSIoTPythonSDK.
– NodeMCU ESP8266 device running Arduino sketch, with SPIFFS‐stored DER certificates and libraries: FS.h, ESP8266WiFi, PubSubClient, NTPClient.
B. Security Artifacts
– X.509 Certificates (certificate.pem, privateKey.pem, rootCA.pem) converted to DER for the ESP8266.
– AWS IoT Thing object (“objeto1”), associated policy (least privilege * for tutorial), attached certificate.
C. AWS IoT Core
– MQTT Broker endpoint (e.g., data.iot.us-west-2.amazonaws.com:8883).
– Rules Engine that evaluates incoming topics (“data”) against SQL queries.
D. AWS Back-End Services
– DynamoDB table “iot-prueba” for all messages.
– Amazon SNS Topic “SNSAlerta” with SMS/email subscriptions.
– Amazon SQS Queue “ColaAlertaIot” subscribed to the SNS topic (for durable message buffering).
E. AWS Console / MQTT Test Client
– Cloud-side test MQTT client under “Test” to subscribe to topic “data” and validate payload.
Relationships and Data Flow
1. Edge devices (Python app or ESP8266) →(MQTT over TLS with X.509 certs)→ AWS IoT Core
2. On receipt of messages on topic “data”:
• Rule 1: INSERT ALL payload fields → DynamoDB (“iot-prueba”)
• Rule 2: IF payload.Temperatura > 40 → publish raw alert message to SNSAlerta
3. SNSAlerta → delivers SMS/email → fan-out to SQS queue (ColaAlertaIot)
4. (Optional) Cloud user inspects DynamoDB table via console or polls SQS for downstream processing
Architectural Patterns and Design Principles
• Publish/Subscribe (MQTT broker) decouples producers (devices) from consumers (cloud rules).
• Event-Driven Rules Engine routes messages without custom code.
• Secure IoT: mutual TLS authentication with device certificates; certificate and policy lifecycle managed in AWS IoT Core.
• Separation of concerns:
• Edge code (device firmware & simulation) vs.
• Cloud ingestion & storage vs.
• Notification & queueing.