How aws-samples/aws-iot-core-lorawan works
Project type and purpose
• This is a “sample-solutions” monorepo for AWS IoT Core for LoRaWAN.
• It provides multiple reference architectures and code samples (Python/Node.js) for:
• Binary payload decoding (transform_binary_payload, cayenneLPPDecoder, etc.)
• Downlink messaging (send_downlink_payload)
• Thing shadow updates (iotthingshadow)
• Telemetry visualization (timestream, timestream_for_transform_binary_payload)
• Condition monitoring and alarm workflows (soilmoisture_alarming, gateway_watchdog)
• Automation scripts (automation/*) and observability guidelines (observability)
File structure
• Top-level folders each represent an independent sample or pattern.
• Most samples follow AWS Serverless + IoT Rule Engine + Lambda:
• src-<component> directories contain Lambda functions (app.py or index.js).
• template.yaml or CDK stacks describe infrastructure.
• Some modules use AWS CDK (gateway_watchdog) or raw CloudFormation/SAM (template.yaml).
• automation/ holds CLI- and Boto3-based scripts executed outside AWS (batch device/gateway registration).
• Observability guidelines are documentation only.
Key insights from README
• The core flow: LoRaWAN Devices → Gateways → AWS IoT Core for LoRaWAN → IoT Core message broker → IoT Rules → Lambda → downstream AWS services.
• Each sample wires IoT Rules to specific actions: e.g. transform payload, write to Timestream, update Thing Shadow, send SNS/SMS.
• Decoders exist as standalone JS/Python libraries, some packaged as Lambda layers.
a. Main components
• LoRaWAN Devices (end-nodes)
• LoRaWAN Gateways
• AWS IoT Core for LoRaWAN service (network server)
• AWS IoT Core (message broker + Rules Engine)
• Lambda functions (decoders, transformers, metrics publishers)
• Downstream services: Amazon Timestream, AWS IoT Events, AWS IoT Thing Shadows, Amazon SNS/SMS, CloudWatch Metrics, Grafana plugin, Pilot Things Sensor Library (external SaaS)
• Automation clients (local scripts using AWS CLI / Boto3)
b. Relationships & data flow
1. Device → Gateways: radio uplink
2. Gateway → AWS IoT Core for LoRaWAN: MQTT over Internet
3. IoT Core for LoRaWAN → AWS IoT Core broker: Pub/Sub topics
4. IoT Rules Engine → invokes Lambdas based on topic filters
5. Lambda decoders/transformers → JSON → route to downstream service via SDK/API
6. Downlink path (reverse): Clients or Lambdas → AWS IoT Core → LoRaWAN Network → Device
c. Architectural patterns
• Event-driven: IoT Rules trigger micro-Lambdas.
• Serverless: minimal servers, pay-per-use.
• Infrastructure as code: SAM template.yaml or AWS CDK stack.py definitions.
• Modular decoders: language-agnostic, shareable libraries/layers.
• CI/CD / code scanning: GitHub Actions (codeql-analysis.yml), CodeBuild badge.
d. Key technologies & frameworks
• AWS LoRaWAN managed network
• AWS IoT Core & Rules Engine
• AWS Lambda (Python, Node.js)
• AWS CDK (Python) and SAM/CloudFormation
• AWS SDK (Boto3, AWS CLI)
• Storage & analytics: Amazon Timestream, Grafana plugin, CloudWatch, IoT Events, SNS
• External: Pilot Things Sensor Library