Skip to content

aws-samples/aws-iot-esp32-arduino-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

AWS IoT + esp32

This project contains several Arduino examples for AWS IoT projects using ESP32 Wi-Fi+BLE based development modules.

Arduino support for ESP32 modules can be found here.

For each example you will need to register an AWS IoT device and create credentials.

Each example has a "secrets.h" file where Wi-Fi and device credentials are to be stored.

Required Parameters:

  • WIFI_SSID: The name of the Wi-Fi network to connect to. Should not include special characters or spaces.
  • WIFI_PASSWORD: The password of the Wi-Fi network to connect to.
  • THINGNAME: Must match the name of the device in the AWS IoT console.
  • AWS_IOT_ENDPOINT: The endpoint associated with your AWS IoT Core account.
  • AWS_CERT_CA: Amazon Root CA 1
  • AWS_CERT_CRT: AWS IoT Thing Certificate
  • AWS_CERT_PRIVATE: AWS IoT Thing Private Key

Required Arduino Libraries:

Examples:

  • basic-pubsub: Connects to AWS IoT. Demonstrates subscribing to and publishing to topics. Works great with the lambda-iot-rule serverless application.
  • thermal-printer: Connects to AWS IoT and subscribes to a topic. Prints messages out to a physical receipt printer.
  • spectral-sensor: This example connects a Sparkfun Spectral Triad (AS7265x) sensor to an Arduino connected to AWS IoT. This sensor examines light absorption on various wavelengths across IR, UV, and visible light. These values can be used to detect different materials.

M5Stick Examples:

  • m5stick-lcd: Connect an M5Stick to AWS IoT and display messages on its built in LCD.
  • m5stick-env: Publish magnetic compass heading, temperature, barometric pressure, and humidity to AWS IoT using an M5Stick with the ENV hat module.

Sample AWS IoT Policy

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "iot:Connect",
      "Resource": "arn:aws:iot:REGION:ACCOUNT_ID:client/THINGNAME"
    },
    {
      "Effect": "Allow",
      "Action": "iot:Subscribe",
      "Resource": "arn:aws:iot:REGION:ACCOUNT_ID:topicfilter/esp32/sub"
    },
	{
      "Effect": "Allow",
      "Action": "iot:Receive",
      "Resource": "arn:aws:iot:REGION:ACCOUNT_ID:topic/esp32/sub"
    },
    {
      "Effect": "Allow",
      "Action": "iot:Publish",
      "Resource": "arn:aws:iot:REGION:ACCOUNT_ID:topic/esp32/pub"
    }
  ]
}

Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: MIT-0