├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── images
├── AWS-IOT-Sensors-QR.png
└── AWS-IoT-Sensors.png
└── node-javascript
├── .gitignore
├── README.md
├── index.js
└── package.json
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | ## Code of Conduct
2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
4 | opensource-codeofconduct@amazon.com with any additional questions or comments.
5 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing Guidelines
2 |
3 | Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional
4 | documentation, we greatly value feedback and contributions from our community.
5 |
6 | Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
7 | information to effectively respond to your bug report or contribution.
8 |
9 |
10 | ## Reporting Bugs/Feature Requests
11 |
12 | We welcome you to use the GitHub issue tracker to report bugs or suggest features.
13 |
14 | When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already
15 | reported the issue. Please try to include as much information as you can. Details like these are incredibly useful:
16 |
17 | * A reproducible test case or series of steps
18 | * The version of our code being used
19 | * Any modifications you've made relevant to the bug
20 | * Anything unusual about your environment or deployment
21 |
22 |
23 | ## Contributing via Pull Requests
24 | Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:
25 |
26 | 1. You are working against the latest source on the *main* branch.
27 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already.
28 | 3. You open an issue to discuss any significant work - we would hate for your time to be wasted.
29 |
30 | To send us a pull request, please:
31 |
32 | 1. Fork the repository.
33 | 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
34 | 3. Ensure local tests pass.
35 | 4. Commit to your fork using clear commit messages.
36 | 5. Send us a pull request, answering any default questions in the pull request interface.
37 | 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
38 |
39 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
40 | [creating a pull request](https://help.github.com/articles/creating-a-pull-request/).
41 |
42 |
43 | ## Finding contributions to work on
44 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start.
45 |
46 |
47 | ## Code of Conduct
48 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
49 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
50 | opensource-codeofconduct@amazon.com with any additional questions or comments.
51 |
52 |
53 | ## Security issue notifications
54 | If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue.
55 |
56 |
57 | ## Licensing
58 |
59 | See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.
60 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT No Attribution
2 |
3 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so.
10 |
11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
13 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
15 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
16 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## AWS IoT Sensors
2 |
3 | This repository provides sample code to help customers easily connect to [AWS IoT Core](https://aws.amazon.com/iot-core/) and learn more about how the AWS IoT Sensors mobile app publishes sensor data from mobile phones to AWS.
4 |
5 | AWS IoT Sensors is a mobile app available on the [Apple App Store](https://apps.apple.com/app/id6447531633) and [Google Play](https://play.google.com/store/apps/details?id=com.amazon.aws.awsiotsensors).
6 |
7 | ### Scan the QR code to download the app.
8 |
9 |
10 |
11 | AWS IoT Sensors enables you to easily collect, and visualize data from sensors on your mobile device using [AWS IoT Core](https://aws.amazon.com/iot-core/) and related services like [Amazon Location Service](https://aws.amazon.com/location/). With a single click, you can start streaming sensor data from your mobile device to AWS IoT Core and view real-time visualizations in the app and on a web dashboard.
12 |
13 | AWS IoT Sensors supports built-in sensors, including accelerometer, gyroscope, magnetometer, barometer, and GPS. It provides a frictionless way for you to use AWS IoT Core without needing an AWS account, credit card, or prior AWS or IoT experience. The app is designed for ease-of-use and to showcase how AWS IoT can be leveraged to collect, process, and visualize sensor data for IoT applications.
14 |
15 | ## Screenshots
16 |
17 |
18 |
19 | ## Contributing
20 |
21 | See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.
22 |
23 | ## License
24 |
25 | This library is licensed under the MIT-0 License. See the LICENSE file.
26 |
27 |
--------------------------------------------------------------------------------
/images/AWS-IOT-Sensors-QR.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-iot-sensors/e816dd114fd9e9c687e84abf54b19f55c6553fe5/images/AWS-IOT-Sensors-QR.png
--------------------------------------------------------------------------------
/images/AWS-IoT-Sensors.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-iot-sensors/e816dd114fd9e9c687e84abf54b19f55c6553fe5/images/AWS-IoT-Sensors.png
--------------------------------------------------------------------------------
/node-javascript/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | package-lock.json
--------------------------------------------------------------------------------
/node-javascript/README.md:
--------------------------------------------------------------------------------
1 | # AWS IoT Sample Code with Node.js and Javascript
2 |
3 | This repository contains a single Javascript file that will connect to AWS IoT core using the MQTTS open protocol using certificates.
4 |
5 | ## Pre-requisites
6 | * npm (v9.8.1+)
7 | * Node.js (v18.17.0+)
8 | * [AWS Account](https://portal.aws.amazon.com/gp/aws/developer/registration/index.html?nc2=h_ct&src=header_signup)
9 |
10 | ## Getting Started
11 | 1. [Create an AWS IoT Core instance](https://docs.aws.amazon.com/iot/latest/developerguide/iot-gs.html#aws-iot-get-started)
12 | 2. [Retrieve certificates for connection](https://docs.aws.amazon.com/iot/latest/developerguide/device-certs-create.html) and put them into this folder
13 | 3. Inside `index.js` replace line 5 to 8 with your own values
14 | 4. Run `node index.js` to start publishing sample data!
--------------------------------------------------------------------------------
/node-javascript/index.js:
--------------------------------------------------------------------------------
1 | const mqtt = require("mqtt");
2 | const fs = require("fs");
3 |
4 | // REPLACE THE FOLLOWING WITH YOUR OWN VALUES
5 | const BROKER = "YOUR BROKER ENDPOINT"// should look similar to: example-ats.iot.us-east-1å.amazonaws.com;
6 | const THING_NAME = "YOUR THING NAME"
7 | const CERT_FILE_NAME = "YOUR CERTIFICATE FILE NAME (PEM)"
8 | const PRIVATE_KEY_FILE_NAME = "YOUR PRIVATE KEY FILE NAME (PEM"
9 |
10 |
11 | const options = {
12 | rejectUnauthorized: false,
13 | port: 8883,
14 | host: BROKER,
15 | clientId: THING_NAME,
16 | cert: fs.readFileSync(`./${CERT_FILE_NAME}`, "utf8"),
17 | key: fs.readFileSync(`./${PRIVATE_KEY_FILE_NAME}`, "utf8"),
18 | connectTimeout: 10_000,
19 | };
20 | const client = mqtt.connect(`mqtts://${BROKER}`, options);
21 |
22 | client.on("connect", () => {
23 | console.log("connected");
24 | setInterval(function() {
25 | console.log(new Date().getSeconds())
26 | client.publish(THING_NAME, JSON.stringify([
27 | {
28 | "label": "Accelerometer",
29 | "display_type": "line_graph",
30 | "unit": "meters",
31 | "values": [
32 | {
33 | "value": Math.floor(Math.random() * 101),
34 | "label": "x"
35 | },
36 | {
37 | "value": Math.floor(Math.random() * 101),
38 | "label": "y"
39 | },
40 | {
41 | "value": Math.floor(Math.random() * 101),
42 | "label": "z"
43 | }
44 | ]
45 | },
46 | {
47 | "label": "Gyroscope",
48 | "display_type": "line_graph",
49 | "unit": "meters",
50 | "values": [
51 | {
52 | "value": Math.floor(Math.random() * 101),
53 | "label": "x"
54 | },
55 | {
56 | "value": Math.floor(Math.random() * 101),
57 | "label": "y"
58 | },
59 | {
60 | "value": Math.floor(Math.random() * 101),
61 | "label": "z"
62 | }
63 | ]
64 | },
65 | {
66 | "label": "Battery",
67 | "display_type": "donut_graph",
68 | "unit": "%",
69 | "values": [
70 | {
71 | "value": 72,
72 | "label": "Charged"
73 | }
74 | ]
75 | },
76 | {
77 | "label": "GPS",
78 | "display_type": "map",
79 | "unit": "",
80 | "values": [
81 | {
82 | "value": -122.33328,
83 | "label": "Longitude"
84 | },
85 | {
86 | "value": 47.61544,
87 | "label": "Latitude"
88 | },
89 | {
90 | "value": 118732,
91 | "label": "Accuracy (m)"
92 | }
93 | ]
94 | }
95 | ]));
96 | }, 1000);
97 | });
98 |
99 | client.on("reconnect", () => {
100 | console.warn('reconnecting')
101 | })
--------------------------------------------------------------------------------
/node-javascript/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "aws-iot-node-js-sample",
3 | "version": "1.0.0",
4 | "description": "Sample code for AWS IoT services with NodeJs and Javascript",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "",
10 | "license": "",
11 | "dependencies": {
12 | "mqtt": "^5.3.1"
13 | }
14 | }
15 |
--------------------------------------------------------------------------------