Coder Social home page Coder Social logo

aws-iot-js-template's Introduction

aws_iot_js_simple_template

This is an attempt to easily perform basic tasks for aws iot core - things. It uses aws-iot-device-sdk-v2 . For more details check aws-sdk

Installation

Use git to clone aws_iot_js_simple_template and npm to install dependencies.

git clone https://github.com/mishrasatyam/aws-iot-js-template.git
cd aws-iot-js-template && npm install

Prerequesties

Make sure your policy allows node js sdk and topics used by you.eg(topic is sensor here):

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "iot:Publish",
        "iot:Receive"
      ],
      "Resource": [
        "arn:aws:iot:ap-south-1:77********36:client/sdk-nodejs-*",
        "arn:aws:iot:ap-south-1:77********36:topic/sensor"
      ]
    },
    {
      "Effect": "Allow",
      "Action": [
        "iot:Subscribe"
      ],
      "Resource": [
        "arn:aws:iot:ap-south-1:77********36:client/sdk-nodejs-*",
        "arn:aws:iot:ap-south-1:77********36:topicfilter/sensor"
      ]
    },
    {
      "Effect": "Allow",
      "Action": [
        "iot:Connect"
      ],
      "Resource": [
        "arn:aws:iot:ap-south-1:77********36:client/sdk-nodejs-*"
      ]
    }
  ]
}

Assuming your thing name is thing1.
You will get files like root-CA.Crt , thing1.cert.pem, thing1.private.pem, thing1.public.key and start.sh .
Put all above files(except start.sh) in files folder.
Edit a config.json mentioning below fields(easily find endpoint and client_id in start.sh) and file paths.eg:

{
    "endpoint":"a*************-ats.iot.ap-*****-1.amazonaws.com",
    "root_ca_cert":"files/root-CA.crt",
    "pem_cert": "files/thing1.cert.pem",
    "private_key":"files/thing1.private.key",
    "client_id":"sdk-nodejs-b*******-4***-4***-a***-1**********b"
}

Usage

node index.js

It will publish a message sending {Temperature:23.65}. You cn edit index.js to customise data as per your needs.

License

MIT

aws-iot-js-template's People

Contributors

mishrasatyam avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.