Demo application for using the AT&T IoT Starter Kit Powered by AWS.
Dependencies: SDFileSystem
Fork of ATT_AWS_IoT_demo by
IoT Starter Kit Powered by AWS Demo
This program demonstrates the AT&T IoT Starter Kit sending data directly into AWS IoT. It's explained and used in the Getting Started with the IoT Starter Kit Powered by AWS on starterkit.att.com.
What's required
- AT&T IoT LTE Add-on (also known as the Cellular Shield)
- NXP K64F - for programming
- microSD card - used to store your AWS security credentials
- AWS account
- Python, locally installed
If you don't already have an IoT Starter Kit, you can purchase a kit here. The IoT Starter Kit Powered by AWS includes the LTE cellular shield, K64F, and a microSD card.
README.md@21:56f91bdacff1, 2016-12-07 (annotated)
- Committer:
- ampembeng
- Date:
- Wed Dec 07 21:15:56 2016 +0000
- Revision:
- 21:56f91bdacff1
- Parent:
- 16:02008a2a2569
- Child:
- 24:224c07ec3bd0
Updated the README to reflect the changes from the last few commits.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ampembeng | 21:56f91bdacff1 | 1 | ############################################################################################################# |
ampembeng | 21:56f91bdacff1 | 2 | Summary |
ampembeng | 21:56f91bdacff1 | 3 | ############################################################################################################# |
ampembeng | 21:56f91bdacff1 | 4 | This demo uses the FRDM-K64F target hardware and the Avnet Shield M14A2A (using AT&T LTE network) to connect |
ampembeng | 21:56f91bdacff1 | 5 | to an Amazon Web Services IoT "thing" (device). The AWS IoT device Shadow will reflect the FRDM LED color |
ampembeng | 21:56f91bdacff1 | 6 | along with FRDM sensor data. The (optional) Python GUI can be used to reflect the Shadow information and |
ampembeng | 21:56f91bdacff1 | 7 | request LED color changes. |
ampembeng | 16:02008a2a2569 | 8 | |
ampembeng | 16:02008a2a2569 | 9 | ############################################################################################################# |
ampembeng | 16:02008a2a2569 | 10 | Resources |
ampembeng | 16:02008a2a2569 | 11 | ############################################################################################################# |
ampembeng | 16:02008a2a2569 | 12 | Getting Started with MBED using FRDM-K64F: (NOTE!!! The FRDM bootloader MUST be updated to work with Windows 10) |
ampembeng | 16:02008a2a2569 | 13 | https://developer.mbed.org/platforms/frdm-k64f/ |
ampembeng | 16:02008a2a2569 | 14 | |
ampembeng | 16:02008a2a2569 | 15 | Avnet IoT Kit quickstart: |
ampembeng | 16:02008a2a2569 | 16 | https://starterkit.att.com/quickstart |
ampembeng | 16:02008a2a2569 | 17 | |
ampembeng | 16:02008a2a2569 | 18 | AWS IoT Interactive Tutorial (what this demo is based on): |
ampembeng | 16:02008a2a2569 | 19 | https://us-west-2.console.aws.amazon.com/iot/home?region=us-west-2#/tutorial/help |
ampembeng | 16:02008a2a2569 | 20 | |
ampembeng | 16:02008a2a2569 | 21 | AWS IoT C-SDK Tutorial (targeted for Raspberry Pi-2): |
ampembeng | 16:02008a2a2569 | 22 | http://docs.aws.amazon.com/iot/latest/developerguide/iot-device-sdk-c.html |
ampembeng | 16:02008a2a2569 | 23 | |
ampembeng | 16:02008a2a2569 | 24 | Python AWS IoT Tutorial: |
ampembeng | 16:02008a2a2569 | 25 | https://github.com/aws/aws-iot-device-sdk-python |
ampembeng | 16:02008a2a2569 | 26 | |
ampembeng | 16:02008a2a2569 | 27 | ############################################################################################################# |
ampembeng | 16:02008a2a2569 | 28 | Demo Quickstart |
ampembeng | 16:02008a2a2569 | 29 | ############################################################################################################# |
ampembeng | 16:02008a2a2569 | 30 | NOTE1: FRDM-K64F bootloader must be updated to work with Windows 10 (otherwise board will reset over and over). |
ampembeng | 16:02008a2a2569 | 31 | |
ampembeng | 16:02008a2a2569 | 32 | FRDM-K64F: |
ampembeng | 16:02008a2a2569 | 33 | 1) This quickstart assumes you've gone through the "Getting Started with MBED using FRDM-K64F" and that you |
ampembeng | 16:02008a2a2569 | 34 | can successfully drag-and-drop binaries to flash the FRDM-K64F device. |
ampembeng | 16:02008a2a2569 | 35 | |
ampembeng | 21:56f91bdacff1 | 36 | |
ampembeng | 16:02008a2a2569 | 37 | AT&T IoT Kit: |
ampembeng | 16:02008a2a2569 | 38 | 1) This quickstart assumes you've gone through the "Avnet IoT Kit quickstart" and your kits sim card has been |
ampembeng | 16:02008a2a2569 | 39 | activated and verified to work with the AT&T LTE network. |
ampembeng | 16:02008a2a2569 | 40 | |
ampembeng | 21:56f91bdacff1 | 41 | |
ampembeng | 16:02008a2a2569 | 42 | Amazon AWS IoT: |
ampembeng | 16:02008a2a2569 | 43 | 1) Create an AWS IoT thing using AWS IoT Console. Makes sure to get your 'thing' certificates. |
mbed_official | 2:270602af41c9 | 44 | |
ampembeng | 21:56f91bdacff1 | 45 | |
ampembeng | 16:02008a2a2569 | 46 | MBED: |
ampembeng | 16:02008a2a2569 | 47 | 1) In the mbed ATT_AWS_IoT_demo project open "network_interface.h" and comment in the following: |
ampembeng | 16:02008a2a2569 | 48 | #define USING_AVNET_SHIELD // NOTE: Make sure you only comment in ONE Network Connection |
ampembeng | 16:02008a2a2569 | 49 | |
ampembeng | 21:56f91bdacff1 | 50 | 2a) Option a (default) - Use an SD card: |
ampembeng | 21:56f91bdacff1 | 51 | a) Format a MicroSD card to use a "FAT32" file system (https://www.sdcard.org/downloads/formatter_4/) |
ampembeng | 21:56f91bdacff1 | 52 | |
ampembeng | 21:56f91bdacff1 | 53 | b) Create a folder on the SD card root named 'certs' |
ampembeng | 21:56f91bdacff1 | 54 | |
ampembeng | 21:56f91bdacff1 | 55 | c) Copy your AWS things certs into this folder. Your file paths should look exactly like this: |
ampembeng | 21:56f91bdacff1 | 56 | /certs/rootCA-certificate.crt |
ampembeng | 21:56f91bdacff1 | 57 | /certs/certificate.pem.crt |
ampembeng | 21:56f91bdacff1 | 58 | /certs/private.pem.key |
ampembeng | 21:56f91bdacff1 | 59 | |
ampembeng | 21:56f91bdacff1 | 60 | d) Create a file in the 'certs' directory named 'mqtt_config.txt', and copy the template below into the file |
ampembeng | 21:56f91bdacff1 | 61 | fill in these parameters with your AWS IoT thing information (minus the brackets): |
ampembeng | 21:56f91bdacff1 | 62 | NOTE: Port is always 8883 (if not using web socket) |
ampembeng | 21:56f91bdacff1 | 63 | AWS_IOT_MQTT_HOST=[1234asdf.iot.us-west-2.amazonaws.com] |
ampembeng | 21:56f91bdacff1 | 64 | AWS_IOT_MQTT_PORT=8883 |
ampembeng | 21:56f91bdacff1 | 65 | AWS_IOT_MQTT_CLIENT_ID=[MyThingName] |
ampembeng | 21:56f91bdacff1 | 66 | AWS_IOT_MY_THING_NAME=[MyThingName] |
ampembeng | 16:02008a2a2569 | 67 | |
ampembeng | 21:56f91bdacff1 | 68 | e) Place SD card into the FRDM-K64F MicroSD slot before powering it on. |
ampembeng | 21:56f91bdacff1 | 69 | |
ampembeng | 21:56f91bdacff1 | 70 | |
ampembeng | 21:56f91bdacff1 | 71 | 2b) Option b - Hard code certs/key and MQTT config: |
ampembeng | 21:56f91bdacff1 | 72 | a) In the mbed ATT_AWS_IoT_demo project open "aws_iot_config.h" and comment out the following #define: |
ampembeng | 21:56f91bdacff1 | 73 | //#define USING_SD_CARD |
ampembeng | 21:56f91bdacff1 | 74 | |
ampembeng | 21:56f91bdacff1 | 75 | b) In the mbed ATT_AWS_IoT_demo project open "aws_iot_config.h" and update the following to match your AWS |
ampembeng | 21:56f91bdacff1 | 76 | IoT 'thing': |
ampembeng | 21:56f91bdacff1 | 77 | #define AWS_IOT_MQTT_HOST |
ampembeng | 21:56f91bdacff1 | 78 | #define AWS_IOT_MQTT_CLIENT_ID |
ampembeng | 21:56f91bdacff1 | 79 | #define AWS_IOT_MY_THING_NAME |
ampembeng | 21:56f91bdacff1 | 80 | |
ampembeng | 21:56f91bdacff1 | 81 | c) In the mbed ATT_AWS_IoT_demo project open "certs.cpp" and update the following to match your AWS 'thing' |
ampembeng | 21:56f91bdacff1 | 82 | private key and IoT certificate. NOTE Make sure the string format matches the format of AWS_IOT_ROOT_CA |
ampembeng | 21:56f91bdacff1 | 83 | (which is pre-populated): |
ampembeng | 21:56f91bdacff1 | 84 | const unsigned char AWS_IOT_CERTIFICATE[] |
ampembeng | 21:56f91bdacff1 | 85 | const unsigned char AWS_IOT_PRIVATE_KEY[] |
ampembeng | 21:56f91bdacff1 | 86 | |
ampembeng | 16:02008a2a2569 | 87 | |
ampembeng | 16:02008a2a2569 | 88 | Python GUI (optional): |
ampembeng | 16:02008a2a2569 | 89 | 1) The Python GUI "ATT_AWS_IoT_Demo_GUI.py" is used to communicate with the 'thing' device shadow, and can |
ampembeng | 16:02008a2a2569 | 90 | be used to request 'desired' and report 'reported' shadow states. This quickstart assumes you've gone |
ampembeng | 16:02008a2a2569 | 91 | through the "Python AWS IoT Tutorial" to the point where you've installed Python 2.7.11 and the libraries |
ampembeng | 16:02008a2a2569 | 92 | required to run the script (paho-mqtt, AWSIoTPythonSDK). |
ampembeng | 16:02008a2a2569 | 93 | |
ampembeng | 21:56f91bdacff1 | 94 | |
ampembeng | 21:56f91bdacff1 | 95 | |
ampembeng | 21:56f91bdacff1 | 96 | 2a) Option a (default) - Use an mqtt_config.txt file: |
ampembeng | 21:56f91bdacff1 | 97 | a) Use the same mqtt_config.txt file from MBED section above. |
ampembeng | 21:56f91bdacff1 | 98 | b) Place the file where Python looks for it: |
ampembeng | 21:56f91bdacff1 | 99 | AWS_MQTT_CONFIG_FILENAME = "C:/Temp/certs/mqtt_config.txt" |
ampembeng | 16:02008a2a2569 | 100 | |
ampembeng | 21:56f91bdacff1 | 101 | 2b) Option b - Hard code the MQTT config: |
ampembeng | 21:56f91bdacff1 | 102 | a) In the ATT_AWS_IoT_Demo_GUI.py script search for the "AWS IoT Config Parameters" and update them so they |
ampembeng | 21:56f91bdacff1 | 103 | match the same 'thing' parameters as the mbed project. |
ampembeng | 21:56f91bdacff1 | 104 | |
ampembeng | 21:56f91bdacff1 | 105 | b) In the Python file change the following variable to TRUE: |
ampembeng | 21:56f91bdacff1 | 106 | hardCodeMQTT = True |
ampembeng | 21:56f91bdacff1 | 107 | |
ampembeng | 21:56f91bdacff1 | 108 | 3) Place your 'thing' certificates into file locations where the Python looks for them. For example: |
ampembeng | 16:02008a2a2569 | 109 | AWS_IOT_ROOT_CA_FILENAME = "C:/Temp/certs/rootCA-certificate.crt" |
ampembeng | 16:02008a2a2569 | 110 | AWS_IOT_PRIVATE_KEY_FILENAME = "C:/Temp/certs/private.pem.key" |
ampembeng | 16:02008a2a2569 | 111 | AWS_IOT_CERTIFICATE_FILENAME = "C:/Temp/certs/certificate.pem.crt" |
ampembeng | 16:02008a2a2569 | 112 | |
ampembeng | 16:02008a2a2569 | 113 | Once all this is setup you should be able to: |
ampembeng | 16:02008a2a2569 | 114 | 1) See the FRDM board start up and connect to Amazon and then create a 'thing' shadow (if there is none). |
ampembeng | 16:02008a2a2569 | 115 | 2) See the FRDM board get the shadow LED color. |
ampembeng | 16:02008a2a2569 | 116 | 3) Press the SW3 button on the FRDM board to cycle the LED color -> (Off R G B W) |
ampembeng | 16:02008a2a2569 | 117 | 4) Use the AWS IoT Console to "Update shadow" to set new 'desired' colors via -> (0 1 2 4 7) |
ampembeng | 21:56f91bdacff1 | 118 | 5) Use the Python GUI buttons to request 'desired' colors. The GUI should also report the "AWS Reported LED Status" |
ampembeng | 21:56f91bdacff1 | 119 | 6) See the FRDM board report the Temperature and Humidity values. |